Skip to content

Commit

Permalink
Merge pull request #1180 from Flink/master
Browse files Browse the repository at this point in the history
Fixes scope behaviour when method is :all and name is set to something else
  • Loading branch information
gregbell committed Jul 7, 2012
2 parents b77073a + 2c01b52 commit 379bc72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/active_admin/scope.rb
Expand Up @@ -24,6 +24,7 @@ def initialize(name, method = nil, options = {}, &block)
@scope_method = method
# Scope ':all' means no scoping
@scope_method ||= name.to_sym unless name.to_sym == :all
@scope_method = nil if method && method.to_s == 'all'
@id = @name.gsub(' ', '').underscore
if block_given?
@scope_method = nil
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/scope_spec.rb
Expand Up @@ -22,6 +22,13 @@
its(:scope_block) { should == nil }
end

context 'when a name and scope method is :all' do
let(:scope) { ActiveAdmin::Scope.new 'Tous', :all }
its(:name) { should eq 'Tous' }
its(:scope_method) { should be_nil }
its(:scope_block) { should be_nil }
end

context "when a name and scope method" do
let(:scope) { ActiveAdmin::Scope.new "With API Access", :with_api_access }
its(:name) { should == "With API Access"}
Expand Down

0 comments on commit 379bc72

Please sign in to comment.