Skip to content

Index action can be configured with custom query params. but Rspec matcher only expect ClassName #867

Description

@asad-ali-bhatti

Steps to reproduce

We can configure index actions in ability class like following

can :index, [Product], brand_id: allowed_brand_ids_from_session

But how I can test it in Rspec as you can only access allowed products coming from session
Why we dont we allow query params in be_able_to matchers

This don't cover actuall implementation of our ability. Because at the moment we can only pass model name only.

expect(subject).to be_able_to(:index, Product) 

Expected behavior

we can allow some thing like .with to also mention query params that we pass in actuall ability class.

expect(subject).to be_able_to(:index, Product).with(brand_id: some_brand_ids) 

Actual behavior

Tell us what happens instead

System configuration

Rails version:

Ruby version:

CanCanCan version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions