3 class UserCreationTest < ActionDispatch::IntegrationTest
9 OmniAuth.config.test_mode = true
15 OmniAuth.config.mock_auth[:openid] = nil
16 OmniAuth.config.mock_auth[:google] = nil
17 OmniAuth.config.mock_auth[:facebook] = nil
18 OmniAuth.config.mock_auth[:windowslive] = nil
19 OmniAuth.config.mock_auth[:github] = nil
20 OmniAuth.config.test_mode = false
23 def test_create_user_form
24 I18n.available_locales.each do |locale|
25 get_via_redirect "/user/new", {}, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
26 assert_response :success
27 assert_template "user/new"
31 def test_user_create_submit_duplicate_email
32 I18n.available_locales.each do |locale|
33 dup_email = users(:public_user).email
34 display_name = "#{locale}_new_tester"
35 assert_difference("User.count", 0) do
36 assert_difference("ActionMailer::Base.deliveries.size", 0) do
38 { :user => { :email => dup_email, :email_confirmation => dup_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } },
39 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
42 assert_response :success
43 assert_template "user/new"
44 assert_equal locale.to_s, response.headers["Content-Language"] unless locale == :root
45 assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email"
46 assert_no_missing_translations
50 def test_user_create_submit_duplicate_username
51 I18n.available_locales.each do |locale|
52 dup_display_name = users(:public_user).display_name
53 email = "#{locale}_new_tester"
54 assert_difference("User.count", 0) do
55 assert_difference("ActionMailer::Base.deliveries.size", 0) do
57 { :user => { :email => email, :email_confirmation => email, :display_name => dup_display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } },
58 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
61 assert_response :success
62 assert_template "user/new"
63 assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name"
64 assert_no_missing_translations
68 def test_user_create_success
69 I18n.available_locales.each do |locale|
70 new_email = "#{locale}newtester@osm.org"
71 display_name = "#{locale}_new_tester"
73 assert_difference("User.count", 0) do
74 assert_difference("ActionMailer::Base.deliveries.size", 0) do
76 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
80 assert_redirected_to "/user/terms"
82 assert_difference("User.count") do
83 assert_difference("ActionMailer::Base.deliveries.size", 1) do
84 post_via_redirect "/user/save", {},
85 { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
90 register_email = ActionMailer::Base.deliveries.first
92 assert_equal register_email.to[0], new_email
93 # Check that the confirm account url is correct
94 assert_match /#{@url}/, register_email.body.to_s
97 assert_response :success
98 assert_template "user/confirm"
100 ActionMailer::Base.deliveries.clear
104 # Check that the user can successfully recover their password
105 def lost_password_recovery_success
106 # Open the lost password form
107 # Submit the lost password form
109 # Submit the reset password token
110 # Check that the password has changed, and the user can login
113 def test_user_create_redirect
114 new_email = "redirect_tester@osm.org"
115 display_name = "redirect_tester"
116 password = "testtest"
117 # nothing special about this page, just need a protected page to redirect back to.
118 referer = "/traces/mine"
119 assert_difference("User.count") do
120 assert_difference("ActionMailer::Base.deliveries.size", 1) do
122 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }, :referer => referer
123 assert_redirected_to "/user/terms"
124 post_via_redirect "/user/save",
125 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }
130 register_email = ActionMailer::Base.deliveries.first
132 assert_equal register_email.to[0], new_email
133 # Check that the confirm account url is correct
134 confirm_regex = Regexp.new("/user/redirect_tester/confirm\\?confirm_string=([a-zA-Z0-9]*)")
135 register_email.parts.each do |part|
136 assert_match confirm_regex, part.body.to_s
138 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
141 assert_response :success
142 assert_template "user/confirm"
144 ActionMailer::Base.deliveries.clear
146 # Go to the confirmation page
147 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
148 assert_response :success
149 assert_template "user/confirm"
151 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
152 assert_response :redirect
154 assert_response :success
155 assert_template "site/welcome"
158 def test_user_create_openid_success
159 OmniAuth.config.add_mock(:openid, :uid => "http://localhost:1123/new.tester")
161 new_email = "newtester-openid@osm.org"
162 display_name = "new_tester-openid"
163 password = "testtest"
164 assert_difference("User.count") do
165 assert_difference("ActionMailer::Base.deliveries.size", 1) do
167 :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 => "" }
168 assert_response :redirect
169 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
171 assert_response :redirect
172 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
174 assert_response :redirect
175 assert_redirected_to "/user/terms"
177 :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 }
178 assert_response :redirect
184 assert_response :success
185 assert_template "user/confirm"
187 ActionMailer::Base.deliveries.clear
190 def test_user_create_openid_failure
191 OmniAuth.config.mock_auth[:openid] = :connection_failed
193 new_email = "newtester-openid2@osm.org"
194 display_name = "new_tester-openid2"
195 assert_difference("User.count", 0) do
196 assert_difference("ActionMailer::Base.deliveries.size", 0) do
198 :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 => "" }
199 assert_response :redirect
200 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
202 assert_response :redirect
203 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
205 assert_response :redirect
206 assert_redirected_to auth_failure_path(:strategy => "openid", :message => "connection_failed", :origin => "/user/new")
208 assert_response :redirect
210 assert_response :success
211 assert_template "user/new"
215 ActionMailer::Base.deliveries.clear
218 def test_user_create_openid_redirect
219 OmniAuth.config.add_mock(:openid, :uid => "http://localhost:1123/new.tester")
221 new_email = "redirect_tester_openid@osm.org"
222 display_name = "redirect_tester_openid"
223 # nothing special about this page, just need a protected page to redirect back to.
224 referer = "/traces/mine"
225 assert_difference("User.count") do
226 assert_difference("ActionMailer::Base.deliveries.size", 1) do
228 :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
229 assert_response :redirect
230 assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
232 assert_response :redirect
233 assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
235 assert_response :redirect
236 assert_redirected_to "/user/terms"
237 post_via_redirect "/user/save",
238 :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" }
243 register_email = ActionMailer::Base.deliveries.first
245 assert_equal register_email.to[0], new_email
246 # Check that the confirm account url is correct
247 confirm_regex = Regexp.new("/user/redirect_tester_openid/confirm\\?confirm_string=([a-zA-Z0-9]*)")
248 register_email.parts.each do |part|
249 assert_match confirm_regex, part.body.to_s
251 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
254 assert_response :success
255 assert_template "user/confirm"
257 ActionMailer::Base.deliveries.clear
259 # Go to the confirmation page
260 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
261 assert_response :success
262 assert_template "user/confirm"
264 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
265 assert_response :redirect
267 assert_response :success
268 assert_template "site/welcome"
271 def test_user_create_google_success
272 OmniAuth.config.add_mock(:google, :uid => "123454321", :extra => {
273 :id_info => { "openid_id" => "http://localhost:1123/new.tester" }
276 new_email = "newtester-google@osm.org"
277 display_name = "new_tester-google"
278 password = "testtest"
279 assert_difference("User.count") do
280 assert_difference("ActionMailer::Base.deliveries.size", 1) do
282 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }
283 assert_response :redirect
284 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
286 assert_response :redirect
287 assert_redirected_to auth_success_path(:provider => "google")
289 assert_response :redirect
290 assert_redirected_to "/user/terms"
292 :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 }
293 assert_response :redirect
299 assert_response :success
300 assert_template "user/confirm"
302 ActionMailer::Base.deliveries.clear
305 def test_user_create_google_failure
306 OmniAuth.config.mock_auth[:google] = :connection_failed
308 new_email = "newtester-google2@osm.org"
309 display_name = "new_tester-google2"
310 assert_difference("User.count", 0) do
311 assert_difference("ActionMailer::Base.deliveries.size", 0) do
313 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }
314 assert_response :redirect
315 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
317 assert_response :redirect
318 assert_redirected_to auth_success_path(:provider => "google")
320 assert_response :redirect
321 assert_redirected_to auth_failure_path(:strategy => "google", :message => "connection_failed", :origin => "/user/new")
323 assert_response :redirect
325 assert_response :success
326 assert_template "user/new"
330 ActionMailer::Base.deliveries.clear
333 def test_user_create_google_redirect
334 OmniAuth.config.add_mock(:google, :uid => "123454321", :extra => {
335 :id_info => { "openid_id" => "http://localhost:1123/new.tester" }
338 new_email = "redirect_tester_google@osm.org"
339 display_name = "redirect_tester_google"
340 # nothing special about this page, just need a protected page to redirect back to.
341 referer = "/traces/mine"
342 assert_difference("User.count") do
343 assert_difference("ActionMailer::Base.deliveries.size", 1) do
345 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
346 assert_response :redirect
347 assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
349 assert_response :redirect
350 assert_redirected_to auth_success_path(:provider => "google")
352 assert_response :redirect
353 assert_redirected_to "/user/terms"
354 post_via_redirect "/user/save",
355 :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" }
360 register_email = ActionMailer::Base.deliveries.first
362 assert_equal register_email.to[0], new_email
363 # Check that the confirm account url is correct
364 confirm_regex = Regexp.new("/user/redirect_tester_google/confirm\\?confirm_string=([a-zA-Z0-9]*)")
365 register_email.parts.each do |part|
366 assert_match confirm_regex, part.body.to_s
368 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
371 assert_response :success
372 assert_template "user/confirm"
374 ActionMailer::Base.deliveries.clear
376 # Go to the confirmation page
377 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
378 assert_response :success
379 assert_template "user/confirm"
381 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
382 assert_response :redirect
384 assert_response :success
385 assert_template "site/welcome"
388 def test_user_create_facebook_success
389 OmniAuth.config.add_mock(:facebook, :uid => "123454321")
391 new_email = "newtester-facebook@osm.org"
392 display_name = "new_tester-facebook"
393 password = "testtest"
394 assert_difference("User.count") do
395 assert_difference("ActionMailer::Base.deliveries.size", 1) do
397 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }
398 assert_response :redirect
399 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
401 assert_response :redirect
402 assert_redirected_to auth_success_path(:provider => "facebook")
404 assert_response :redirect
405 assert_redirected_to "/user/terms"
407 :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 }
408 assert_response :redirect
414 assert_response :success
415 assert_template "user/confirm"
417 ActionMailer::Base.deliveries.clear
420 def test_user_create_facebook_failure
421 OmniAuth.config.mock_auth[:facebook] = :connection_failed
423 new_email = "newtester-facebook2@osm.org"
424 display_name = "new_tester-facebook2"
425 assert_difference("User.count", 0) do
426 assert_difference("ActionMailer::Base.deliveries.size", 0) do
428 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }
429 assert_response :redirect
430 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
432 assert_response :redirect
433 assert_redirected_to auth_success_path(:provider => "facebook")
435 assert_response :redirect
436 assert_redirected_to auth_failure_path(:strategy => "facebook", :message => "connection_failed", :origin => "/user/new")
438 assert_response :redirect
440 assert_response :success
441 assert_template "user/new"
445 ActionMailer::Base.deliveries.clear
448 def test_user_create_facebook_redirect
449 OmniAuth.config.add_mock(:facebook, :uid => "123454321")
451 new_email = "redirect_tester_facebook@osm.org"
452 display_name = "redirect_tester_facebook"
453 # nothing special about this page, just need a protected page to redirect back to.
454 referer = "/traces/mine"
455 assert_difference("User.count") do
456 assert_difference("ActionMailer::Base.deliveries.size", 1) do
458 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
459 assert_response :redirect
460 assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
462 assert_response :redirect
463 assert_redirected_to auth_success_path(:provider => "facebook")
465 assert_response :redirect
466 assert_redirected_to "/user/terms"
467 post_via_redirect "/user/save",
468 :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" }
473 register_email = ActionMailer::Base.deliveries.first
475 assert_equal register_email.to[0], new_email
476 # Check that the confirm account url is correct
477 confirm_regex = Regexp.new("/user/redirect_tester_facebook/confirm\\?confirm_string=([a-zA-Z0-9]*)")
478 register_email.parts.each do |part|
479 assert_match confirm_regex, part.body.to_s
481 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
484 assert_response :success
485 assert_template "user/confirm"
487 ActionMailer::Base.deliveries.clear
489 # Go to the confirmation page
490 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
491 assert_response :success
492 assert_template "user/confirm"
494 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
495 assert_response :redirect
497 assert_response :success
498 assert_template "site/welcome"
501 def test_user_create_windowslive_success
502 OmniAuth.config.add_mock(:windowslive, :uid => "123454321")
504 new_email = "newtester-windowslive@osm.org"
505 display_name = "new_tester-windowslive"
506 password = "testtest"
507 assert_difference("User.count") do
508 assert_difference("ActionMailer::Base.deliveries.size", 1) do
510 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }
511 assert_response :redirect
512 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
514 assert_response :redirect
515 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
517 assert_response :redirect
518 assert_redirected_to "/user/terms"
520 :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 }
521 assert_response :redirect
527 assert_response :success
528 assert_template "user/confirm"
530 ActionMailer::Base.deliveries.clear
533 def test_user_create_windowslive_failure
534 OmniAuth.config.mock_auth[:windowslive] = :connection_failed
536 new_email = "newtester-windowslive2@osm.org"
537 display_name = "new_tester-windowslive2"
538 assert_difference("User.count", 0) do
539 assert_difference("ActionMailer::Base.deliveries.size", 0) do
541 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }
542 assert_response :redirect
543 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
545 assert_response :redirect
546 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
548 assert_response :redirect
549 assert_redirected_to auth_failure_path(:strategy => "windowslive", :message => "connection_failed", :origin => "/user/new")
551 assert_response :redirect
553 assert_response :success
554 assert_template "user/new"
558 ActionMailer::Base.deliveries.clear
561 def test_user_create_windowslive_redirect
562 OmniAuth.config.add_mock(:windowslive, :uid => "123454321")
564 new_email = "redirect_tester_windowslive@osm.org"
565 display_name = "redirect_tester_windowslive"
566 # nothing special about this page, just need a protected page to redirect back to.
567 referer = "/traces/mine"
568 assert_difference("User.count") do
569 assert_difference("ActionMailer::Base.deliveries.size", 1) do
571 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
572 assert_response :redirect
573 assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
575 assert_response :redirect
576 assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
578 assert_response :redirect
579 assert_redirected_to "/user/terms"
580 post_via_redirect "/user/save",
581 :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" }
586 register_email = ActionMailer::Base.deliveries.first
588 assert_equal register_email.to[0], new_email
589 # Check that the confirm account url is correct
590 confirm_regex = Regexp.new("/user/redirect_tester_windowslive/confirm\\?confirm_string=([a-zA-Z0-9]*)")
591 register_email.parts.each do |part|
592 assert_match confirm_regex, part.body.to_s
594 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
597 assert_response :success
598 assert_template "user/confirm"
600 ActionMailer::Base.deliveries.clear
602 # Go to the confirmation page
603 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
604 assert_response :success
605 assert_template "user/confirm"
607 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
608 assert_response :redirect
610 assert_response :success
611 assert_template "site/welcome"
614 def test_user_create_github_success
615 OmniAuth.config.add_mock(:github, :uid => "123454321")
617 new_email = "newtester-github@osm.org"
618 display_name = "new_tester-github"
619 password = "testtest"
620 assert_difference("User.count") do
621 assert_difference("ActionMailer::Base.deliveries.size", 1) do
623 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }
624 assert_response :redirect
625 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
627 assert_response :redirect
628 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
630 assert_response :redirect
631 assert_redirected_to "/user/terms"
633 :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 }
634 assert_response :redirect
640 assert_response :success
641 assert_template "user/confirm"
643 ActionMailer::Base.deliveries.clear
646 def test_user_create_github_failure
647 OmniAuth.config.mock_auth[:github] = :connection_failed
649 new_email = "newtester-github2@osm.org"
650 display_name = "new_tester-github2"
651 assert_difference("User.count", 0) do
652 assert_difference("ActionMailer::Base.deliveries.size", 0) do
654 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }
655 assert_response :redirect
656 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
658 assert_response :redirect
659 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
661 assert_response :redirect
662 assert_redirected_to auth_failure_path(:strategy => "github", :message => "connection_failed", :origin => "/user/new")
664 assert_response :redirect
666 assert_response :success
667 assert_template "user/new"
671 ActionMailer::Base.deliveries.clear
674 def test_user_create_github_redirect
675 OmniAuth.config.add_mock(:github, :uid => "123454321")
677 new_email = "redirect_tester_github@osm.org"
678 display_name = "redirect_tester_github"
679 # nothing special about this page, just need a protected page to redirect back to.
680 referer = "/traces/mine"
681 assert_difference("User.count") do
682 assert_difference("ActionMailer::Base.deliveries.size", 1) do
684 :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
685 assert_response :redirect
686 assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
688 assert_response :redirect
689 assert_redirected_to auth_success_path(:provider => "github", :origin => "/user/new")
691 assert_response :redirect
692 assert_redirected_to "/user/terms"
693 post_via_redirect "/user/save",
694 :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" }
699 register_email = ActionMailer::Base.deliveries.first
701 assert_equal register_email.to[0], new_email
702 # Check that the confirm account url is correct
703 confirm_regex = Regexp.new("/user/redirect_tester_github/confirm\\?confirm_string=([a-zA-Z0-9]*)")
704 register_email.parts.each do |part|
705 assert_match confirm_regex, part.body.to_s
707 confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
710 assert_response :success
711 assert_template "user/confirm"
713 ActionMailer::Base.deliveries.clear
715 # Go to the confirmation page
716 get "/user/#{display_name}/confirm", :confirm_string => confirm_string
717 assert_response :success
718 assert_template "user/confirm"
720 post "/user/#{display_name}/confirm", :confirm_string => confirm_string
721 assert_response :redirect
723 assert_response :success
724 assert_template "site/welcome"