#465: Added specs for KeyPairPolicy

This commit is contained in:
Vokhmin Alexey V 2015-04-11 01:40:11 +03:00
parent be69f5855a
commit 751c820d80
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
require 'spec_helper'
RSpec.describe KeyPairPolicy, type: :policy do
let(:key_pair) { FactoryGirl.build(:key_pair) }
subject { described_class }
%i(create? destroy?).each do |perm|
permissions perm do
it "denies access to user" do
expect(subject).to_not permit(User.new, key_pair)
end
it "grants access for admin of platform" do
allow_any_instance_of(KeyPairPolicy).to receive(:local_admin?).
with(key_pair.repository.platform).and_return(true)
expect(subject).to permit(User.new, key_pair)
end
it "grants access for to global admin" do
expect(subject).to permit(FactoryGirl.build(:admin), key_pair)
end
end
end
end