mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Remove surrounding whitespace from pasted DFC URL
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user