Skip to content

Commit c25c417

Browse files
Deprecate custom CanCanCan aliases used with accessible_by
1 parent 13c8469 commit c25c417

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

core/app/models/spree/ability.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def can?(action, *args)
4444
super(normalize_action(action), *args)
4545
end
4646

47+
def model_adapter(model_class, action)
48+
super(model_class, normalize_action(action))
49+
end
50+
4751
private
4852

4953
def normalize_action(action)

core/spec/models/spree/ability_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,5 +318,12 @@ def initialize(_user)
318318
expect(Spree::Deprecation).to have_received(:warn)
319319
.with(/alias action display is deprecated/)
320320
end
321+
322+
it 'raises deprecation when called on models by accessible_by' do
323+
Spree::Order.accessible_by(ability, :display)
324+
325+
expect(Spree::Deprecation).to have_received(:warn)
326+
.with(/alias action display is deprecated/)
327+
end
321328
end
322329
end

0 commit comments

Comments
 (0)