#465: Added specs for HookPolicy

This commit is contained in:
Vokhmin Alexey V 2015-04-11 01:26:32 +03:00
parent 699aba3cbe
commit 15e1621566
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
require 'spec_helper'
RSpec.describe HookPolicy, type: :policy do
let(:hook) { FactoryGirl.build(:hook) }
subject { described_class }
%i(show? read? create? destroy? update?).each do |perm|
permissions perm do
it "denies access to anonymous user" do
expect(subject).to_not permit(User.new, hook)
end
it "denies access if user can not update a project" do
allow_any_instance_of(ProjectPolicy).to receive(:update?).and_return(false)
expect(subject).to_not permit(User.new, hook)
end
it "grants access if user can update a project" do
allow_any_instance_of(ProjectPolicy).to receive(:update?).and_return(true)
expect(subject).to permit(User.new, hook)
end
end
end
end