mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Add instagram handler validator
update entreprise model to match the correct pattern for instagram attribute & add migration to correct wrong links in db + test
This commit is contained in:
committed by
Jean-Baptiste Bellet
parent
fdf3a0d7b7
commit
bfd396e644
@@ -155,6 +155,94 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
|
||||
describe "prevent a wrong instagram link pattern" do
|
||||
it "invalidates the instagram attribute https://facebook.com/user" do
|
||||
e = build(:enterprise, instagram: 'https://facebook.com/user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute tagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'tagram.com/user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user/preferences" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user/preferences')
|
||||
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/')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user-user" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user-user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe "Verify accepted instagram url pattern" do
|
||||
it "validates empty instagram attribute" do
|
||||
e = build(:enterprise, instagram: '')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq ""
|
||||
end
|
||||
|
||||
it "validates the instagram attribute @my_user" do
|
||||
e = build(:enterprise, instagram: '@my_user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "my_user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute user" do
|
||||
e = build(:enterprise, instagram: 'user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute my_www5.example" do
|
||||
e = build(:enterprise, instagram: 'my_www5.example')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "my_www5.example"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute http://instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'http://instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute https://www.instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'https://www.instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute instagram.com/@user" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/@user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute Https://www.Instagram.com/@User" do
|
||||
e = build(:enterprise, instagram: 'Https://www.Instagram.com/@User')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "renders the expected pattern" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/user')
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
end
|
||||
|
||||
describe "preferred_shopfront_taxon_order" do
|
||||
it "empty strings are valid" do
|
||||
enterprise = build(:enterprise, preferred_shopfront_taxon_order: "")
|
||||
|
||||
Reference in New Issue
Block a user