-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple tests for relationships, following and unfollowing added.
- Loading branch information
1 parent
be13d2d
commit 2f8e925
Showing
6 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
class Relationship < ActiveRecord::Base | ||
belongs_to :follower, class_name: "User" | ||
belongs_to :followed, class_name: "User" | ||
validates :follower_id, presence: true | ||
validates :followed_id, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
follower_id: 1 | ||
followed_id: 1 | ||
|
||
two: | ||
follower_id: 1 | ||
followed_id: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
require 'test_helper' | ||
|
||
class RelationshipTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
|
||
def setup | ||
@relationship = Relationship.new(follower_id: 1, followed_id: 2) | ||
end | ||
|
||
test "should be valid" do | ||
assert @relationship.valid? | ||
end | ||
|
||
test "should require a follower_id" do | ||
@relationship.follower_id = nil | ||
assert @relationship.invalid? | ||
end | ||
|
||
test "should require a followed_id" do | ||
@relationship.followed_id = nil | ||
assert @relationship.invalid? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters