Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes scope behaviour when method is :all and name is set to something else #1180

Merged
merged 1 commit into from
Jul 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/active_admin/scope.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(name, method = nil, options = {}, &block)
@scope_method = method @scope_method = method
# Scope ':all' means no scoping # Scope ':all' means no scoping
@scope_method ||= name.to_sym unless name.to_sym == :all @scope_method ||= name.to_sym unless name.to_sym == :all
@scope_method = nil if method && method.to_s == 'all'
@id = @name.gsub(' ', '').underscore @id = @name.gsub(' ', '').underscore
if block_given? if block_given?
@scope_method = nil @scope_method = nil
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/scope_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
its(:scope_block) { should == nil } its(:scope_block) { should == nil }
end 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 context "when a name and scope method" do
let(:scope) { ActiveAdmin::Scope.new "With API Access", :with_api_access } let(:scope) { ActiveAdmin::Scope.new "With API Access", :with_api_access }
its(:name) { should == "With API Access"} its(:name) { should == "With API Access"}
Expand Down