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
When having two models with very long model names, and creating a HABTM relation between them, the join table name inflected by Rails is shortened (depending on the underlying database). For PostgreSQL the table name has a maximum length of 63 characters.
For Rails this join table name is shortened automatically. For shoulda-matchers we have to explicitly define the join_table option on the relation, otherwise shoulda-matchers will report an error.
Can the inflection in shoulda-matchers include the table name length constraints used by Rails?
Expected DataProtection::ProcessingActivity to have a has_and_belongs_to_many association called
technical_and_organisational_security_measures (join table
data_protection_processing_activities_technical_and_organisational_security_measures doesn't exist)
We tried adding the correct join table name option to the matcher:
it { should have_and_belong_to_many(:technical_and_organisational_security_measures).join_table('data_protection_processing_activities_technical_and_organisatio') }
Now shoulda-matchers fails with:
Expected DataProtection::ProcessingActivity to have a has_and_belongs_to_many association called
technical_and_organisational_security_measures (technical_and_organisational_security_measures should use
"data_protection_processing_activities_technical_and_organisatio" for :join_table option)
This forces us to explicitly add the join_table option to the model, which is not necessary:
When having two models with very long model names, and creating a HABTM relation between them, the join table name inflected by Rails is shortened (depending on the underlying database). For PostgreSQL the table name has a maximum length of 63 characters.
For Rails this join table name is shortened automatically. For shoulda-matchers we have to explicitly define the
join_table
option on the relation, otherwise shoulda-matchers will report an error.Can the inflection in shoulda-matchers include the table name length constraints used by Rails?
Example: these are our models:
The
schema.rb
contains the shortened join table name for PostgreSQL:When using these matchers in the model specs:
shoulda-matchers fails with:
We tried adding the correct join table name option to the matcher:
Now shoulda-matchers fails with:
This forces us to explicitly add the
join_table
option to the model, which is not necessary:Now the matcher does not report an error any longer.
The text was updated successfully, but these errors were encountered: