rosa-build/spec/policies/user_policy_spec.rb

31 lines
705 B
Ruby
Raw Normal View History

2015-04-13 22:26:01 +01:00
require 'spec_helper'
RSpec.describe UserPolicy, type: :policy do
let(:user) { FactoryGirl.build(:user) }
subject { described_class }
permissions :show? do
it "grants access to anonymous user" do
expect(subject).to permit(User.new, user)
end
end
%i(update? notifiers? show_current_user? write?).each do |perm|
permissions perm do
it "denies access to user" do
expect(subject).to_not permit(User.new, user)
end
it "grants access for himself" do
expect(subject).to permit(user, user)
end
it "grants access for to global admin" do
expect(subject).to permit(FactoryGirl.build(:admin), user)
end
end
end
end