Sha256: 3c406b3ab64eafa32c1ed2f03b8e9c11996d6b0fab1f4bb3b1785bf9434d5c4a

Contents?: true

Size: 1.07 KB

Versions: 16

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Faalis::AdminOnlyPolicy do
  subject { Faalis::AdminOnlyPolicy.new(user, entity) }

  # We use Group as an entity because we don't have
  # too much models
  let(:entity) { group(:admin) }

  context 'for visitors' do
    let(:user) { nil }

    [:index, :show, :update, :create, :destroy].each do |action|
      it "denies access to #{action} on the protected entity" do
        expect(subject.send("#{action}?")).not_to be(true)
      end
    end
  end

  context 'for guest users' do
    let(:user) { create(:user, password: '123123123') }

    [:index, :show, :update, :create, :destroy].each do |action|
      it "denies access to #{action} on the protected entity" do
        expect(subject.send("#{action}?")).not_to be(true)
      end
    end
  end

  context 'for admin users' do
    let(:user) { create(:admin, password: '123123123') }

    [:index, :show, :update, :create, :destroy].each do |action|
      it "denies access to #{action} on the protected entity" do
        expect(subject.send("#{action}?")).to be(true)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
faalis-2.0.8 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.7 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.5 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.4 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.3 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.1 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0.rc6 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0.rc5 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0.rc4 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0.rc3 spec/policies/faalis/admin_only_policy_spec.rb
faalis-2.0.0.rc2 spec/policies/faalis/admin_only_policy_spec.rb
faalis-1.0.0 spec/policies/faalis/admin_only_policy_spec.rb
faalis-1.0.0.alpha4 spec/policies/faalis/admin_only_policy_spec.rb
faalis-1.0.0.alpha3 spec/policies/faalis/admin_only_policy_spec.rb
faalis-1.0.0.alpha2 spec/policies/faalis/admin_only_policy_spec.rb