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