From f634cc43ed7a5011b6c74073c7aee663a4a57bcc Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 14 Apr 2015 00:26:01 +0300 Subject: [PATCH] #465: Added specs for UserPolicy --- spec/policies/user_policy_spec.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/policies/user_policy_spec.rb diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb new file mode 100644 index 000000000..73ed53c97 --- /dev/null +++ b/spec/policies/user_policy_spec.rb @@ -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