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

Adds error on dialog field association circular reference catch #2056

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
3 changes: 3 additions & 0 deletions app/controllers/miq_ae_customization_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class MiqAeCustomizationController < ApplicationController
require "English"
include_concern 'CustomButtons'
include_concern 'OldDialogs'
include_concern 'Dialogs'
Expand Down Expand Up @@ -56,6 +57,8 @@ def upload_import_file
add_flash(_("Error: the file uploaded is not of the supported format"), :error)
rescue DialogImportValidator::ParsedNonDialogYamlError
add_flash(_("Error during upload: incorrect Dialog format, only service dialogs can be imported"), :error)
rescue DialogImportValidator::DialogFieldAssociationCircularReferenceError
add_flash(_("Error during upload: the following dialog fields to be imported contain circular association references: #{$ERROR_INFO}"), :error)
rescue DialogImportValidator::InvalidDialogFieldTypeError
add_flash(_("Error during upload: one of the DialogField types is not supported"), :error)
end
Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/miq_ae_customization_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@
end
end

context "when the dialog importer raises a circular reference error" do
before do
allow(dialog_import_service).to receive(:store_for_import)
.and_raise(DialogImportValidator::DialogFieldAssociationCircularReferenceError)
end

it "redirects with an error message" do
post :upload_import_file, :params => params, :xhr => true
expect(controller.instance_variable_get(:@flash_array))
.to include(:message => "Error during upload: the following dialog fields to be imported contain circular association references: DialogImportValidator::DialogFieldAssociationCircularReferenceError",
:level => :error)
end
end

context "when the dialog importer raises a parse non dialog yaml error" do
before do
allow(dialog_import_service).to receive(:store_for_import)
Expand Down