#465: Added specs for UserPolicy
This commit is contained in:
parent
13de6b93c7
commit
f634cc43ed
|
@ -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
|
Loading…
Reference in New Issue