Action Policy v0.4.0 Release Notes

Release Date: 2019-12-11 // over 4 years ago
  • ๐Ÿ”‹ Features

    • Optional authorization context. (#95)

    In addition to allow_nil: true, we now have an option to skip the context altogether:

    class OptionalRolePolicy \< ActionPolicy::Baseauthorize :role, optional: trueendpolicy = OptionalRolePolicy.newpolicy.role #=\> nil
    
    • ๐Ÿš… Rails generators. (#87)

    Now you can use action_policy:install and action_policy:policy MODEL Rails generators.

    • ๐Ÿ†• New instrumentation event: action_policy.init.

    Triggered every time a new policy object is initialized.

    ๐Ÿ”„ Changes

    • โœ… Composed matchers are supported in authorization target testing.

    โœ… Now you can write tests like this:

    expect { subject }.to be\_authorized\_to(:show?, an\_instance\_of(User))