#465: Added specs for SubscribePolicy

This commit is contained in:
Vokhmin Alexey V 2015-04-14 00:17:37 +03:00
parent f2d3b3cbd4
commit 4a5610983d
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
require 'spec_helper'
RSpec.describe SubscribePolicy, type: :policy do
let(:subscribe) { FactoryGirl.create(:subscribe) }
subject { described_class }
permissions :create? do
it "denies access to anonymous user" do
expect(subject).to_not permit(User.new, subscribe)
end
it "grants access to user" do
expect(subject).to permit(FactoryGirl.create(:user), subscribe)
end
it "denies access if user already subscribed" do
expect(subject).to_not permit(subscribe.user, subscribe)
end
end
permissions :destroy? do
it "denies access to anonymous user" do
expect(subject).to_not permit(User.new, subscribe)
end
it "denies access to user" do
expect(subject).to_not permit(FactoryGirl.create(:user), subscribe)
end
it "grants access if user already subscribed" do
expect(subject).to permit(subscribe.user, subscribe)
end
end
end