diff --git a/app/controllers/admin/dfc_product_imports_controller.rb b/app/controllers/admin/dfc_product_imports_controller.rb index df2cec0347..d3001838b6 100644 --- a/app/controllers/admin/dfc_product_imports_controller.rb +++ b/app/controllers/admin/dfc_product_imports_controller.rb @@ -15,7 +15,7 @@ module Admin def index # Fetch DFC catalog JSON for preview api = DfcRequest.new(spree_current_user) - @catalog_url = params.require(:catalog_url) + @catalog_url = params.require(:catalog_url).strip @catalog_json = api.call(@catalog_url) graph = DfcIo.import(@catalog_json) catalog = DfcCatalog.new(graph) diff --git a/spec/system/admin/dfc_product_import_spec.rb b/spec/system/admin/dfc_product_import_spec.rb index 8e45169409..03c86eb379 100644 --- a/spec/system/admin/dfc_product_import_spec.rb +++ b/spec/system/admin/dfc_product_import_spec.rb @@ -20,18 +20,17 @@ RSpec.describe "DFC Product Import" do it "imports from given catalog" do visit admin_product_import_path - # We are testing against our own catalog for now but we want to replace - # this with the URL of another app when available. - # We also add a common mistake: copying the URL with an extra space. - host = Rails.application.default_url_options[:host] - url = " http://#{host}/api/dfc/enterprises/#{enterprise.id}/catalog_items" - fill_in "catalog_url", with: url + fill_in "catalog_url", with: "invalid url" select enterprise.name, from: "Create products for enterprise" click_button "Preview" expect(page).to have_content "This catalog URL is not valid" - url = "http://#{host}/api/dfc/enterprises/#{enterprise.id}/catalog_items" + # We are testing against our own catalog for now but we want to replace + # this with the URL of another app when available. + # We also add a common mistake: copying the URL with an extra space. + host = Rails.application.default_url_options[:host] + url = " http://#{host}/api/dfc/enterprises/#{enterprise.id}/catalog_items" fill_in "catalog_url", with: url select enterprise.name, from: "Create products for enterprise" click_button "Preview"