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

[EUWE] container common mixin: ui_lookup should get a string #13389

Merged
merged 1 commit into from
Jan 10, 2017
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
11 changes: 6 additions & 5 deletions app/controllers/mixins/containers_common_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def check_compliance(model)
ids = showlist ? find_checked_items : find_current_item(model)

if ids.empty?
add_flash(_("No %{model} were selected for %{task}") % {:model => ui_lookup(:models => model),
add_flash(_("No %{model} were selected for %{task}") % {:model => ui_lookup(:models => model.to_s),
:task => "Compliance Check"}, :error)
else
process_check_compliance(model, ids)
Expand All @@ -196,7 +196,7 @@ def check_compliance(model)

def find_current_item(model)
if params[:id].nil? || model.find_by(:id => params[:id].to_i).nil?
add_flash(_("%{model} no longer exists") % {:table => ui_lookup(:model => model)}, :error)
add_flash(_("%{model} no longer exists") % {:model => ui_lookup(:model => model.to_s)}, :error)
[]
else
[params[:id].to_i]
Expand Down Expand Up @@ -225,9 +225,10 @@ def process_check_compliance(model, ids)
begin
entity.check_compliance
rescue StandardError => bang
add_flash(_("%{model} \"%{name}\": Error during 'Check Compliance': ") %
{:model => ui_lookup(:model => model),
:name => entity.name} << bang.message,
add_flash(_("%{model} \"%{name}\": Error during 'Check Compliance': %{error}") %
{:model => ui_lookup(:model => model.to_s),
:name => entity.name,
:error => bang.message},
:error) # Push msg and error flag
else
add_flash(_("\"%{record}\": Compliance check successfully initiated") % {:record => entity.name})
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/container_image_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
expect(controller.send(:flash_errors?)).not_to be_truthy
end

it "when Check Compliance is pressed with no images" do
ApplicationController.handle_exceptions = true

expect(controller).to receive(:check_compliance).and_call_original
expect(controller).to receive(:add_flash).with("Container Image no longer exists", :error)
expect(controller).to receive(:add_flash).with("No Container Images were selected for Compliance Check", :error)
post :button, :params => { :pressed => 'container_image_check_compliance', :format => :js }
end

it 'renders edit container image tags' do
ApplicationController.handle_exceptions = true

Expand Down