Not sure if I'm missing something...
Scope in model:
has_many :active_website_resources, -> {
joins(:resource)
.where(is_active: true)
.where(resource: { status: :active }) },
class_name: 'WebsiteResource'
This test passes:
it { should have_many(:active_website_resources)
.conditions(resource: { status: :active }) #1 <==
.conditions(is_active: true) #2 <==
.class_name('WebsiteResource') }
But when conditions are reversed then it fails:
it { should have_many(:active_website_resources)
.conditions(is_active: true) #2 <==
.conditions(resource: { status: :active }) #1 <==
.class_name('WebsiteResource') }
with message:
Expected Website to have a has_many association called active_website_resources (active_website_resources should have the following conditions: {:resource=>{:status=>:active}})
Not sure if I'm missing something...
Scope in model:
This test passes:
But when conditions are reversed then it fails:
with message: