Skip to content

Commit

Permalink
Add Relationship validations and fix tests (No issue opened) (#2078)
Browse files Browse the repository at this point in the history
* Refactor code for user's social links

* Fix Relationship tests

* Add validations to Relationship model
  • Loading branch information
seafr authored and jywarren committed Feb 1, 2018
1 parent 69e0a39 commit e682250
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ class Relationship < ActiveRecord::Base
attr_accessible :followed_id, :follower_id
belongs_to :follower, class_name: 'User'
belongs_to :followed, class_name: 'User'
validates :followed_id, presence: true
validates :follower_id, presence: true
end
4 changes: 2 additions & 2 deletions test/unit/relationship_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def setup

test 'should require follower_id' do
@relationship.follower_id = nil
assert @relationship.valid?
assert_not @relationship.valid?
end

test 'should require followed_id' do
@relationship.followed_id = nil
assert @relationship.valid?
assert_not @relationship.valid?
end
end

0 comments on commit e682250

Please sign in to comment.