1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserControllerTest < ActionController::TestCase
6 # The user creation page loads
9 assert_response :success
12 assert_select "html:root", :count => 1 do
13 assert_select "head", :count => 1 do
14 assert_select "title", :text => /create account/, :count => 1
16 assert_select "body", :count => 1 do
17 assert_select "div#content", :count => 1 do
18 assert_select "form[action='/user/save'][method=post]", :count => 1 do
19 assert_select "input[id=user_email]", :count => 1
20 assert_select "input[id=user_email_confirmation]", :count => 1
21 assert_select "input[id=user_display_name]", :count => 1
22 assert_select "input[id=user_pass_crypt][type=password]", :count => 1
23 assert_select "input[id=user_pass_crypt_confirmation][type=password]", :count => 1
24 assert_select "input[type=submit][value=Signup]", :count => 1
31 # Check that the user account page will display and contains some relevant
32 # information for the user
33 def test_view_user_account
35 assert_response :not_found
37 get :view, {:display_name => "test"}
38 assert_response :success
41 def test_user_api_details
43 assert_response :unauthorized
45 # Private users can login and get the api details
46 usr = users(:normal_user)
47 basic_authorization(usr.email, "test")
49 assert_response :success
50 # Now check the content of the XML returned
52 assert_select "osm:root[version=#{API_VERSION}][generator='#{GENERATOR}']", :count => 1 do
53 assert_select "user[display_name='#{usr.display_name}'][account_created='#{usr.creation_time.xmlschema}']", :count => 1 do
54 assert_select "home[lat='#{usr.home_lat}'][lon='#{usr.home_lon}'][zoom='#{usr.home_zoom}']", :count => 1
60 # Check that we can login through the web using the mixed case fixture,
61 # lower case and upper case
62 def test_user_login_web_case
63 login_web_case_ok users(:normal_user).email, "test"
64 login_web_case_ok users(:normal_user).email.upcase, "test"
65 login_web_case_ok users(:normal_user).email.downcase, "test"
68 def login_web_case_ok(userstring, password)
69 post :login, :user => {:email => userstring, :password => password}
70 assert_redirected_to :controller => 'site', :action => 'index'
73 # Check that we can login to the api, and get the user details
74 # using the mixed case fixture, lower case and upper case
75 def test_user_login_api_case
76 login_api_case_ok users(:normal_user).email, "test"
77 login_api_case_ok users(:normal_user).email.upcase, "test"
78 login_api_case_ok users(:normal_user).email.downcase, "test"
81 def login_api_case_ok(userstring, password)
82 basic_authorization(userstring, password)