]> git.openstreetmap.org Git - rails.git/blob - test/system/user_signup_test.rb
Merge remote-tracking branch 'upstream/pull/5681'
[rails.git] / test / system / user_signup_test.rb
1 require "application_system_test_case"
2
3 class UserSignupTest < ApplicationSystemTestCase
4   include ActionMailer::TestHelper
5
6   def setup
7     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
8   end
9
10   test "Sign up with confirmation email" do
11     visit root_path
12
13     click_on "Sign Up"
14
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"
20
21       assert_emails 1 do
22         click_on "Sign Up"
23
24         assert_content "We sent you a confirmation email"
25       end
26     end
27
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)
33     assert_not_nil match
34
35     visit match[0]
36
37     assert_content "new_user_account"
38     assert_content "Welcome!"
39   end
40
41   test "Sign up with confirmation email resending" do
42     visit root_path
43
44     click_on "Sign Up"
45
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"
51
52       assert_emails 2 do
53         click_on "Sign Up"
54
55         assert_content "We sent you a confirmation email"
56
57         click_on "Resend the confirmation email"
58
59         assert_content "Email Address or Username"
60       end
61     end
62
63     assert_content "sent a new confirmation"
64     assert_no_content "<p>"
65
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)
71     assert_not_nil match
72
73     visit match[0]
74
75     assert_content "new_user_account"
76     assert_content "Welcome!"
77   end
78
79   test "Sign up from login page" do
80     visit login_path
81
82     within_content_heading do
83       click_on "Sign Up"
84     end
85
86     within_content_body do
87       assert_content "Confirm Password"
88     end
89   end
90
91   test "Show OpenID form when OpenID provider button is clicked" do
92     visit login_path
93
94     within_content_body do
95       assert_no_field "OpenID URL"
96       assert_no_button "Continue"
97
98       click_on "Log in with OpenID"
99
100       assert_field "OpenID URL"
101       assert_button "Continue"
102     end
103   end
104 end