-
-
Notifications
You must be signed in to change notification settings - Fork 909
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
[Question] Working with belongs_to :relation, required: true #861
Comments
I believe this may be a newer option that we haven't added yet (I haven't heard of it). That would be a good idea to add (although I'd have the qualifier be |
In rails 5 |
I'm using Rails 5.0.0.beta3 with RSpec 3.5.0.beta2 and shoulda-matchers 3.1.1 Consider: class User < ApplicationRecord
has_many :changesets, inverse_of: :user, dependent: :restrict_with_error
end
class Changeset < ApplicationRecord
belongs_to :user, inverse_of: :changesets
end
RSpec.describe Changeset, type: :model do
subject { create :changeset }
it { is_expected.to belong_to(:user).inverse_of(:changesets) }
it { is_expected.to validate_presence_of :user }
end Rails changed the "required" belongs_to validation message.
Specifying the message fixes it for now:
|
Just FYI, try |
Fixed deprecation warning uniq -> distinct See: rails/rails#20198 Fixed exception for validate_presence “The record was indeed invalid, but it produced these validation errors instead” See: thoughtbot/shoulda-matchers#861 (comment) Fixed deprecation warning - use keyword syntax for get, put etc in controller tests Fixed coffee-rails not loading error
@mcmire @stephanngamedev Isn't that issue resolved by now? |
@robbl-as Yup! Sorry. Not sure why this issue wasn't closed automatically. This will be in the next release, or if you're feeling adventurous, you can point to master. |
If you have something like
Currently, what I can do on my specs is:
Which does cover it for me, but I'm curious as to ideas on having something in the likes of:
If it's in the docs, I apologize, I couldn't find it
The text was updated successfully, but these errors were encountered: