mapping spec
This commit is contained in:
parent
b3f8f6652a
commit
fa3a725df9
2 changed files with 12 additions and 3 deletions
|
@ -4,10 +4,13 @@ class Mapping < ActiveRecord::Base
|
|||
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
|
||||
|
||||
belongs_to :mappable, polymorphic: true
|
||||
|
||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
||||
|
||||
belongs_to :user
|
||||
|
||||
validates :xloc, presence: true
|
||||
validates :yloc, presence: true
|
||||
validates :map, presence: true
|
||||
validates :mappable, presence: true
|
||||
|
||||
def user_name
|
||||
self.user.name
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mapping, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
it { is_expected.to belong_to :user }
|
||||
it { is_expected.to belong_to :map }
|
||||
it { is_expected.to belong_to :mappable }
|
||||
it { is_expected.to validate_presence_of :xloc }
|
||||
it { is_expected.to validate_presence_of :yloc }
|
||||
it { is_expected.to validate_presence_of :map }
|
||||
it { is_expected.to validate_presence_of :mappable }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue