Last active
January 2, 2016 07:19
-
-
Save enricostano/8268768 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 | |
ignore do | |
group = nil | |
end | |
after(:create) { |user, evaluator| user.add_role :admin, evaluator.group } | |
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 |
Author
enricostano
commented
Jan 5, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment