-
-
Save jalcine/8269138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factory :user do | |
name "Jessie Pinkman" | |
password "secret" | |
password_confirmation "secret" | |
factory :group_admin, parent: :user do | |
after(:create) do |user, evaluator| | |
group = evaluator.respond_to? :group ? evaluator.group : create(:group) | |
user.add_role :admin, group | |
end | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe GroupPolicy do | |
subject { GroupPolicy.new(user, group) } | |
let(:group) { FactoryGirl.create :group } | |
context 'A visitor' do | |
let(:user) { FactoryGirl.create :user } | |
it { should permit :create } | |
it { should_not permit :show } | |
it { should_not permit :update } | |
it { should_not permit :destroy } | |
end | |
context 'A group admin' do | |
let(:user) do | |
FactoryGirl.create :group_admin, group: group | |
end | |
it { should permit :create } | |
it { should permit :show } | |
it { should permit :update } | |
it { should permit :destroy } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment