##// 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,10 +81,14 class User < ActiveRecord::Base
81 81 end
82 82
83 83 def identity_url=(url)
84 begin
85 self.write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
86 rescue InvalidOpenId
87 # Invlaid url, don't save
84 if url.blank?
85 write_attribute(:identity_url, '')
86 else
87 begin
88 write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
89 rescue OpenIdAuthentication::InvalidOpenId
90 # Invlaid url, don't save
91 end
88 92 end
89 93 self.read_attribute(:identity_url)
90 94 end
@@ -204,6 +204,17 class UserTest < Test::Unit::TestCase
204 204 u = User.new( :identity_url => 'example.com' )
205 205 assert_equal normalized_open_id_url, u.identity_url
206 206 end
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
207 218
208 219 else
209 220 puts "Skipping openid tests."
General Comments 0
You need to be logged in to leave comments. Login now