mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Test twitter with (almost) real world example
I discovered that twitter doesn't have 'www' in the url anymore, no '@' symbol and interestingly no trailing slash. I added back the '@' just so we can test that still. Using a regex group we can cater for optional www in a single regex.
This commit is contained in:
@@ -459,11 +459,11 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def correct_instagram_url(url)
|
||||
url && strip_url(url.downcase).sub(%r{www.instagram.com/}, '').sub(%r{instagram.com/}, '').delete("@")
|
||||
url && strip_url(url.downcase).sub(%r{(www\.)?instagram.com/}, '').delete("@")
|
||||
end
|
||||
|
||||
def correct_twitter_url(url)
|
||||
url && strip_url(url).sub(%r{www.twitter.com/}, '').delete("@")
|
||||
url && strip_url(url).sub(%r{(www\.)?twitter.com/}, '').delete("@")
|
||||
end
|
||||
|
||||
def set_unused_address_fields
|
||||
|
||||
@@ -128,7 +128,7 @@ describe "Registration" do
|
||||
fill_in 'enterprise_website', with: 'www.shop.com'
|
||||
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_twitter', with: 'https://twitter.com/@OpenFoodNet'
|
||||
fill_in 'enterprise_instagram', with: 'https://www.instagram.com/OpenFoodNetwork/'
|
||||
click_button "Continue"
|
||||
expect(page).to have_content 'Finished!'
|
||||
@@ -146,7 +146,7 @@ describe "Registration" do
|
||||
expect(e.website).to eq "www.shop.com"
|
||||
expect(e.facebook).to eq "FaCeBoOk"
|
||||
expect(e.linkedin).to eq "LiNkEdIn"
|
||||
expect(e.twitter).to eq "TwItTeR"
|
||||
expect(e.twitter).to eq "OpenFoodNet"
|
||||
expect(e.instagram).to eq "openfoodnetwork"
|
||||
|
||||
click_link "Go to Enterprise Dashboard"
|
||||
|
||||
Reference in New Issue
Block a user