You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rails 7.1 modifies raise_on_assign_to_attr_readonlylink to be enabled by default. In the past, the code would silently carry on. I'm now fixing our code base to no longer write to a read_only attribute.
It appears that shoulda-matchers attempts to write to read only attributes.
Reproduction Steps
Create a model
class MyClass < ActiveRecord::Base
attr_readonly :company_id
validates :company_id, presence: true
end
Create a spec
RSpec.describe MyClass, type: :model do
describe 'validation' do
subject { create(:my_class) }
it { is_expected.to validate_presence_of(:company_id) }
end
end
Hey @professor, thanks for opening this issue. I'll have more time to look at it this Friday. Meanwhile, would you mind trying it out with a subject that is not persisted?
Description
Rails 7.1 modifies
raise_on_assign_to_attr_readonly
link to be enabled by default. In the past, the code would silently carry on. I'm now fixing our code base to no longer write to a read_only attribute.It appears that shoulda-matchers attempts to write to read only attributes.
Reproduction Steps
Expected behavior
tests to pass
Actual behavior
System configuration
shoulda_matchers version: 6.2.0
rails version: 7.1.3.2
ruby version: 3.3.1
The text was updated successfully, but these errors were encountered: