Sha256: 5ca1461cb8d402090d2c61ede0fb6e803b1c35c39919d0274ab19fee1f32a875

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

require 'rails_helper'

describe Arrthorizer::Rails::ControllerConcern do
  describe :authorization_scope do
    let(:controller) { SomeController.new }

    context "when no scope is explicitly configured" do
      specify "the default of :current_user is tried" do
        expect(controller).to receive(:current_user)

        controller.send(:arrthorizer_scope)
      end

      context "when a different scope is explicitly configured" do
        let(:controller_class) { Class.new(SomeController) }
        let(:controller)       { controller_class.new }

        before :each do
          controller_class.authorization_scope :some_other_method
        end

        specify "that scope is used for authorization" do
          expect(controller).to receive(:some_other_method)

          controller.send(:arrthorizer_scope)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arrthorizer-0.4.2 spec/rails/controller_concern/authorization_scope_spec.rb
arrthorizer-0.4.1 spec/rails/controller_concern/authorization_scope_spec.rb