##// END OF EJS Templates
Fixed: User#identity_url raises an error when invalid url is supplied (#2742)....
Jean-Philippe Lang -
r2415:d643d9a94c65
parent child
Show More
@@ -81,11 +81,15 class User < ActiveRecord::Base
81 81 end
82 82
83 83 def identity_url=(url)
84 if url.blank?
85 write_attribute(:identity_url, '')
86 else
84 87 begin
85 self.write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
86 rescue InvalidOpenId
88 write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
89 rescue OpenIdAuthentication::InvalidOpenId
87 90 # Invlaid url, don't save
88 91 end
92 end
89 93 self.read_attribute(:identity_url)
90 94 end
91 95
@@ -205,6 +205,17 class UserTest < Test::Unit::TestCase
205 205 assert_equal normalized_open_id_url, u.identity_url
206 206 end
207 207
208 def test_setting_blank_identity_url
209 u = User.new( :identity_url => 'example.com' )
210 u.identity_url = ''
211 assert u.identity_url.blank?
212 end
213
214 def test_setting_invalid_identity_url
215 u = User.new( :identity_url => 'this is not an openid url' )
216 assert u.identity_url.blank?
217 end
218
208 219 else
209 220 puts "Skipping openid tests."
210 221 end
General Comments 0
You need to be logged in to leave comments. Login now