activeadmin-cancan 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,23 @@
1
1
  require 'activeadmin'
2
-
2
+
3
3
  ActiveAdmin::Namespace.class_eval do
4
4
  alias_method :old_register, :register
5
-
5
+
6
6
  def register(resource_class, options = {}, &block)
7
7
  config = find_or_build_resource(resource_class, options)
8
+
9
+ # Register the resource
8
10
  register_resource_controller(config)
9
- resource_dsl.prepare_menu(config)
11
+
12
+ if ActiveAdmin::VERSION =~ /^0\.[5-9]/
13
+ ActiveAdmin::ResourceDSL.new(config).prepare_menu5
14
+ else
15
+ resource_dsl.prepare_menu(config)
16
+ end
17
+
10
18
  config = old_register(resource_class, options, &block)
11
19
  config.controller.load_and_authorize_resource
12
- config
20
+ config
13
21
  end
14
22
  end
15
23
 
@@ -21,12 +29,19 @@ ActiveAdmin::DSL.class_eval do
21
29
  menu :if => proc{ can?(:manage, resource) }
22
30
  end
23
31
  end
32
+
33
+ def prepare_menu5
34
+ resource = controller.resource_class
35
+ instance_eval do
36
+ menu :if => proc{ can?(:manage, resource) }
37
+ end
38
+ end
24
39
  end
25
40
 
26
41
  CanCan::ControllerResource.class_eval do
27
42
  def collection_instance=(instance)
28
43
  end
29
-
44
+
30
45
  def resource_instance=(instance)
31
46
  end
32
47
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminCancan
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -7,7 +7,7 @@ class ActiveadminCancanTest < ActiveSupport::TestCase
7
7
 
8
8
  test "authorize resource with cancan on register" do
9
9
  controller = ActiveAdmin.register(Foo).controller
10
- controller.expects(:authorize_resource)
10
+ controller.expects(:load_and_authorize_resource)
11
11
  ActiveAdmin::Resource.any_instance.stubs(:controller).returns(controller)
12
12
  ActiveAdmin.register Foo
13
13
  end
File without changes
@@ -200,3 +200,7 @@
200
200
   (0.1ms) rollback transaction
201
201
   (0.0ms) begin transaction
202
202
   (0.1ms) rollback transaction
203
+  (0.5ms) begin transaction
204
+  (0.1ms) rollback transaction
205
+  (0.1ms) begin transaction
206
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-cancan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70366631082800 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70366631082800
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: cancan
27
- requirement: &70366631081600 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 1.6.2
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70366631081600
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.2
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: activeadmin
38
- requirement: &70366631080100 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.4.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70366631080100
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: sqlite3
49
- requirement: &70366631079060 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70366631079060
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Provides CanCan roles to ActiveAdmin
59
79
  email:
60
80
  - laurent@11factory.fr
@@ -116,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
136
  version: '0'
117
137
  segments:
118
138
  - 0
119
- hash: 1370845984403649450
139
+ hash: 1516628949132554263
120
140
  required_rubygems_version: !ruby/object:Gem::Requirement
121
141
  none: false
122
142
  requirements:
@@ -125,10 +145,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
145
  version: '0'
126
146
  segments:
127
147
  - 0
128
- hash: 1370845984403649450
148
+ hash: 1516628949132554263
129
149
  requirements: []
130
150
  rubyforge_project:
131
- rubygems_version: 1.7.2
151
+ rubygems_version: 1.8.23
132
152
  signing_key:
133
153
  specification_version: 3
134
154
  summary: Provides CanCan roles to ActiveAdmin