rosa-build/spec/policies/token_policy_spec.rb

30 lines
862 B
Ruby
Raw Permalink Normal View History

2015-04-13 22:22:41 +01:00
require 'spec_helper'
RSpec.describe TokenPolicy, type: :policy do
let(:token) { FactoryGirl.build(:platform_token) }
subject { described_class }
%i(show? create? read? withdraw?).each do |perm|
permissions perm do
it "denies access to user" do
expect(subject).to_not permit(User.new, token)
end
it "grants access to owner of platform" do
allow_any_instance_of(TokenPolicy).to receive(:owner?).and_return(true)
expect(subject).to permit(User.new, token)
end
it "grants access to admin of platform" do
allow_any_instance_of(TokenPolicy).to receive(:local_admin?).and_return(true)
expect(subject).to permit(User.new, token)
end
it "grants access for to global admin" do
expect(subject).to permit(FactoryGirl.build(:admin), token)
end
end
end
end