]> git.openstreetmap.org Git - rails.git/blob - test/system/user_signup_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / system / user_signup_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class UserSignupTest < ApplicationSystemTestCase
6   include ActionMailer::TestHelper
7
8   def setup
9     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
10   end
11
12   test "Sign up with confirmation email" do
13     visit root_path
14
15     click_on "Sign Up"
16
17     within_content_body do
18       fill_in "Email", :with => "new_user_account@example.com"
19       fill_in "Display Name", :with => "new_user_account"
20       fill_in "Password", :with => "new_user_password"
21       fill_in "Confirm Password", :with => "new_user_password"
22
23       assert_emails 1 do
24         click_on "Sign Up"
25
26         assert_content "We sent you a confirmation email"
27       end
28     end
29
30     email = ActionMailer::Base.deliveries.first
31     assert_equal 1, email.to.count
32     assert_equal "new_user_account@example.com", email.to.first
33     email_text = email.parts[0].parts[0].decoded
34     match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
35     assert_not_nil match
36
37     visit match[0]
38
39     assert_content "new_user_account"
40     assert_content "Welcome!"
41   end
42
43   test "Sign up with confirmation email resending" do
44     visit root_path
45
46     click_on "Sign Up"
47
48     within_content_body do
49       fill_in "Email", :with => "new_user_account@example.com"
50       fill_in "Display Name", :with => "new_user_account"
51       fill_in "Password", :with => "new_user_password"
52       fill_in "Confirm Password", :with => "new_user_password"
53
54       assert_emails 2 do
55         click_on "Sign Up"
56
57         assert_content "We sent you a confirmation email"
58
59         click_on "Resend the confirmation email"
60
61         assert_content "Email Address or Username"
62       end
63     end
64
65     assert_content "sent a new confirmation"
66     assert_no_content "<p>"
67
68     email = ActionMailer::Base.deliveries.last
69     assert_equal 1, email.to.count
70     assert_equal "new_user_account@example.com", email.to.first
71     email_text = email.parts[0].parts[0].decoded
72     match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
73     assert_not_nil match
74
75     visit match[0]
76
77     assert_content "new_user_account"
78     assert_content "Welcome!"
79   end
80
81   test "Sign up from login page" do
82     visit login_path
83
84     within_content_heading do
85       click_on "Sign Up"
86     end
87
88     within_content_body do
89       assert_content "Confirm Password"
90     end
91   end
92 end