canard 0.4.3 → 0.5.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +6 -9
- data/{README.rdoc → README.md} +39 -21
- data/TODO +2 -1
- data/canard.gemspec +14 -19
- data/lib/canard/adapters/active_record.rb +11 -17
- data/lib/canard/adapters/mongoid.rb +9 -9
- data/lib/canard/railtie.rb +10 -7
- data/lib/canard/user_model.rb +1 -1
- data/lib/canard/version.rb +1 -1
- data/lib/generators/canard/ability/templates/abilities.rb.erb +5 -7
- data/lib/generators/rspec/ability/templates/abilities_spec.rb.erb +30 -47
- metadata +22 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc60d17173f92f98f6d45330a03a33fd1f7b1253
|
4
|
+
data.tar.gz: 4381d33e14aa4dde69a7433eb998b09a1fad5528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 476dac97c8a7588373a07f3812c4975b3330b3f815139ba96b530084d6ebd2a85c9e0cdee374bf6de6a961646bc3aa0144989f3aa22038aee6f75c6d7e0a3de5
|
7
|
+
data.tar.gz: 1f3d9f6111da01e36310b343948f5b0f2eddb979810237755653033a06edbf1a7aff3fa229d1fcbf045f4451f8b2e34c6625f9ffbd1c5ed8583a6bce362437ea
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 1
|
5
|
-
-
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- jruby-
|
9
|
-
- jruby-19mode # JRuby in 1.9 mode
|
10
|
-
- rbx-18mode
|
11
|
-
- rbx-19mode
|
3
|
+
- 2.0
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3.3
|
7
|
+
- 2.4.0
|
8
|
+
- jruby-9.1.7.0
|
12
9
|
services:
|
13
10
|
- mongodb
|
14
11
|
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,15 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Canard
|
2
|
+
======
|
3
|
+
[![Build Status](https://travis-ci.org/james2m/canard.svg?branch=master)](https://travis-ci.org/james2m/canard)
|
4
|
+
|
3
5
|
Canard brings CanCan and RoleModel together to make role based authorization in Rails easy. Your ability
|
4
6
|
definitions gain their own folder and a little structure. The easiest way to get started is with the
|
5
7
|
Canard generator. Canard progressively enhances the abilities of the model by applying role abilities on
|
6
8
|
top of the models base abilities.
|
7
|
-
|
8
9
|
A User model with :admin and :manager roles would be defined:
|
9
10
|
|
10
11
|
class User < ActiveRecord::Base
|
11
12
|
|
12
|
-
acts_as_user :roles =>
|
13
|
+
acts_as_user :roles => [ :manager, :admin ]
|
13
14
|
|
14
15
|
end
|
15
16
|
|
@@ -22,7 +23,8 @@ First it will look for a users abilities, then it will look for the roles in the
|
|
22
23
|
|
23
24
|
Therefore each the later abilities only need to build on their predecessors.
|
24
25
|
|
25
|
-
|
26
|
+
Usage
|
27
|
+
=====
|
26
28
|
To generate some abilities for the User.
|
27
29
|
|
28
30
|
$ rails g canard:ability user can:[read,create]:[account,statement] cannot:destroy:account
|
@@ -131,8 +133,8 @@ Obviously the generators are just a starting point and should be used only to g
|
|
131
133
|
suggest that every new model you create you add to the abilities as the specs are easy to write and CanCan
|
132
134
|
definitions are very clear and simple.
|
133
135
|
|
134
|
-
|
135
|
-
|
136
|
+
Scopes
|
137
|
+
======
|
136
138
|
The :acts_as_user method with automatically define some named scopes for each role. For the example User model
|
137
139
|
above it will define the following scopes;
|
138
140
|
|
@@ -146,10 +148,11 @@ In addition to the role specific scopes it also adds some general scopes;
|
|
146
148
|
User.with_any_role(roles):: return all the users with any of the specified roles
|
147
149
|
User.with_all_roles(roles):: return only the users with all the specified roles
|
148
150
|
|
149
|
-
|
150
|
-
|
151
|
-
=== Rails 3.x & 4.x
|
151
|
+
Installation
|
152
|
+
============
|
152
153
|
|
154
|
+
Rails 3.x, 4.x & 5.x
|
155
|
+
--------------------
|
153
156
|
Add the canard gem to your Gemfile. In Gemfile:
|
154
157
|
|
155
158
|
gem "canard"
|
@@ -161,17 +164,19 @@ Add the `roles_mask` field to your user table:
|
|
161
164
|
|
162
165
|
That's it!
|
163
166
|
|
164
|
-
|
167
|
+
Rails 2.x
|
168
|
+
---------
|
165
169
|
|
166
|
-
Sorry you are out of luck with Rails 2.x Canard has only been written and tested with Rails 3
|
167
|
-
to accept pull requests for tested Rails 2.x updates if anybody is game.
|
170
|
+
Sorry you are out of luck with Rails 2.x Canard has only been written and tested with Rails 3 and above.
|
168
171
|
|
169
|
-
|
172
|
+
Supported ORM's
|
173
|
+
---------------
|
170
174
|
|
171
175
|
Canard is ORM agnostic. ActiveRecord and Mongoid (thanks David Butler) adapters are currently implemented.
|
172
176
|
New adapters can easily be added, but you'd need to check CanCan can also support your adapter.
|
173
177
|
|
174
|
-
|
178
|
+
Further reading
|
179
|
+
---------------
|
175
180
|
|
176
181
|
Canard stands on the sholders of Ryan Bates' CanCan and Martin Rehfeld's RoleModel. You can read more
|
177
182
|
about defining abilities on the CanCan wiki (https://github.com/ryanb/cancan/wiki). Canard implements
|
@@ -206,7 +211,8 @@ Under the covers Canard uses RoleModel (https://github.com/martinrehfeld/role_mo
|
|
206
211
|
is based on Ryan Bates' suggested approach to role based authorization which is documented in the CanCan
|
207
212
|
wiki (https://github.com/ryanb/cancan/wiki/role-based-authorization).
|
208
213
|
|
209
|
-
|
214
|
+
Note on Patches/Pull Request
|
215
|
+
----------------------------
|
210
216
|
|
211
217
|
* Fork the project.
|
212
218
|
* Make your feature addition or bug fix.
|
@@ -215,21 +221,33 @@ wiki (https://github.com/ryanb/cancan/wiki/role-based-authorization).
|
|
215
221
|
bump version in a commit by itself I can ignore it when I pull)
|
216
222
|
* Send me a pull request. Bonus points for topic branches.
|
217
223
|
|
218
|
-
|
224
|
+
Contributors
|
225
|
+
------------
|
219
226
|
|
220
227
|
git log | grep Author | sort | uniq
|
221
228
|
|
229
|
+
* Alessandro Dal Grande
|
230
|
+
* David Butler
|
231
|
+
* Dmitriy Molodtsov
|
232
|
+
* Dmytro Salko
|
222
233
|
* James McCarthy
|
234
|
+
* Jesse McGinnis
|
223
235
|
* Joey Geiger
|
236
|
+
* Jon Kinney
|
237
|
+
* Justin Buchanan
|
224
238
|
* Morton Jonuschat
|
225
|
-
*
|
239
|
+
* Piotr Kuczynski
|
240
|
+
* Thomas Hoen
|
241
|
+
* Travis Berry
|
226
242
|
|
227
243
|
If you feel like contributing there is a TODO list in the root with a few ideas and opportunities!
|
228
244
|
|
229
|
-
|
245
|
+
Credits
|
246
|
+
-------
|
230
247
|
|
231
248
|
Thanks to Ryan Bates for creating the awesome CanCan (http://wiki.github.com/ryanb/cancan)
|
232
249
|
and Martin Rehfeld for implementing Role Based Authorization in the form of RoleModel (http://github.com/martinrehfeld/role_model).
|
233
250
|
|
234
|
-
|
235
|
-
|
251
|
+
Copyright
|
252
|
+
---------
|
253
|
+
Copyright (c) 2011-2017 James McCarthy, released under the MIT license
|
data/TODO
CHANGED
@@ -7,4 +7,5 @@
|
|
7
7
|
* Add install generator to allow overriding of the default tests.
|
8
8
|
* Make the Ability user referece configureable in Ability.
|
9
9
|
* Add DataMapper support.
|
10
|
-
* Detect and use FactoryGirl syntax in generated spec.
|
10
|
+
* Detect and use FactoryGirl syntax in generated spec.
|
11
|
+
* Stop extending ActiveRecord, use composition instead.
|
data/canard.gemspec
CHANGED
@@ -1,34 +1,29 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require
|
3
|
+
require 'canard/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'canard'
|
7
7
|
s.version = Canard::VERSION
|
8
8
|
s.date = `git log -1 --format="%cd" --date=short lib/canard/version.rb`
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
12
|
-
s.summary = %q{Adds role based authorisation to Rails by combining RoleModel and
|
13
|
-
s.description = %q{Wraps
|
9
|
+
s.authors = ['James McCarthy']
|
10
|
+
s.email = ['james2mccarthy@gmail.com']
|
11
|
+
s.homepage = 'https://github.com/james2m/canard'
|
12
|
+
s.summary = %q{Adds role based authorisation to Rails by combining RoleModel and CanCanCan.}
|
13
|
+
s.description = %q{Wraps CanCanCan and RoleModel up to make role based authorisation really easy in Rails 4+.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "canard"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
-
s.require_paths = [
|
20
|
+
s.require_paths = ['lib']
|
21
21
|
|
22
|
-
s.add_development_dependency
|
23
|
-
s.add_development_dependency
|
22
|
+
s.add_development_dependency 'minitest', '~> 2'
|
23
|
+
s.add_development_dependency 'rails', '~> 3.2.3', '>= 3.2.3'
|
24
|
+
s.add_development_dependency 'mongoid', '~> 3.0'
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
s.add_development_dependency "mongoid", "~> 3.0"
|
29
|
-
end
|
30
|
-
|
31
|
-
s.requirements << 'cancan for Rails3 and earlier or the Rails4 compatible cancancan fork.'
|
32
|
-
s.add_runtime_dependency "cancancan"
|
33
|
-
s.add_runtime_dependency "role_model"
|
26
|
+
s.requirements << "cancan's community supported Rails4+ compatible cancancan fork."
|
27
|
+
s.add_runtime_dependency 'cancancan', '~> 1'
|
28
|
+
s.add_runtime_dependency 'role_model', '~> 0'
|
34
29
|
end
|
@@ -4,23 +4,24 @@ module Canard
|
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
def add_role_scopes
|
7
|
+
def add_role_scopes(*args)
|
8
|
+
options = args.extract_options!
|
8
9
|
# TODO change to check has_roles_attribute?
|
9
10
|
if active_record_table?
|
10
11
|
valid_roles.each do |role|
|
11
|
-
define_scopes_for_role role
|
12
|
+
define_scopes_for_role role, options[:prefix]
|
12
13
|
end
|
13
14
|
|
14
15
|
# TODO change hard coded :role_mask to roles_attribute_name
|
15
|
-
|
16
|
+
define_singleton_method(:with_any_role) do |*roles|
|
16
17
|
where("#{role_mask_column} & :role_mask > 0", { :role_mask => mask_for(*roles) })
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
define_singleton_method(:with_all_roles) do |*roles|
|
20
21
|
where("#{role_mask_column} & :role_mask = :role_mask", { :role_mask => mask_for(*roles) })
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
define_singleton_method(:with_only_roles) do |*roles|
|
24
25
|
where("#{role_mask_column} = :role_mask", { :role_mask => mask_for(*roles) })
|
25
26
|
end
|
26
27
|
end
|
@@ -35,29 +36,22 @@ module Canard
|
|
35
36
|
active_record_table? && column_names.include?(roles_attribute_name.to_s) || super
|
36
37
|
end
|
37
38
|
|
38
|
-
def define_scopes_for_role(role)
|
39
|
-
include_scope
|
40
|
-
exclude_scope
|
39
|
+
def define_scopes_for_role(role, prefix=nil)
|
40
|
+
include_scope = [prefix, String(role).pluralize].compact.join('_')
|
41
|
+
exclude_scope = "non_#{include_scope}"
|
41
42
|
|
42
|
-
|
43
|
+
define_singleton_method(include_scope) do
|
43
44
|
where("#{role_mask_column} & :role_mask > 0", { :role_mask => mask_for(role) })
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
+
define_singleton_method(exclude_scope) do
|
47
48
|
where("#{role_mask_column} & :role_mask = 0 or #{role_mask_column} is null", { :role_mask => mask_for(role) })
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
|
-
def define_scope_method(method, &block)
|
52
|
-
(class << self; self end).class_eval do
|
53
|
-
define_method(method, block)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
52
|
def role_mask_column
|
58
53
|
"#{quoted_table_name}.#{connection.quote_column_name roles_attribute_name}"
|
59
54
|
end
|
60
|
-
|
61
55
|
end
|
62
56
|
end
|
63
57
|
end
|
@@ -4,9 +4,10 @@ module Canard
|
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
def add_role_scopes
|
7
|
+
def add_role_scopes(*args)
|
8
|
+
options = args.extract_options!
|
8
9
|
valid_roles.each do |role|
|
9
|
-
define_scopes_for_role role
|
10
|
+
define_scopes_for_role role, options[:prefix]
|
10
11
|
end
|
11
12
|
|
12
13
|
def with_any_role(*roles)
|
@@ -26,14 +27,13 @@ module Canard
|
|
26
27
|
fields.include?(roles_attribute_name.to_s) || super
|
27
28
|
end
|
28
29
|
|
29
|
-
def define_scopes_for_role(role)
|
30
|
-
include_scope
|
31
|
-
exclude_scope
|
32
|
-
|
33
|
-
scope include_scope, lambda { where("(this.#{roles_attribute_name} & #{mask_for(role)}) > 0") }
|
34
|
-
scope exclude_scope, lambda { any_of({roles_attribute_name => { "$exists" => false }}, {roles_attribute_name => nil}, {"$where" => "(this.#{roles_attribute_name} & #{mask_for(role)}) === 0"}) }
|
35
|
-
end
|
30
|
+
def define_scopes_for_role(role, prefix=nil)
|
31
|
+
include_scope = [prefix, String(role).pluralize].compact.join('_')
|
32
|
+
exclude_scope = "non_#{include_scope}"
|
36
33
|
|
34
|
+
scope include_scope, -> { where("(this.#{roles_attribute_name} & #{mask_for(role)}) > 0") }
|
35
|
+
scope exclude_scope, -> { any_of({roles_attribute_name => { "$exists" => false }}, {roles_attribute_name => nil}, {"$where" => "(this.#{roles_attribute_name} & #{mask_for(role)}) === 0"}) }
|
36
|
+
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/canard/railtie.rb
CHANGED
@@ -25,21 +25,24 @@ module Canard
|
|
25
25
|
end
|
26
26
|
|
27
27
|
initializer "canard.mongoid" do |app|
|
28
|
-
if defined?(Mongoid)
|
29
|
-
require 'canard/adapters/mongoid'
|
30
|
-
end
|
28
|
+
require 'canard/adapters/mongoid' if defined?(Mongoid)
|
31
29
|
end
|
32
30
|
|
33
31
|
initializer "canard.abilities_reloading", :after => "action_dispatch.configure" do |app|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ActionDispatch::Reloader.before { Canard.find_abilities }
|
32
|
+
reloader = rails5? ? ActiveSupport::Reloader : ActionDispatch::Reloader
|
33
|
+
if reloader.respond_to?(:to_prepare)
|
34
|
+
reloader.to_prepare { Canard.find_abilities }
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
38
|
rake_tasks do
|
42
39
|
load File.expand_path('../../tasks/canard.rake', __FILE__)
|
43
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def rails5?
|
45
|
+
ActionPack::VERSION::MAJOR == 5
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
data/lib/canard/user_model.rb
CHANGED
@@ -73,7 +73,7 @@ module Canard
|
|
73
73
|
|
74
74
|
roles options[:roles] if options.has_key?(:roles) && has_roles_mask_accessors?
|
75
75
|
|
76
|
-
add_role_scopes if respond_to?(:add_role_scopes, true)
|
76
|
+
add_role_scopes(prefix: options[:prefix]) if respond_to?(:add_role_scopes, true)
|
77
77
|
end
|
78
78
|
|
79
79
|
private
|
data/lib/canard/version.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
Canard::Abilities.for(<%= ":#{name}" -%>) do
|
2
|
-
|
3
2
|
<% if ability_definitions.empty? -%>
|
4
3
|
# Define abilities for the user role here. For example:
|
5
4
|
#
|
@@ -19,14 +18,13 @@ Canard::Abilities.for(<%= ":#{name}" -%>) do
|
|
19
18
|
# The third argument is an optional hash of conditions to further filter the objects.
|
20
19
|
# For example, here the user can only update published articles.
|
21
20
|
#
|
22
|
-
# can :update, Article, :
|
21
|
+
# can :update, Article, published: true
|
23
22
|
#
|
24
|
-
# See the wiki for details: https://github.com/
|
23
|
+
# See the wiki for details: https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
|
25
24
|
<% else -%>
|
26
25
|
<% definitions do |model, definition| -%>
|
27
|
-
<%= "can
|
28
|
-
<%= "cannot
|
26
|
+
<%= "can #{definition.cans.map(&:to_sym)}, #{model.classify}" unless definition.cans.empty? %>
|
27
|
+
<%= "cannot #{definition.cannots.map(&:to_sym)}, #{model.classify}" unless definition.cannots.empty? %>
|
29
28
|
<% end -%>
|
30
29
|
<% end -%>
|
31
|
-
|
32
|
-
end
|
30
|
+
end
|
@@ -1,68 +1,51 @@
|
|
1
|
-
|
1
|
+
require 'rails_helper'
|
2
|
+
require 'cancan/matchers'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
describe Canard::Abilities, "for <%= plural_name %>" do
|
6
|
-
|
7
|
-
before do
|
4
|
+
describe Canard::Abilities, '#<%= plural_name %>' do
|
8
5
|
<% if Rails.configuration.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
|
9
|
-
|
6
|
+
let(:acting_<%= name %>) { FactoryGirl.create(:user<%= name == 'user' ? '' : ", :#{name}" %>) }
|
10
7
|
<% elsif Rails.configuration.generators.options[:rails][:fixture_replacement] == :machinist -%>
|
11
|
-
|
8
|
+
let(:acting_<%= name %>) { User.make!(:<%= name %>) }
|
12
9
|
<% else -%>
|
13
|
-
|
10
|
+
let(:acting_<%= name %>) { User.create(roles: %w(<%= name -%>)) }
|
14
11
|
<% end -%>
|
15
|
-
|
16
|
-
|
17
|
-
subject { Ability.new(@user) }
|
18
|
-
|
12
|
+
subject(:<%= name %>_ability) { Ability.new(acting_<%= name %>) }
|
13
|
+
|
19
14
|
<% if ability_definitions.empty? -%>
|
20
|
-
# Define your ability tests thus;
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# before do
|
25
|
-
# @activity = Factory.create(:activity)
|
26
|
-
# end
|
15
|
+
# # Define your ability tests thus;
|
16
|
+
# describe 'on <%= name.camelize %>' do
|
17
|
+
# let(:<%= name %>) { FactoryGirl.create(<%= name %>) }
|
27
18
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
# # on Activity
|
19
|
+
# it { is_expected.to be_able_to(:index, <%= name.camelize %>) }
|
20
|
+
# it { is_expected.to be_able_to(:show, <%= name %>) }
|
21
|
+
# it { is_expected.to be_able_to(:read, <%= name %>) }
|
22
|
+
# it { is_expected.to be_able_to(:new, <%= name %>) }
|
23
|
+
# it { is_expected.to be_able_to(:create, <%= name %>) }
|
24
|
+
# it { is_expected.to be_able_to(:edit, <%= name %>) }
|
25
|
+
# it { is_expected.to be_able_to(:update, <%= name %>) }
|
26
|
+
# it { is_expected.to be_able_to(:destroy, <%= name %>) }
|
27
|
+
# end
|
28
|
+
# # on <%= name.camelize %>
|
39
29
|
<% else -%>
|
40
30
|
<% definitions do |model, definition| -%>
|
41
31
|
<% model_name = model.camelize -%>
|
42
|
-
|
43
|
-
describe 'on <%= model_name -%>' do
|
44
|
-
|
45
|
-
before do
|
32
|
+
describe 'on <%= model_name -%>' do
|
46
33
|
<% if Rails.configuration.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
|
47
|
-
|
34
|
+
let(:<%= model -%>) { FactoryGirl.create(:<%= model -%>) }
|
48
35
|
<% elsif Rails.configuration.generators.options[:rails][:fixture_replacement] == :machinist -%>
|
49
|
-
|
36
|
+
let(:<%= model -%>) { <%= model_name -%>.make! }
|
50
37
|
<% else -%>
|
51
|
-
|
38
|
+
let(:<%= model -%>) { <%= model_name -%>.create }
|
52
39
|
<% end -%>
|
53
|
-
|
54
|
-
|
40
|
+
|
55
41
|
<% definition.cans.each do |can| -%>
|
56
|
-
it {
|
42
|
+
it { is_expected.to be_able_to(<%= ":#{can}, #{model}" -%>) }
|
57
43
|
<% end -%>
|
58
44
|
<%- definition.cannots.each do |cannot| -%>
|
59
|
-
it {
|
45
|
+
it { is_expected.to_not be_able_to(<%= ":#{cannot}, #{model}" -%>) }
|
60
46
|
<% end -%>
|
61
|
-
|
62
47
|
end
|
63
48
|
# on <%= model_name %>
|
64
|
-
|
65
|
-
|
66
|
-
<% end -%>
|
49
|
+
<% end -%>
|
50
|
+
<% end -%>
|
67
51
|
end
|
68
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James McCarthy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.2.3
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.2.3
|
34
37
|
type: :development
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 3.2.3
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.2.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: mongoid
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,32 +62,32 @@ dependencies:
|
|
56
62
|
name: cancancan
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '1'
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '1'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: role_model
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
81
|
version: '0'
|
76
82
|
type: :runtime
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- - "
|
86
|
+
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '0'
|
83
|
-
description: Wraps
|
84
|
-
easy in Rails
|
89
|
+
description: Wraps CanCanCan and RoleModel up to make role based authorisation really
|
90
|
+
easy in Rails 4+.
|
85
91
|
email:
|
86
92
|
- james2mccarthy@gmail.com
|
87
93
|
executables: []
|
@@ -92,7 +98,7 @@ files:
|
|
92
98
|
- ".travis.yml"
|
93
99
|
- Gemfile
|
94
100
|
- MIT-LICENSE
|
95
|
-
- README.
|
101
|
+
- README.md
|
96
102
|
- Rakefile
|
97
103
|
- TODO
|
98
104
|
- canard.gemspec
|
@@ -170,16 +176,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
176
|
version: '0'
|
171
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
178
|
requirements:
|
173
|
-
- - "
|
179
|
+
- - ">"
|
174
180
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
181
|
+
version: 1.3.1
|
176
182
|
requirements:
|
177
|
-
- cancan
|
183
|
+
- cancan's community supported Rails4+ compatible cancancan fork.
|
178
184
|
rubyforge_project: canard
|
179
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.6.10
|
180
186
|
signing_key:
|
181
187
|
specification_version: 4
|
182
|
-
summary: Adds role based authorisation to Rails by combining RoleModel and
|
188
|
+
summary: Adds role based authorisation to Rails by combining RoleModel and CanCanCan.
|
183
189
|
test_files:
|
184
190
|
- test/abilities/administrators.rb
|
185
191
|
- test/canard/abilities_test.rb
|