-
-
Notifications
You must be signed in to change notification settings - Fork 911
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 required/optional qual's to belongs_to/has_one #1058
Conversation
|
||
message = | ||
'Expected Child to have a belongs_to association called parent ' + | ||
'(the association should have been defined with `optional: true`, ' + |
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.
Line is too long. [81/80]
@@ -279,13 +279,92 @@ | |||
end | |||
end | |||
|
|||
def belonging_to_parent(options = {}) | |||
define_model :parent | |||
context 'given an association with neither :required nor :optional specified' do |
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.
Line is too long. [84/80]
) | ||
|
||
if diff | ||
lines << "Diff:" |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -6,6 +6,8 @@ | |||
require "shoulda/matchers/active_record/association_matchers/order_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/through_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/dependent_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/required_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/optional_matcher" |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -6,6 +6,8 @@ | |||
require "shoulda/matchers/active_record/association_matchers/order_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/through_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/dependent_matcher" | |||
require "shoulda/matchers/active_record/association_matchers/required_matcher" |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Rails 5 made two changes to `belongs_to` associations: * `required` and `optional` were added as options (which add and remove a presence validation on the association, respectively) * `required` was made the default In addition, a `required` option was also added to `has_one`. These new qualifiers allow us to test these options appropriately. Credit: Shia <rise.shia@gmail.com>
dd37208
to
3af3d9f
Compare
@guialbuk Would you mind reviewing this? :) |
Rails 5 made two changes to
belongs_to
associations:required
andoptional
were added as options (which add and removea presence validation on the association, respectively)
required
was made the defaultIn addition, a
required
option was also added tohas_one
.These new qualifiers allow us to test these options appropriately.
Credit: Shia rise.shia@gmail.com
Fixes #956, #870, #861.