Sha256: bccc54183a91ed5396537f02af3efd6e89bea645c63dcef56a3262a6f0fd22f2

Contents?: true

Size: 995 Bytes

Versions: 5

Compression:

Stored size: 995 Bytes

Contents

require 'spec_helper'

describe ActiveAdmin::PunditAdapter do

  describe "full integration" do

    let(:application) { ActiveAdmin::Application.new }
    let(:namespace) { ActiveAdmin::Namespace.new(application, "Admin") }
    let(:resource) { namespace.register(Post) }
    let(:auth) { namespace.authorization_adapter.new(resource, double) }

    before do
      namespace.authorization_adapter = ActiveAdmin::PunditAdapter
    end

    it "should initialize the ability stored in the namespace configuration" do
      expect(auth.authorized?(:read, Post)).to eq true
      expect(auth.authorized?(:update, Post)).to eq false
    end

    it "should scope the collection" do
      class RSpec::Mocks::MockPolicy < ApplicationPolicy
        class Scope < Struct.new(:user, :scope)
          def resolve
            scope
          end
        end
      end

      collection = double
      auth.scope_collection(collection, :read)
      expect(collection).to eq collection
    end
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
active_administration-0.0.3 spec/unit/pundit_adapter_spec.rb
activeadministration-0.0.2 spec/unit/pundit_adapter_spec.rb
active_administration-0.0.2 spec/unit/pundit_adapter_spec.rb
activeadministration-0.0.1 spec/unit/pundit_adapter_spec.rb
active_administration-0.0.1 spec/unit/pundit_adapter_spec.rb