Sha256: 62481a76b292fb00ba080382d27dbd9fe3470c999334202f98d05aeef561027f
Contents?: true
Size: 1.61 KB
Versions: 10
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' describe Storytime::CommentPolicy do subject { Storytime::CommentPolicy.new(user, comment) } let(:post) { FactoryGirl.create(:post) } context "as a normal user" do let(:user) { FactoryGirl.create(:user) } context "a comment owned by the user" do let(:comment) { FactoryGirl.build(:comment, user: user, post: post) } it { should permit!(:create) } it { should permit!(:destroy) } end context "a comment not owned by the user" do let(:comment) { FactoryGirl.build(:comment, post: post) } it { should_not permit!(:create) } it { should_not permit!(:destroy) } end end context "as an editor" do let(:user){ FactoryGirl.create(:editor) } context "a comment owned by the user" do let(:comment) { FactoryGirl.build(:comment, user: user, post: post) } it { should permit!(:create) } it { should permit!(:destroy) } end context "a comment not owned by the user" do let(:comment) { FactoryGirl.build(:comment, post: post) } it { should_not permit!(:create) } it { should permit!(:destroy) } end end context "as an admin" do let(:user){ FactoryGirl.create(:admin) } context "a comment owned by the user" do let(:comment) { FactoryGirl.build(:comment, user: user, post: post) } it { should permit!(:create) } it { should permit!(:destroy) } end context "a comment not owned by the user" do let(:comment) { FactoryGirl.build(:comment, post: post) } it { should_not permit!(:create) } it { should permit!(:destroy) } end end end
Version data entries
10 entries across 10 versions & 1 rubygems