File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Bug Fixes
6
+
7
+ * Fix pundit policy retrieving for static pages when the pundit namespace is : active_admin . [ #5777 ] by [ @kwent ]
8
+
5
9
## 2.1.0 [ ☰] ( https://github.com/activeadmin/activeadmin/compare/v2.0.0..v2.1.0 )
6
10
7
11
### Bug Fixes
@@ -454,6 +458,7 @@ Please check [0-6-stable] for previous changes.
454
458
[ #5740 ] : https://github.com/activeadmin/activeadmin/pull/5740
455
459
[ #5751 ] : https://github.com/activeadmin/activeadmin/pull/5751
456
460
[ #5758 ] : https://github.com/activeadmin/activeadmin/pull/5758
461
+ [ #5777 ] : https://github.com/activeadmin/activeadmin/pull/5777
457
462
458
463
[ @5t111111 ] : https://github.com/5t111111
459
464
[ @aarek ] : https://github.com/aarek
@@ -490,6 +495,7 @@ Please check [0-6-stable] for previous changes.
490
495
[ @johnnyshields ] : https://github.com/johnnyshields
491
496
[ @kjeldahl ] : https://github.com/kjeldahl
492
497
[ @kobeumut ] : https://github.com/kobeumut
498
+ [ @kwent ] : https://github.com/kwent
493
499
[ @leio10 ] : https://github.com/leio10
494
500
[ @markstory ] : https://github.com/markstory
495
501
[ @mauriciopasquier ] : https://github.com/mauriciopasquier
Original file line number Diff line number Diff line change @@ -57,8 +57,8 @@ def format_action(action, subject)
57
57
private
58
58
59
59
def namespace ( object )
60
- if ActiveAdmin . application . pundit_policy_namespace
61
- [ ActiveAdmin . application . pundit_policy_namespace . to_sym , object ]
60
+ if default_policy_namespace && ! object . class . to_s . include? ( default_policy_namespace . to_s . camelize )
61
+ [ default_policy_namespace . to_sym , object ]
62
62
else
63
63
object
64
64
end
@@ -72,6 +72,10 @@ def default_policy(user, subject)
72
72
default_policy_class . new ( user , subject )
73
73
end
74
74
8000
75
+ def default_policy_namespace
76
+ ActiveAdmin . application . pundit_policy_namespace
77
+ end
78
+
75
79
end
76
80
77
81
end
Original file line number Diff line number Diff line change @@ -130,5 +130,17 @@ def resolve
130
130
end
131
131
end
132
132
end
133
+
134
+ context "when retrieve_policy is given a page and namespace is :active_admin" do
135
+ let ( :page ) { namespace . register_page "Dashboard" }
136
+
137
+ subject ( :policy ) { auth . retrieve_policy ( page ) }
138
+
139
+ before do
140
+ allow ( ActiveAdmin . application ) . to receive ( :pundit_policy_namespace ) . and_return :active_admin
141
+ end
142
+
143
+ it ( "should return page policy instance" ) { is_expected . to be_instance_of ( ActiveAdmin ::PagePolicy ) }
144
+ end
133
145
end
134
146
end
You can’t perform that action at this time.
0 commit comments