Commit 4226f0e213d0cce4bfe4701a87d51c4c2c32f736
1 parent
6cb016a7
Exists in
master
and in
29 other branches
ActionItem1086: verifying hhtp on organization_website before save
Showing
4 changed files
with
34 additions
and
0 deletions
Show diff stats
app/models/enterprise.rb
@@ -12,6 +12,10 @@ class Enterprise < Organization | @@ -12,6 +12,10 @@ class Enterprise < Organization | ||
12 | 12 | ||
13 | settings_items :organization_website, :historic_and_current_context, :activities_short_description, :zip_code, :city, :state, :country | 13 | settings_items :organization_website, :historic_and_current_context, :activities_short_description, :zip_code, :city, :state, :country |
14 | 14 | ||
15 | + before_save do |enterprise| | ||
16 | + enterprise.organization_website = 'http://' + enterprise.organization_website if enterprise.organization_website && enterprise.organization_website !~ /^https?:\/\// | ||
17 | + end | ||
18 | + | ||
15 | def business_name | 19 | def business_name |
16 | self.nickname | 20 | self.nickname |
17 | end | 21 | end |
app/models/person.rb
@@ -83,6 +83,7 @@ class Person < Profile | @@ -83,6 +83,7 @@ class Person < Profile | ||
83 | before_save do |person| | 83 | before_save do |person| |
84 | person.custom_formation = nil if (! person.formation.nil? && person.formation != 'Others') | 84 | person.custom_formation = nil if (! person.formation.nil? && person.formation != 'Others') |
85 | person.custom_area_of_study = nil if (! person.area_of_study.nil? && person.area_of_study != 'Others') | 85 | person.custom_area_of_study = nil if (! person.area_of_study.nil? && person.area_of_study != 'Others') |
86 | + person.organization_website = 'http://' + person.organization_website if person.organization_website && person.organization_website !~ /^https?:\/\// | ||
86 | end | 87 | end |
87 | 88 | ||
88 | def active_fields | 89 | def active_fields |
test/unit/enterprise_test.rb
@@ -308,4 +308,18 @@ class EnterpriseTest < Test::Unit::TestCase | @@ -308,4 +308,18 @@ class EnterpriseTest < Test::Unit::TestCase | ||
308 | assert enterprise.enable_contact? | 308 | assert enterprise.enable_contact? |
309 | end | 309 | end |
310 | 310 | ||
311 | + should 'save organization_website with http' do | ||
312 | + p = Enterprise.new(:name => 'test_ent', :identifier => 'test_ent') | ||
313 | + p.organization_website = 'website.without.http' | ||
314 | + p.save! | ||
315 | + assert_equal 'http://website.without.http', p.organization_website | ||
316 | + end | ||
317 | + | ||
318 | + should 'save organization_website as typed if has http' do | ||
319 | + p = Enterprise.new(:name => 'test_ent', :identifier => 'test_ent') | ||
320 | + p.organization_website = 'http://website.with.http' | ||
321 | + p.save | ||
322 | + assert_equal 'http://website.with.http', p.organization_website | ||
323 | + end | ||
324 | + | ||
311 | end | 325 | end |
test/unit/person_test.rb
@@ -540,4 +540,19 @@ class PersonTest < Test::Unit::TestCase | @@ -540,4 +540,19 @@ class PersonTest < Test::Unit::TestCase | ||
540 | 540 | ||
541 | assert !p.ask_to_join?(c) | 541 | assert !p.ask_to_join?(c) |
542 | end | 542 | end |
543 | + | ||
544 | + should 'save organization_website with http' do | ||
545 | + p = create_user('person_test').person | ||
546 | + p.organization_website = 'website.without.http' | ||
547 | + p.save | ||
548 | + assert_equal 'http://website.without.http', p.organization_website | ||
549 | + end | ||
550 | + | ||
551 | + should 'save organization_website as typed if has http' do | ||
552 | + p = create_user('person_test').person | ||
553 | + p.organization_website = 'http://website.with.http' | ||
554 | + p.save | ||
555 | + assert_equal 'http://website.with.http', p.organization_website | ||
556 | + end | ||
557 | + | ||
543 | end | 558 | end |