Commit 911de09a7059cb5ecf40d884e4d4c261dd9a8f8d

Authored by AntonioTerceiro
1 parent 754655ff

ActionItem449: adding http:// if not already there


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2021 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 14 additions and 0 deletions   Show diff stats
app/models/event.rb
... ... @@ -83,4 +83,13 @@ class Event < Article
83 83 result
84 84 end
85 85  
  86 + def link=(value)
  87 + self.body[:link] =
  88 + if value =~ /https?:\/\//
  89 + value
  90 + else
  91 + 'http://' + value
  92 + end
  93 + end
  94 +
86 95 end
... ...
test/unit/event_test.rb
... ... @@ -138,6 +138,11 @@ class EventTest < ActiveSupport::TestCase
138 138  
139 139 end
140 140  
  141 + should 'add http:// to the link if not already present' do
  142 + a = Event.new(:link => 'www.nohttp.net')
  143 + assert_equal 'http://www.nohttp.net', a.link
  144 + end
  145 +
141 146 protected
142 147  
143 148 def assert_tag_in_string(text, options)
... ...