3 class UserCreationTest < ActionDispatch::IntegrationTest
9 OmniAuth.config.test_mode = true
11 stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
17 OmniAuth.config.mock_auth[:openid] = nil
18 OmniAuth.config.mock_auth[:google] = nil
19 OmniAuth.config.mock_auth[:facebook] = nil
20 OmniAuth.config.mock_auth[:windowslive] = nil
21 OmniAuth.config.mock_auth[:github] = nil
22 OmniAuth.config.test_mode = false
25 def test_create_user_form
26 I18n.available_locales.each do |locale|
27 get_via_redirect "/user/new", {}, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
28 assert_response :success
29 assert_template "user/new"
33 def test_user_create_submit_duplicate_email
34 I18n.available_locales.each do |locale|
35 dup_email = users(:public_user).email
36 display_name = "#{locale}_new_tester"
37 assert_difference("User.count", 0) do
38 assert_difference("ActionMailer::Base.deliveries.size", 0) do
40 { :user => { :email => dup_email, :email_confirmation => dup_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } },
41 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
44 assert_response :success
45 assert_template "user/new"
46 assert_equal locale.to_s, response.headers["Content-Language"] unless locale == :root
47 assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email"
48 assert_no_missing_translations
52 def test_user_create_submit_duplicate_username
53 I18n.available_locales.each do |locale|
54 dup_display_name = users(:public_user).display_name
55 email = "#{locale}_new_tester"
56 assert_difference("User.count", 0) do
57 assert_difference("ActionMailer::Base.deliveries.size", 0) do
59 { :user => { :email => email, :email_confirmation => email, :display_name => dup_display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } },
60 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
63 assert_response :success
64 assert_template "user/new"
65 assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name"
66 assert_no_missing_translations
70 def test_user_create_success
71 I18n.available_locales.each do |locale|
72 new_email = "#{locale}newtester@osm.org"
73 display_name = "#{locale}_new_tester"
75 assert_difference("User.count", 0) do
76 assert_difference("ActionMailer::Base.deliveries.size", 0) do
78 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
82 assert_redirected_to "/user/terms"
84 assert_difference("User.count") do
85 assert_difference("ActionMailer::Base.deliveries.size", 1) do
86 post_via_redirect "/user/save", {},
87 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
92 register_email = ActionMailer::Base.deliveries.first
94 assert_equal register_email.to[0], new_email
95 # Check that the confirm account url is correct
96 assert_match /#{@url}/, register_email.body.to_s
99 assert_response :success
100 assert_template "user/confirm"
102 ActionMailer::Base.deliveries.clear
106 # Check that the user can successfully recover their password
107 def lost_password_recovery_success
108 # Open the lost password form
109 # Submit the lost password form
111 # Submit the reset password token
112 # Check that the password has changed, and the user can login
115 def test_user_create_redirect
116 new_email = "redirect_tester@osm.org"
117 display_name = "redirect_tester"
118 password = "testtest"
119 # nothing special about this page, just need a protected page to redirect back to.
120 referer = "/traces/mine"
121 assert_difference("User.count") do
122 assert_difference("ActionMailer::Base.deliveries.size", 1) do
124 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }, :referer => referer
125 assert_redirected_to "/user/terms"
126 post_via_redirect "/user/save",
127 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }
132 register_email = ActionMailer::Base.deliveries.first
134 assert_equal register_email.to[0], new_email
135 # Check that the confirm account url is correct
136 confirm_regex = Regexp.new("/user/redirect_tester/confirm\\?confirm_string=([a-zA-Z0-9]*)")
137 register_email.parts.each do |part|
138 assert_match confirm_regex, part.body.to_s
140 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
143 assert_response :success
144 assert_template "user/confirm"
146 ActionMailer::Base.deliveries.clear
148 # Go to the confirmation page
149 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
150 assert_response :success
151 assert_template "user/confirm"
153 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
154 assert_response :redirect
156 assert_response :success
157 assert_template "site/welcome"
160 def test_user_create_openid_success
161 OmniAuth.config.add_mock(:openid, :uid => "http://localhost:1123/new.tester")
163 new_email = "newtester-openid@osm.org"
164 display_name = "new_tester-openid"
165 password = "testtest"
166 assert_difference("User.count") do
167 assert_difference("ActionMailer::Base.deliveries.size", 1) do
169 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
170 assert_response :redirect
171 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
173 assert_response :redirect
174 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
176 assert_response :redirect
177 assert_redirected_to "/user/terms"
179 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => password, :pass_crypt_confirmation => password }
180 assert_response :redirect
186 assert_response :success
187 assert_template "user/confirm"
189 ActionMailer::Base.deliveries.clear
192 def test_user_create_openid_failure
193 OmniAuth.config.mock_auth[:openid] = :connection_failed
195 new_email = "newtester-openid2@osm.org"
196 display_name = "new_tester-openid2"
197 assert_difference("User.count", 0) do
198 assert_difference("ActionMailer::Base.deliveries.size", 0) do
200 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
201 assert_response :redirect
202 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
204 assert_response :redirect
205 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
207 assert_response :redirect
208 assert_redirected_to auth_failure_path(:strategy => "openid", :message => "connection_failed", :origin => "/user/new")
210 assert_response :redirect
212 assert_response :success
213 assert_template "user/new"
217 ActionMailer::Base.deliveries.clear
220 def test_user_create_openid_redirect
221 OmniAuth.config.add_mock(:openid, :uid => "http://localhost:1123/new.tester")
223 new_email = "redirect_tester_openid@osm.org"
224 display_name = "redirect_tester_openid"
225 # nothing special about this page, just need a protected page to redirect back to.
226 referer = "/traces/mine"
227 assert_difference("User.count") do
228 assert_difference("ActionMailer::Base.deliveries.size", 1) do
230 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
231 assert_response :redirect
232 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
234 assert_response :redirect
235 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
237 assert_response :redirect
238 assert_redirected_to "/user/terms"
239 post_via_redirect "/user/save",
240 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
245 register_email = ActionMailer::Base.deliveries.first
247 assert_equal register_email.to[0], new_email
248 # Check that the confirm account url is correct
249 confirm_regex = Regexp.new("/user/redirect_tester_openid/confirm\\?confirm_string=([a-zA-Z0-9]*)")
250 register_email.parts.each do |part|
251 assert_match confirm_regex, part.body.to_s
253 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
256 assert_response :success
257 assert_template "user/confirm"
259 ActionMailer::Base.deliveries.clear
261 # Go to the confirmation page
262 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
263 assert_response :success
264 assert_template "user/confirm"
266 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
267 assert_response :redirect
269 assert_response :success
270 assert_template "site/welcome"
273 def test_user_create_google_success
274 OmniAuth.config.add_mock(:google, :uid => "123454321", :extra => {
275 :id_info => { "openid_id" => "http://localhost:1123/new.tester" }
278 new_email = "newtester-google@osm.org"
279 display_name = "new_tester-google"
280 password = "testtest"
281 assert_difference("User.count") do
282 assert_difference("ActionMailer::Base.deliveries.size", 1) do
284 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }
285 assert_response :redirect
286 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
288 assert_response :redirect
289 assert_redirected_to auth_success_path(:provider => "google")
291 assert_response :redirect
292 assert_redirected_to "/user/terms"
294 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }
295 assert_response :redirect
301 assert_response :success
302 assert_template "user/confirm"
304 ActionMailer::Base.deliveries.clear
307 def test_user_create_google_failure
308 OmniAuth.config.mock_auth[:google] = :connection_failed
310 new_email = "newtester-google2@osm.org"
311 display_name = "new_tester-google2"
312 assert_difference("User.count", 0) do
313 assert_difference("ActionMailer::Base.deliveries.size", 0) do
315 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }
316 assert_response :redirect
317 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
319 assert_response :redirect
320 assert_redirected_to auth_success_path(:provider => "google")
322 assert_response :redirect
323 assert_redirected_to auth_failure_path(:strategy => "google", :message => "connection_failed", :origin => "/user/new")
325 assert_response :redirect
327 assert_response :success
328 assert_template "user/new"
332 ActionMailer::Base.deliveries.clear
335 def test_user_create_google_redirect
336 OmniAuth.config.add_mock(:google, :uid => "123454321", :extra => {
337 :id_info => { "openid_id" => "http://localhost:1123/new.tester" }
340 new_email = "redirect_tester_google@osm.org"
341 display_name = "redirect_tester_google"
342 # nothing special about this page, just need a protected page to redirect back to.
343 referer = "/traces/mine"
344 assert_difference("User.count") do
345 assert_difference("ActionMailer::Base.deliveries.size", 1) do
347 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
348 assert_response :redirect
349 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
351 assert_response :redirect
352 assert_redirected_to auth_success_path(:provider => "google")
354 assert_response :redirect
355 assert_redirected_to "/user/terms"
356 post_via_redirect "/user/save",
357 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
362 register_email = ActionMailer::Base.deliveries.first
364 assert_equal register_email.to[0], new_email
365 # Check that the confirm account url is correct
366 confirm_regex = Regexp.new("/user/redirect_tester_google/confirm\\?confirm_string=([a-zA-Z0-9]*)")
367 register_email.parts.each do |part|
368 assert_match confirm_regex, part.body.to_s
370 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
373 assert_response :success
374 assert_template "user/confirm"
376 ActionMailer::Base.deliveries.clear
378 # Go to the confirmation page
379 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
380 assert_response :success
381 assert_template "user/confirm"
383 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
384 assert_response :redirect
386 assert_response :success
387 assert_template "site/welcome"
390 def test_user_create_facebook_success
391 OmniAuth.config.add_mock(:facebook, :uid => "123454321")
393 new_email = "newtester-facebook@osm.org"
394 display_name = "new_tester-facebook"
395 password = "testtest"
396 assert_difference("User.count") do
397 assert_difference("ActionMailer::Base.deliveries.size", 1) do
399 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }
400 assert_response :redirect
401 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
403 assert_response :redirect
404 assert_redirected_to auth_success_path(:provider => "facebook")
406 assert_response :redirect
407 assert_redirected_to "/user/terms"
409 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }
410 assert_response :redirect
416 assert_response :success
417 assert_template "user/confirm"
419 ActionMailer::Base.deliveries.clear
422 def test_user_create_facebook_failure
423 OmniAuth.config.mock_auth[:facebook] = :connection_failed
425 new_email = "newtester-facebook2@osm.org"
426 display_name = "new_tester-facebook2"
427 assert_difference("User.count", 0) do
428 assert_difference("ActionMailer::Base.deliveries.size", 0) do
430 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }
431 assert_response :redirect
432 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
434 assert_response :redirect
435 assert_redirected_to auth_success_path(:provider => "facebook")
437 assert_response :redirect
438 assert_redirected_to auth_failure_path(:strategy => "facebook", :message => "connection_failed", :origin => "/user/new")
440 assert_response :redirect
442 assert_response :success
443 assert_template "user/new"
447 ActionMailer::Base.deliveries.clear
450 def test_user_create_facebook_redirect
451 OmniAuth.config.add_mock(:facebook, :uid => "123454321")
453 new_email = "redirect_tester_facebook@osm.org"
454 display_name = "redirect_tester_facebook"
455 # nothing special about this page, just need a protected page to redirect back to.
456 referer = "/traces/mine"
457 assert_difference("User.count") do
458 assert_difference("ActionMailer::Base.deliveries.size", 1) do
460 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
461 assert_response :redirect
462 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
464 assert_response :redirect
465 assert_redirected_to auth_success_path(:provider => "facebook")
467 assert_response :redirect
468 assert_redirected_to "/user/terms"
469 post_via_redirect "/user/save",
470 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
475 register_email = ActionMailer::Base.deliveries.first
477 assert_equal register_email.to[0], new_email
478 # Check that the confirm account url is correct
479 confirm_regex = Regexp.new("/user/redirect_tester_facebook/confirm\\?confirm_string=([a-zA-Z0-9]*)")
480 register_email.parts.each do |part|
481 assert_match confirm_regex, part.body.to_s
483 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
486 assert_response :success
487 assert_template "user/confirm"
489 ActionMailer::Base.deliveries.clear
491 # Go to the confirmation page
492 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
493 assert_response :success
494 assert_template "user/confirm"
496 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
497 assert_response :redirect
499 assert_response :success
500 assert_template "site/welcome"
503 def test_user_create_windowslive_success
504 OmniAuth.config.add_mock(:windowslive, :uid => "123454321")
506 new_email = "newtester-windowslive@osm.org"
507 display_name = "new_tester-windowslive"
508 password = "testtest"
509 assert_difference("User.count") do
510 assert_difference("ActionMailer::Base.deliveries.size", 1) do
512 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }
513 assert_response :redirect
514 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
516 assert_response :redirect
517 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
519 assert_response :redirect
520 assert_redirected_to "/user/terms"
522 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }
523 assert_response :redirect
529 assert_response :success
530 assert_template "user/confirm"
532 ActionMailer::Base.deliveries.clear
535 def test_user_create_windowslive_failure
536 OmniAuth.config.mock_auth[:windowslive] = :connection_failed
538 new_email = "newtester-windowslive2@osm.org"
539 display_name = "new_tester-windowslive2"
540 assert_difference("User.count", 0) do
541 assert_difference("ActionMailer::Base.deliveries.size", 0) do
543 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }
544 assert_response :redirect
545 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
547 assert_response :redirect
548 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
550 assert_response :redirect
551 assert_redirected_to auth_failure_path(:strategy => "windowslive", :message => "connection_failed", :origin => "/user/new")
553 assert_response :redirect
555 assert_response :success
556 assert_template "user/new"
560 ActionMailer::Base.deliveries.clear
563 def test_user_create_windowslive_redirect
564 OmniAuth.config.add_mock(:windowslive, :uid => "123454321")
566 new_email = "redirect_tester_windowslive@osm.org"
567 display_name = "redirect_tester_windowslive"
568 # nothing special about this page, just need a protected page to redirect back to.
569 referer = "/traces/mine"
570 assert_difference("User.count") do
571 assert_difference("ActionMailer::Base.deliveries.size", 1) do
573 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
574 assert_response :redirect
575 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
577 assert_response :redirect
578 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
580 assert_response :redirect
581 assert_redirected_to "/user/terms"
582 post_via_redirect "/user/save",
583 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
588 register_email = ActionMailer::Base.deliveries.first
590 assert_equal register_email.to[0], new_email
591 # Check that the confirm account url is correct
592 confirm_regex = Regexp.new("/user/redirect_tester_windowslive/confirm\\?confirm_string=([a-zA-Z0-9]*)")
593 register_email.parts.each do |part|
594 assert_match confirm_regex, part.body.to_s
596 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
599 assert_response :success
600 assert_template "user/confirm"
602 ActionMailer::Base.deliveries.clear
604 # Go to the confirmation page
605 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
606 assert_response :success
607 assert_template "user/confirm"
609 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
610 assert_response :redirect
612 assert_response :success
613 assert_template "site/welcome"
616 def test_user_create_github_success
617 OmniAuth.config.add_mock(:github, :uid => "123454321")
619 new_email = "newtester-github@osm.org"
620 display_name = "new_tester-github"
621 password = "testtest"
622 assert_difference("User.count") do
623 assert_difference("ActionMailer::Base.deliveries.size", 1) do
625 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }
626 assert_response :redirect
627 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
629 assert_response :redirect
630 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
632 assert_response :redirect
633 assert_redirected_to "/user/terms"
635 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }
636 assert_response :redirect
642 assert_response :success
643 assert_template "user/confirm"
645 ActionMailer::Base.deliveries.clear
648 def test_user_create_github_failure
649 OmniAuth.config.mock_auth[:github] = :connection_failed
651 new_email = "newtester-github2@osm.org"
652 display_name = "new_tester-github2"
653 assert_difference("User.count", 0) do
654 assert_difference("ActionMailer::Base.deliveries.size", 0) do
656 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }
657 assert_response :redirect
658 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
660 assert_response :redirect
661 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
663 assert_response :redirect
664 assert_redirected_to auth_failure_path(:strategy => "github", :message => "connection_failed", :origin => "/user/new")
666 assert_response :redirect
668 assert_response :success
669 assert_template "user/new"
673 ActionMailer::Base.deliveries.clear
676 def test_user_create_github_redirect
677 OmniAuth.config.add_mock(:github, :uid => "123454321")
679 new_email = "redirect_tester_github@osm.org"
680 display_name = "redirect_tester_github"
681 # nothing special about this page, just need a protected page to redirect back to.
682 referer = "/traces/mine"
683 assert_difference("User.count") do
684 assert_difference("ActionMailer::Base.deliveries.size", 1) do
686 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
687 assert_response :redirect
688 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
690 assert_response :redirect
691 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
693 assert_response :redirect
694 assert_redirected_to "/user/terms"
695 post_via_redirect "/user/save",
696 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
701 register_email = ActionMailer::Base.deliveries.first
703 assert_equal register_email.to[0], new_email
704 # Check that the confirm account url is correct
705 confirm_regex = Regexp.new("/user/redirect_tester_github/confirm\\?confirm_string=([a-zA-Z0-9]*)")
706 register_email.parts.each do |part|
707 assert_match confirm_regex, part.body.to_s
709 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
712 assert_response :success
713 assert_template "user/confirm"
715 ActionMailer::Base.deliveries.clear
717 # Go to the confirmation page
718 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
719 assert_response :success
720 assert_template "user/confirm"
722 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
723 assert_response :redirect
725 assert_response :success
726 assert_template "site/welcome"