Skip to content

Commit 379bc72

Browse files
committed
Merge pull request activeadmin#1180 from Flink/master
Fixes scope behaviour when method is :all and name is set to something else
2 parents b77073a + 2c01b52 commit 379bc72

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/active_admin/scope.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def initialize(name, method = nil, options = {}, &block)
2424
@scope_method = method
2525
# Scope ':all' means no scoping
2626
@scope_method ||= name.to_sym unless name.to_sym == :all
27+
@scope_method = nil if method && method.to_s == 'all'
2728
@id = @name.gsub(' ', '').underscore
2829
if block_given?
2930
@scope_method = nil

spec/unit/scope_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
its(:scope_block) { should == nil }
2323
end
2424

25+
context 'when a name and scope method is :all' do
26+
let(:scope) { ActiveAdmin::Scope.new 'Tous', :all }
27+
its(:name) { should eq 'Tous' }
28+
its(:scope_method) { should be_nil }
29+
its(:scope_block) { should be_nil }
30+
end
31+
2532
context "when a name and scope method" do
2633
let(:scope) { ActiveAdmin::Scope.new "With API Access", :with_api_access }
2734
its(:name) { should == "With API Access"}

0 commit comments

Comments
 (0)