Sha256: a7f2558e45eb1892970d192e9f4722f6657cfe2315a85f77b9c3870cf610e6ac

Contents?: true

Size: 1.27 KB

Versions: 46

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe ActiveAdmin::AuthorizationAdapter do

  let(:adapter) { ActiveAdmin::AuthorizationAdapter.new(stub, stub) }

  describe "#authorized?" do

    it "should always return true" do
      adapter.authorized?(:read, "Resource").should == true
    end

  end

  describe "#scope_collection" do

    it "should return the collection unscoped" do
      collection = stub
      adapter.scope_collection(collection).should == collection
    end

  end

  describe "using #normalized in a subclass" do

    let(:auth_class) do
      Class.new(ActiveAdmin::AuthorizationAdapter) do 

        def authorized?(action, subject = nil)
          case subject
          when normalized(String)
            true
          else
            false
          end
        end

      end
    end

    let(:adapter) { auth_class.new(stub, stub) }

    it "should match agains a class" do
      adapter.authorized?(:read, String).should == true
    end

    it 'should match against an instance' do
      adapter.authorized?(:read, "String").should == true
    end

    it 'should not match a different class' do
      adapter.authorized?(:read, Hash).should == false
    end

    it 'should not match a different instance' do
      adapter.authorized?(:read, {}).should == false
    end

  end

end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.94 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.84 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.80 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.79 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.78 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.77 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.74 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.73 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.72 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.71 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.66 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.65 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
activeadmin-0.6.0 spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.64 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.63 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.62 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.61 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.60 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb