]> git.openstreetmap.org Git - rails.git/blob - test/system/user_signup_test.rb
ebd91340a53d6b51b78482a882fed2f7fb20b014
[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 from login page" do
42     visit login_path
43
44     click_on "Sign up"
45
46     within_content_body do
47       assert_content "Confirm Password"
48     end
49   end
50
51   test "Show OpenID form when OpenID provider button is clicked" do
52     visit login_path
53
54     within_content_body do
55       assert_no_field "OpenID URL"
56       assert_no_button "Continue"
57
58       click_on "Log in with OpenID"
59
60       assert_field "OpenID URL"
61       assert_button "Continue"
62     end
63   end
64 end