fix specs in contact
This commit is contained in:
parent
bb19531195
commit
acf6936d7c
1 changed files with 2 additions and 2 deletions
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
class Contact < ActiveRecord::Base
|
class Contact < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
validates_presence_of :user
|
|
||||||
|
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
validates :person, :presence => true
|
validates :person, :presence => true
|
||||||
|
|
@ -18,6 +17,7 @@ class Contact < ActiveRecord::Base
|
||||||
validate :not_contact_for_self,
|
validate :not_contact_for_self,
|
||||||
:not_blocked_user
|
:not_blocked_user
|
||||||
|
|
||||||
|
validates_presence_of :user
|
||||||
validates_uniqueness_of :person_id, :scope => :user_id
|
validates_uniqueness_of :person_id, :scope => :user_id
|
||||||
|
|
||||||
before_destroy :destroy_notifications,
|
before_destroy :destroy_notifications,
|
||||||
|
|
@ -101,7 +101,7 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def not_blocked_user
|
def not_blocked_user
|
||||||
if user.blocks.where(:person_id => person_id).exists?
|
if user && user.blocks.where(:person_id => person_id).exists?
|
||||||
errors[:base] << 'Cannot connect to an ignored user'
|
errors[:base] << 'Cannot connect to an ignored user'
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue