Skip to content

Commit

Permalink
Ticket CV2-5653 [WIP]: Fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Nov 23, 2024
1 parent 5da8e26 commit dd58419
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/models/relationship_2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def teardown
pm1 = create_project_media team: t
pm2 = create_project_media team: t
pm3 = create_project_media team: t
pm4 = create_project_media team: t

# Create a relationship between two items
assert_difference 'Relationship.count' do
Expand All @@ -434,13 +435,6 @@ def teardown
end
end

# If an item is already a parent, it can't be a child in another relationship
assert_no_difference 'Relationship.count' do
assert_raises ActiveRecord::StatementInvalid do
create_relationship source_id: pm3.id, target_id: pm1.id
end
end

# If an item is already a child, it can't be a child in another relationship
assert_no_difference 'Relationship.count' do
assert_raises ActiveRecord::StatementInvalid do
Expand All @@ -455,10 +449,17 @@ def teardown
end
end

# If an item is already a parent, it can't be a child in another relationship - move targets to new relationship
assert_equal 1, Relationship.where(source_id: pm1.id).count
assert_equal 0, Relationship.where(source_id: pm3.id).count
create_relationship source_id: pm3.id, target_id: pm1.id
assert_equal 0, Relationship.where(source_id: pm1.id).count
assert_equal 2, Relationship.where(source_id: pm3.id).count

# If an item is already a parent, it can still have another child
assert_difference 'Relationship.count' do
assert_nothing_raised do
create_relationship source_id: pm1.id, target_id: pm3.id
create_relationship source_id: pm3.id, target_id: pm4.id
end
end
end
Expand Down

0 comments on commit dd58419

Please sign in to comment.