#465: Added specs for UserPolicy

This commit is contained in:
Vokhmin Alexey V 2015-04-14 00:26:01 +03:00
parent 13de6b93c7
commit f634cc43ed
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
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