thoughtbot / shoulda-matchers

Simple one-liner tests for common Rails functionality
https://matchers.shoulda.io
MIT License
3.5k stars 911 forks source link

feat: Add `query_constraints` modifier to `AssociationMatcher` #1604

Closed matsales28 closed 7 months ago

matsales28 commented 7 months ago

Closes: #1592

Rails 7.1 introduced the query_constraints qualifier that can be passed to the association definition.

For example:

class Author < ApplicationRecord
  self.primary_key = [:first_name, :last_name]
  has_many :books, query_constraints: [:author_first_name, :author_last_name]
end

class Book < ApplicationRecord
  belongs_to :author, query_constraints: [:author_first_name, :author_last_name]
end

We're adding this qualifier to the association matchers.

matsales28 commented 7 months ago

LGTM! I believe it's time to consider a new release due to the bug fix in the master branch - #1603. I'm available to begin working on it over the next few weeks, but if you would like to work on it, please let me know.

@VSPPedro I have time to work on it this Friday if you haven't started yet.

vsppedro commented 7 months ago

Please, do. I need to give some love to snowglobe, shoulda-context and shoulda.