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.141 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/unit/authorization/authorization_adapter_spec.rb