Skip to content

Commit 001df29

Browse files
Evan Kucharevanboho
authored andcommitted
fix application_helper#bulk_menu for overriding abstract_model
When using the helper method `bulk_menu` for a model that is not the current `@abstract_model` the helper incorrectly gets the wording for the instance variable instead of passing the passed variable through.
1 parent 482b5ac commit 001df29

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

app/helpers/rails_admin/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def bulk_menu(abstract_model = @abstract_model)
160160
content_tag(:ul, class: 'dropdown-menu', style: 'left:auto; right:0;') do
161161
actions.collect do |action|
162162
content_tag :li do
163-
link_to wording_for(:bulk_link, action), '#', onclick: "jQuery('#bulk_action').val('#{action.action_name}'); jQuery('#bulk_form').submit(); return false;"
163+
link_to wording_for(:bulk_link, action, abstract_model), '#', onclick: "jQuery('#bulk_action').val('#{action.action_name}'); jQuery('#bulk_form').submit(); return false;"
164164
end
165165
end.join.html_safe
166166
end

spec/helpers/rails_admin/application_helper_spec.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,25 @@ def initialize(_user)
355355
end
356356
end
357357
end
358-
@action = RailsAdmin::Config::Actions.find :index
359-
result = helper.bulk_menu(RailsAdmin::AbstractModel.new(Team))
358+
en = {admin: {actions: {
359+
zorg: {bulk_link: 'Zorg all these %{model_label_plural}'},
360+
blub: {bulk_link: 'Blub all these %{model_label_plural}'},
361+
}}}
362+
I18n.backend.store_translations(:en, en)
363+
364+
@abstract_model = RailsAdmin::AbstractModel.new(Team)
365+
result = helper.bulk_menu
366+
360367
expect(result).to match('zorg_action')
368+
expect(result).to match('Zorg all these Teams')
361369
expect(result).to match('blub')
370+
expect(result).to match('Blub all these Teams')
362371

363-
expect(helper.bulk_menu(RailsAdmin::AbstractModel.new(Player))).not_to match('blub')
372+
result_2 = helper.bulk_menu(RailsAdmin::AbstractModel.new(Player))
373+
expect(result_2).to match('zorg_action')
374+
expect(result_2).to match('Zorg all these Players')
375+
expect(result_2).not_to match('blub')
376+
expect(result_2).not_to match('Blub all these Players')
364377
end
365378
end
366379

0 commit comments

Comments
 (0)