mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
creating facebook url
This commit is contained in:
@@ -41,4 +41,20 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
address.firstname = address.lastname = 'unused' if address.present?
|
||||
end
|
||||
|
||||
def facebook_url
|
||||
if (facebook.blank?) then
|
||||
return nil
|
||||
end
|
||||
if is_url? facebook then
|
||||
facebook
|
||||
else
|
||||
'https://www.facebook.com/' + facebook
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def is_url?(s)
|
||||
s.andand.include? '://'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,4 +52,15 @@ describe EnterpriseGroup do
|
||||
EnterpriseGroup.on_front_page.should == [eg1]
|
||||
end
|
||||
end
|
||||
|
||||
describe "urls" do
|
||||
it 'provides a Facebook URL' do
|
||||
g = create(:enterprise_group)
|
||||
g.facebook_url.should be_nil
|
||||
g.facebook = 'test'
|
||||
g.facebook_url.should == 'https://www.facebook.com/test'
|
||||
g.facebook = 'http://fb.com/test'
|
||||
g.facebook_url.should == g.facebook
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user