Skip to content

Commit

Permalink
Merge pull request #2782 from evanboho/fix_wording_for
Browse files Browse the repository at this point in the history
fix application_helper#bulk_menu for overriding abstract_model
  • Loading branch information
mshibuya authored Apr 30, 2019
2 parents ec4e8a8 + 495bf28 commit 6cde21d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def bulk_menu(abstract_model = @abstract_model)
content_tag(:ul, class: 'dropdown-menu', style: 'left:auto; right:0;') do
actions.collect do |action|
content_tag :li do
link_to wording_for(:bulk_link, action), '#', onclick: "jQuery('#bulk_action').val('#{action.action_name}'); jQuery('#bulk_form').submit(); return false;"
link_to wording_for(:bulk_link, action, abstract_model), '#', onclick: "jQuery('#bulk_action').val('#{action.action_name}'); jQuery('#bulk_form').submit(); return false;"
end
end.join.html_safe
end
Expand Down
19 changes: 16 additions & 3 deletions spec/helpers/rails_admin/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,25 @@
end
end
end
@action = RailsAdmin::Config::Actions.find :index
result = helper.bulk_menu(RailsAdmin::AbstractModel.new(Team))
en = {admin: {actions: {
zorg: {bulk_link: 'Zorg all these %{model_label_plural}'},
blub: {bulk_link: 'Blub all these %{model_label_plural}'},
}}}
I18n.backend.store_translations(:en, en)

@abstract_model = RailsAdmin::AbstractModel.new(Team)
result = helper.bulk_menu

expect(result).to match('zorg_action')
expect(result).to match('Zorg all these Teams')
expect(result).to match('blub')
expect(result).to match('Blub all these Teams')

expect(helper.bulk_menu(RailsAdmin::AbstractModel.new(Player))).not_to match('blub')
result_2 = helper.bulk_menu(RailsAdmin::AbstractModel.new(Player))
expect(result_2).to match('zorg_action')
expect(result_2).to match('Zorg all these Players')
expect(result_2).not_to match('blub')
expect(result_2).not_to match('Blub all these Players')
end
end

Expand Down

0 comments on commit 6cde21d

Please sign in to comment.