Sha256: 2bf72b1d26b28f6958a45d97f4ee24c7d58ce8e2dc1d5454b0b54998879c125a
Contents?: true
Size: 1.34 KB
Versions: 20
Compression:
Stored size: 1.34 KB
Contents
require 'rails_helper' describe ActiveAdmin::AuthorizationAdapter do let(:adapter) { ActiveAdmin::AuthorizationAdapter.new(double, double) } describe "#authorized?" do it "should always return true" do expect(adapter.authorized?(:read, "Resource")).to be_truthy end end describe "#scope_collection" do it "should return the collection unscoped" do collection = double expect(adapter.scope_collection(collection, ActiveAdmin::Auth::READ)).to eq 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(double, double) } it "should match against a class" do expect(adapter.authorized?(:read, String)).to be_truthy end it 'should match against an instance' do expect(adapter.authorized?(:read, "String")).to be_truthy end it 'should not match a different class' do expect(adapter.authorized?(:read, Hash)).to be_falsey end it 'should not match a different instance' do expect(adapter.authorized?(:read, {})).to be_falsey end end end
Version data entries
20 entries across 20 versions & 3 rubygems