X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/3893fd72a953beba360fd205ca9fcc2abf623024..c7545691bbd3a62e20d323fa685f025d2bfbfe6f:/test/controllers/user_controller_test.rb diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index 7c79717f3..1561a9ebe 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -749,6 +749,12 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :reset_password + # Test that errors are reported for erroneous submissions + post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "different_password" } } + assert_response :success + assert_template :reset_password + assert_select "div#errorExplanation" + # Test setting a new password post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } } assert_response :redirect @@ -782,6 +788,11 @@ class UserControllerTest < ActionController::TestCase get :account, :params => { :display_name => user.display_name }, :session => { :user => user } assert_response :success assert_template :account + assert_select "form#accountForm" do |form| + assert_equal "post", form.attr("method").to_s + assert_select "input[name='_method']", false + assert_equal "/user/#{URI.encode(user.display_name)}/account", form.attr("action").to_s + end # Updating the description should work user.description = "new description" @@ -1007,6 +1018,34 @@ class UserControllerTest < ActionController::TestCase end end + # Test whether information about contributor terms is shown for users who haven't agreed + def test_terms_not_agreed + agreed_user = create(:user, :terms_agreed => 3.days.ago) + seen_user = create(:user, :terms_seen => true) + not_seen_user = create(:user, :terms_seen => false) + + get :view, :params => { :display_name => agreed_user.display_name } + assert_response :success + assert_select "div#userinformation" do + assert_select "p", :count => 0, :text => /Contributor terms/ + end + + get :view, :params => { :display_name => seen_user.display_name } + assert_response :success + # put @response.body + assert_select "div#userinformation" do + assert_select "p", :count => 1, :text => /Contributor terms/ + assert_select "p", /Declined/ + end + + get :view, :params => { :display_name => not_seen_user.display_name } + assert_response :success + assert_select "div#userinformation" do + assert_select "p", :count => 1, :text => /Contributor terms/ + assert_select "p", /Undecided/ + end + end + def test_api_read user = create(:user, :description => "test", :terms_agreed => Date.yesterday) # check that a visible user is returned properly @@ -1065,7 +1104,7 @@ class UserControllerTest < ActionController::TestCase assert_response :unauthorized # check that we get a response when logged in - basic_authorization(user.email, "test") + basic_authorization user.email, "test" get :api_details assert_response :success assert_equal "text/xml", response.content_type @@ -1120,7 +1159,7 @@ class UserControllerTest < ActionController::TestCase assert_response :unauthorized # check that we get a response when logged in - basic_authorization(user.email, "test") + basic_authorization user.email, "test" get :api_gpx_files assert_response :success assert_equal "application/xml", response.content_type