Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

many specs pass

  • Loading branch information...
commit b8fd7790878478f7aea845daf9e303e1d9e89070 1 parent 5231ac1
@kristianmandrup authored
View
2  Gemfile
@@ -6,7 +6,7 @@ group :default do
gem 'sweetloader', '>= 0.1.6'
gem 'hashie', '>= 1.2.0'
- gem 'cantango-config', '~> 0.1.8'
+ gem 'cantango-config', '~> 0.1.9'
end
group :development do
View
6 Gemfile.lock
@@ -38,7 +38,7 @@ GEM
rails (>= 3.1)
sugar-high (>= 0.6.1)
sweetloader (~> 0.1.6)
- cantango-core (0.1.9.2)
+ cantango-core (0.1.9.3)
cancan (>= 1.4)
hashie (~> 1.2)
rails (>= 3.0.1)
@@ -62,7 +62,7 @@ GEM
bundler (~> 1.0)
git (>= 1.2.5)
rake
- json (1.6.2)
+ json (1.6.3)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -130,7 +130,7 @@ PLATFORMS
DEPENDENCIES
bundler (>= 1.1.rc)
- cantango-config (~> 0.1.8)
+ cantango-config (~> 0.1.9)
cutter
database_cleaner
factory_girl
View
38 README.mdown
@@ -2,10 +2,48 @@
Roles and Role groups extension for [CanTango](https://github.com/kristianmandrup/cantango)
+## Status: Dec 9, 2011
+
+Most specs except those for Permits have been completed and demonstrates that the functionality works as it should.
+
+## Ability helper
+
+* Ability::Helper
+ * Role
+ * RoleGroup
+
+These modules are typically included into an Ability in order to access the roles of the ability subject, typically a user (or in rare cases an account).
+
+The `Role` module has a `#roles` method which returns the role list of the subject.
+The `RoleGroup` module has a `#role_groups` method which returns the role group list of the subject.
+
## Configuration Registry
Roles and RoleGroups configuration via a Registry.
+Roles configuration:
+
+```ruby
+CanTango.config do |config|
+ config.roles do |roles|
+ roles.register :admin, :guest, :basic
+ roles.system = :simple_roles
+ roles.exclude :admin # filter
+ end
+```
+
+Role groups configuration:
+
+```ruby
+CanTango.config do |config|
+ config.roles_groups do |role_groups|
+ role_groups.register :editors, :publishers
+ role_groups.system = :troles
+ role_groups.only :editors # filter
+ end
+end
+```
+
## Permits
Role and RoleGroup Permits for the Permits engine Ability executor.
View
2  lib/cantango/roles_ext/configuration/role_groups.rb
@@ -7,7 +7,7 @@ def system
def default_system_apis
{
- :troles => {:list => :role_group_list}
+ :troles => {:list => :role_group_list, :has => :in_role_group?}
}
end
end
View
5 spec/cantango/builder/role_group_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe CanTango::Builder::Permit::RoleGroup do
+ pending
+end
View
5 spec/cantango/builder/role_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe CanTango::Builder::Permit::Role do
+ pending
+end
View
6 spec/cantango/configuration/role_groups_spec.rb
@@ -1,12 +1,12 @@
require 'spec_helper'
-require 'cantango/configuration/role_registry_ex'
+require 'cantango/configuration/shared/role_registry_ex'
describe CanTango::Configuration::RoleGroups do
subject { CanTango.config.role_groups }
it_should_behave_like "Role Registry" do
- specify { subject.system_api(:has).should == :in_role_group? }
- specify { subject.system_api(:list).should == :role_groups_list }
+ specify { subject.system_api[:list].should == :role_group_list }
+ specify { subject.system_api[:has].should == :in_role_group? }
end
end
View
2  spec/cantango/configuration/roles_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
-require 'cantango/configuration/role_registry_ex'
+require 'cantango/configuration/shared/role_registry_ex'
describe CanTango::Configuration::Roles do
subject { CanTango.config.roles }
View
8 spec/cantango/configuration/shared/role_registry_ex.rb
@@ -4,14 +4,6 @@
shared_examples_for 'Role Registry' do
it_should_behave_like "Registry"
- describe 'default settings' do
- its(:has_method) { should == has }
- its(:list_method) { should == list }
-
- its(:default_has_method) { should be_a Symbol }
- its(:default_list_method) { should be_a Symbol }
- end
-
describe "exclude" do
before do
subject.exclude :admin
View
12 spec/cantango/configuration/shared/system_ex.rb
@@ -3,13 +3,13 @@
shared_examples_for 'System' do
it_should_behave_like "Role Registry"
- describe 'system' do
- its(:system) { should == nil }
+ describe 'default system - simple_roles' do
+ its(:system) { should == :simple_roles }
end
- decribe 'system=' do
+ describe 'system=' do
before do
- system = :my_sys
+ subject.system = :my_sys
end
its(:system) { should == :my_sys }
end
@@ -30,8 +30,8 @@
describe 'add_systems' do
before do
- subject.add_system :my_own_sys => {:list => :listing }
- subject.system = :my_own_sys
+ subject.add_system :my_other_sys => {:list => :listing }
+ subject.system = :my_other_sys
end
specify { subject.system_api[:list].should == :listing }
specify { subject.system_apis.size.should > 1 }
View
1  spec/cantango/engine/permits_spec.rb
@@ -3,4 +3,5 @@
describe CanTango::Engine::Permits do
# use shared Role helper example
+ pending
end
View
9 spec/cantango/filter/role_group_spec.rb
@@ -1,6 +1,5 @@
require 'spec_helper'
require 'fixtures/models'
-require 'cantango/rspec'
CanTango.configure do |config|
config.permission_engine.set :off
@@ -8,28 +7,28 @@
config.categories.register :blog_items => [Article, Post]
end
-class AdminsRoleGroupPermit < CanTango::RoleGroupPermit
+class AdminsRoleGroupPermit < CanTango::Permit::RoleGroup
def initialize ability
super
end
protected
- def static_rules
+ def calc_rules
can :publish, Post
can :write, Article
can :write, category(:blog_items)
end
end
-class EditorsRoleGroupPermit < CanTango::RoleGroupPermit
+class EditorsRoleGroupPermit < CanTango::Permit::RoleGroup
def initialize ability
super
end
protected
- def static_rules
+ def calc_rules
can :publish, category(:blog_items)
end
end
View
2  spec/cantango/helpers/role_spec.rb
@@ -18,7 +18,7 @@ class Subject
end
specify do
- subject.role_method(:list).should == :role_list?
+ subject.role_method(:list).should == :role_list
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.