-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add uniqueness validation on Endpoint#url #12068
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,16 @@ | |
end | ||
end | ||
end | ||
|
||
context "Uniqueness validation on :url" do | ||
it "is not required" do | ||
expect(Endpoint.create!).to be_truthy | ||
expect(Endpoint.create!).to be_truthy | ||
end | ||
|
||
it "raises when provided and already exists" do | ||
Endpoint.create!(:url => "abc") | ||
expect { Endpoint.create!(:url => "abc") }.to raise_error("Validation failed: Url has already been taken") | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, I'm indifferent about these specs. You're essentially testing that ActiveRecord does it's job (which is also why I'm generally against shoulda-matchers. Are you sure you want to add these db writes to the tests? Your choice but thought I'd throw my thoughts out there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I was on the fence about writing them since it is just testing rails validations. My only argument for these kinds of tests is that it shows the intent of the validations for people making future changes. It's essentially testing this use case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alrighty 👍 |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grumble. I guess.