diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 48c3917..bfc0bdc 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -12,6 +12,10 @@ class Enterprise < Organization settings_items :organization_website, :historic_and_current_context, :activities_short_description, :zip_code, :city, :state, :country + before_save do |enterprise| + enterprise.organization_website = 'http://' + enterprise.organization_website if enterprise.organization_website && enterprise.organization_website !~ /^https?:\/\// + end + def business_name self.nickname end diff --git a/app/models/person.rb b/app/models/person.rb index 986f1e5..4a1b199 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -83,6 +83,7 @@ class Person < Profile before_save do |person| person.custom_formation = nil if (! person.formation.nil? && person.formation != 'Others') person.custom_area_of_study = nil if (! person.area_of_study.nil? && person.area_of_study != 'Others') + person.organization_website = 'http://' + person.organization_website if person.organization_website && person.organization_website !~ /^https?:\/\// end def active_fields diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 0462dd4..d65fedf 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -308,4 +308,18 @@ class EnterpriseTest < Test::Unit::TestCase assert enterprise.enable_contact? end + should 'save organization_website with http' do + p = Enterprise.new(:name => 'test_ent', :identifier => 'test_ent') + p.organization_website = 'website.without.http' + p.save! + assert_equal 'http://website.without.http', p.organization_website + end + + should 'save organization_website as typed if has http' do + p = Enterprise.new(:name => 'test_ent', :identifier => 'test_ent') + p.organization_website = 'http://website.with.http' + p.save + assert_equal 'http://website.with.http', p.organization_website + end + end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 4dbaa98..1591d45 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -540,4 +540,19 @@ class PersonTest < Test::Unit::TestCase assert !p.ask_to_join?(c) end + + should 'save organization_website with http' do + p = create_user('person_test').person + p.organization_website = 'website.without.http' + p.save + assert_equal 'http://website.without.http', p.organization_website + end + + should 'save organization_website as typed if has http' do + p = create_user('person_test').person + p.organization_website = 'http://website.with.http' + p.save + assert_equal 'http://website.with.http', p.organization_website + end + end -- libgit2 0.21.2