2011-06-27 15:27:07 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
describe Locomotive::Ability do
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
before :each do
|
2011-08-25 21:28:56 +00:00
|
|
|
@site = FactoryGirl.create(:site)
|
|
|
|
@account = FactoryGirl.create(:account)
|
2011-06-27 15:27:07 +00:00
|
|
|
|
2011-08-25 21:28:56 +00:00
|
|
|
@admin = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => FactoryGirl.build(:site))
|
|
|
|
@designer = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(designer))
|
|
|
|
@author = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(author))
|
2011-06-27 15:27:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'pages' do
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
subject { Locomotive::Page.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of pages from (admin, designer, author)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should allow_permission_from :manage, @designer
|
|
|
|
should_not allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'touching' do
|
|
|
|
it 'should allow touching of pages from (author)' do
|
|
|
|
should allow_permission_from :touch, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'content instance' do
|
|
|
|
|
2011-12-22 23:45:32 +00:00
|
|
|
subject { Locomotive::ContentEntry.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of pages from (admin, designer, author)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should allow_permission_from :manage, @designer
|
|
|
|
should allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'content type' do
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
subject { Locomotive::ContentType.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of pages from (admin, designer)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should allow_permission_from :manage, @designer
|
|
|
|
should_not allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# context 'touching' do
|
|
|
|
# it 'should allow touching of pages from (author)' do
|
|
|
|
# should_not allow_permission_from :touch, @author
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'theme assets' do
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
subject { Locomotive::ThemeAsset.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of pages from (admin, designer)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should allow_permission_from :manage, @designer
|
|
|
|
should_not allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'touching' do
|
|
|
|
it 'should allow touching of pages from (author)' do
|
|
|
|
should allow_permission_from :touch, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'site' do
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
subject { Locomotive::Site.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of pages from (admin)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should_not allow_permission_from :manage, @designer
|
|
|
|
should_not allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'pointing' do
|
|
|
|
it 'should allow importing of sites from (designer)' do
|
|
|
|
should allow_permission_from :point, @designer
|
|
|
|
should_not allow_permission_from :point, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'membership' do
|
|
|
|
|
2011-11-20 10:59:12 +00:00
|
|
|
subject { Locomotive::Membership.new }
|
2011-06-27 15:27:07 +00:00
|
|
|
|
|
|
|
context 'management' do
|
|
|
|
it 'should allow management of memberships from (admin, designer)' do
|
|
|
|
should allow_permission_from :manage, @admin
|
|
|
|
should allow_permission_from :manage, @designer
|
|
|
|
should_not allow_permission_from :manage, @author
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-09-17 14:23:43 +00:00
|
|
|
context 'granting admin' do
|
|
|
|
it 'should allow only admins to grant admin role' do
|
|
|
|
should allow_permission_from :grant_admin, @admin
|
|
|
|
should_not allow_permission_from :grant_admin, @designer
|
|
|
|
should_not allow_permission_from :grant_admin, @author
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-06-27 15:27:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|