mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Accept full URLs
It looks like the intention was there, so I made it work. I've included a real world example, but added capitalisation to complete the test.
This commit is contained in:
@@ -450,7 +450,8 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url&.sub(%r{(https?://)?}, '')
|
||||
# Strip protocol and trailing slash
|
||||
url&.sub(%r{(https?://)?}, '')&.sub(%r{/\z}, '')
|
||||
end
|
||||
|
||||
def correct_whatsapp_url(phone_number)
|
||||
|
||||
@@ -171,8 +171,8 @@ describe Enterprise do
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user/" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user/')
|
||||
it "invalidates the instagram attribute https://www.instagram.com/p/Cpg4McNPyJA/" do
|
||||
e = build(:enterprise, instagram: 'https://www.instagram.com/p/Cpg4McNPyJA/')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
|
||||
@@ -117,8 +117,8 @@ describe "Registration" do
|
||||
click_button "Continue"
|
||||
expect(page).to have_content 'How can people find My Awesome Enterprise online?'
|
||||
|
||||
# Filling in social with invalid value for instagram - slash after InStAgRaM
|
||||
fill_in "enterprise_instagram", with: 'www.instagram.com/InStAgRaM/'
|
||||
# Filling in social with invalid value for instagram - a link to a post instead of user
|
||||
fill_in "enterprise_instagram", with: 'https://www.instagram.com/p/Cpg4McNPyJA/'
|
||||
accept_alert "Failed to update your enterprise." do
|
||||
click_button "Continue"
|
||||
end
|
||||
@@ -129,7 +129,7 @@ describe "Registration" do
|
||||
fill_in 'enterprise_facebook', with: 'FaCeBoOk'
|
||||
fill_in 'enterprise_linkedin', with: 'LiNkEdIn'
|
||||
fill_in 'enterprise_twitter', with: 'https://www.twitter.com/@TwItTeR'
|
||||
fill_in 'enterprise_instagram', with: 'www.instagram.com/InStAgRaM'
|
||||
fill_in 'enterprise_instagram', with: 'https://www.instagram.com/OpenFoodNetwork/'
|
||||
click_button "Continue"
|
||||
expect(page).to have_content 'Finished!'
|
||||
|
||||
@@ -147,7 +147,7 @@ describe "Registration" do
|
||||
expect(e.facebook).to eq "FaCeBoOk"
|
||||
expect(e.linkedin).to eq "LiNkEdIn"
|
||||
expect(e.twitter).to eq "TwItTeR"
|
||||
expect(e.instagram).to eq "instagram"
|
||||
expect(e.instagram).to eq "openfoodnetwork"
|
||||
|
||||
click_link "Go to Enterprise Dashboard"
|
||||
expect(page).to have_content "CHOOSE YOUR PACKAGE"
|
||||
|
||||
Reference in New Issue
Block a user