1 require "application_system_test_case"
 
   3 class UserSignupTest < ApplicationSystemTestCase
 
   4   include ActionMailer::TestHelper
 
   7     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
 
  10   test "Sign up with confirmation email" do
 
  15     within_content_body do
 
  16       fill_in "Email", :with => "new_user_account@example.com"
 
  17       fill_in "Display Name", :with => "new_user_account"
 
  18       fill_in "Password", :with => "new_user_password"
 
  19       fill_in "Confirm Password", :with => "new_user_password"
 
  24         assert_content "We sent you a confirmation email"
 
  28     email = ActionMailer::Base.deliveries.first
 
  29     assert_equal 1, email.to.count
 
  30     assert_equal "new_user_account@example.com", email.to.first
 
  31     email_text = email.parts[0].parts[0].decoded
 
  32     match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
 
  37     assert_content "new_user_account"
 
  38     assert_content "Welcome!"
 
  41   test "Sign up with confirmation email resending" do
 
  46     within_content_body do
 
  47       fill_in "Email", :with => "new_user_account@example.com"
 
  48       fill_in "Display Name", :with => "new_user_account"
 
  49       fill_in "Password", :with => "new_user_password"
 
  50       fill_in "Confirm Password", :with => "new_user_password"
 
  55         assert_content "We sent you a confirmation email"
 
  57         click_on "Resend the confirmation email"
 
  59         assert_content "Email Address or Username"
 
  63     assert_content "sent a new confirmation"
 
  64     assert_no_content "<p>"
 
  66     email = ActionMailer::Base.deliveries.last
 
  67     assert_equal 1, email.to.count
 
  68     assert_equal "new_user_account@example.com", email.to.first
 
  69     email_text = email.parts[0].parts[0].decoded
 
  70     match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
 
  75     assert_content "new_user_account"
 
  76     assert_content "Welcome!"
 
  79   test "Sign up from login page" do
 
  82     within_content_heading do
 
  86     within_content_body do
 
  87       assert_content "Confirm Password"
 
  91   test "Show OpenID form when OpenID provider button is clicked" do
 
  94     within_content_body do
 
  95       assert_no_field "OpenID URL"
 
  96       assert_no_button "Continue"
 
  98       click_on "Log in with OpenID"
 
 100       assert_field "OpenID URL"
 
 101       assert_button "Continue"