Skip to content

Commit

Permalink
Don't leak uniqueness validation into other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneius committed Nov 15, 2020
1 parent eb7cf21 commit 2860be3
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,18 @@ def test_validate_uniqueness_with_object_scope
end

def test_validate_uniqueness_with_polymorphic_object_scope
Essay.validates_uniqueness_of(:name, scope: :writer)
repair_validations(Essay) do
Essay.validates_uniqueness_of(:name, scope: :writer)

a = Author.create(name: "Sergey")
p = Person.create(first_name: "Sergey")
a = Author.create(name: "Sergey")
p = Person.create(first_name: "Sergey")

e1 = a.essays.create(name: "Essay")
assert e1.valid?, "Saving e1"
e1 = a.essays.create(name: "Essay")
assert e1.valid?, "Saving e1"

e2 = p.essays.create(name: "Essay")
assert e2.valid?, "Saving e2"
e2 = p.essays.create(name: "Essay")
assert e2.valid?, "Saving e2"
end
end

def test_validate_uniqueness_with_composed_attribute_scope
Expand Down

0 comments on commit 2860be3

Please sign in to comment.