Merge pull request #11387 from jibees/10957-missing-translation-invalid-url

Admin, White Label: add translation for invalid URL in white label context
This commit is contained in:
Konrad
2023-08-18 15:59:39 +02:00
committed by GitHub
3 changed files with 18 additions and 1 deletions

View File

@@ -452,7 +452,7 @@ class Enterprise < ApplicationRecord
uri = URI(white_label_logo_link)
self.white_label_logo_link = "http://#{white_label_logo_link}" if uri.scheme.nil?
rescue URI::InvalidURIError
errors.add(:white_label_logo_link, I18n.t(:invalid_url))
errors.add(:white_label_logo_link, I18n.t(:invalid_url, url: white_label_logo_link))
end
def image_url_for(image, name)

View File

@@ -90,6 +90,8 @@ en:
preferred_discount_amount: "Calculator Discount Amount:"
preferred_unit_from_list: "Calculator Unit From List:"
preferred_per_unit: "Calculator Per Unit:"
enterprise:
white_label_logo_link: "Link for the logo used in shopfront"
errors:
models:
enterprise_fee:
@@ -3177,6 +3179,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
amount: "Amount"
invoice_number: "Invoice Number"
invoice_file: "File"
invalid_url: "'%{url}' is an invalid URL"
state_names:
ready: Ready
pending: Pending

View File

@@ -716,6 +716,20 @@ describe '
it_behaves_like "edit link with", "www.openfoodnetwork.org", "http://www.openfoodnetwork.org"
it_behaves_like "edit link with", "openfoodnetwork.org", "http://openfoodnetwork.org"
end
shared_examples "edit link with invalid" do |url|
it "url: #{url}" do
fill_in "enterprise_white_label_logo_link", with: url
click_button 'Update'
expect(page)
.to have_content "Link for the logo used in shopfront '#{url}' is an invalid URL"
expect(distributor1.reload.white_label_logo_link).to be_nil
end
end
context "can not edit white label logo link" do
it_behaves_like "edit link with invalid", "invalid url"
end
end
it "can check/uncheck the hide_groups_tab attribute" do