X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/094d6c8bb9949825e1e66b07ba39190a8b57aa0b..e21b9b2bf16d8d27312a82ae4ede5500e618fe88:/test/controllers/users_controller_test.rb diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 62eb79f0c..23c67794a 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -414,6 +414,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_redirected_to :action => :terms, :referer => "/user/#{ERB::Util.u(user.display_name)}/account" end + def test_terms_not_logged_in + get user_terms_path + + assert_redirected_to login_path(:referer => "/user/terms") + end + def test_go_public user = create(:user, :data_public => false) session_for(user) @@ -463,80 +469,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_template :account assert_not_equal user.description, User.find(user.id).description - # Updating the description should work - user.description = "new description" - user.preferred_editor = "default" - post user_account_path(user), :params => { :user => user.attributes } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > div.form-group > div#user_description_container > div#user_description_content > textarea#user_description", user.description - - # Changing to a invalid editor should fail - user.preferred_editor = "unknown" - post user_account_path(user), :params => { :user => user.attributes } - assert_response :success - assert_template :account - assert_select ".notice", false - assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected]", false - - # Changing to a valid editor should work - user.preferred_editor = "id" - post user_account_path(user), :params => { :user => user.attributes } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected][value=?]", "id" - - # Changing to the default editor should work - user.preferred_editor = "default" - post user_account_path(user), :params => { :user => user.attributes } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected]", false - - # Changing to an uploaded image should work - image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif") - post user_account_path(user), :params => { :avatar_action => "new", :user => user.attributes.merge(:avatar => image) } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep" - - # Changing to a gravatar image should work - post user_account_path(user), :params => { :avatar_action => "gravatar", :user => user.attributes } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-group > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar" - - # Removing the image should work - post user_account_path(user), :params => { :avatar_action => "delete", :user => user.attributes } - assert_response :redirect - assert_redirected_to user_account_url(user) - get user_account_path(user) - assert_response :success - assert_template :account - assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-check > input[name=avatar_action][checked]", false - assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-group > div.form-check > input[name=avatar_action][checked]", false - # Adding external authentication should redirect to the auth provider post user_account_path(user), :params => { :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") } assert_response :redirect @@ -624,14 +556,11 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :not_found # Test a normal user - user = create(:user, :home_lon => 1.1, :home_lat => 1.1) - friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2) - create(:friendship, :befriender => user, :befriendee => friend_user) - create(:changeset, :user => friend_user) + user = create(:user) get user_path(user) assert_response :success - assert_select "div#userinformation" do + assert_select "div.content-heading" do assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1 @@ -650,7 +579,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest create(:user_block, :user => blocked_user) get user_path(blocked_user) assert_response :success - assert_select "div#userinformation" do + assert_select "div.content-heading" do assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/traces']", 1 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary']", 1 @@ -666,7 +595,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest create(:user_block, :creator => moderator_user) get user_path(moderator_user) assert_response :success - assert_select "div#userinformation" do + assert_select "div.content-heading" do assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/traces']", 1 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary']", 1 @@ -683,7 +612,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest # Test the normal user get user_path(user) assert_response :success - assert_select "div#userinformation" do + assert_select "div.content-heading" do assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1 assert_select "a[href='/traces/mine']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1 @@ -694,18 +623,13 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 end - # Friends should be visible as we're now logged in - assert_select "div#friends-container" do - assert_select "div.contact-activity", :count => 1 - end - # Login as a moderator session_for(create(:moderator_user)) # Test the normal user get user_path(user) assert_response :success - assert_select "div#userinformation" do + assert_select "div.content-heading" do assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1 @@ -725,23 +649,23 @@ class UsersControllerTest < ActionDispatch::IntegrationTest get user_path(agreed_user) assert_response :success - assert_select "div#userinformation" do - assert_select "p", :count => 0, :text => /Contributor terms/ + assert_select "div.content-heading" do + assert_select "dt", :count => 0, :text => /Contributor terms/ end get user_path(seen_user) assert_response :success # put @response.body - assert_select "div#userinformation" do - assert_select "p", :count => 1, :text => /Contributor terms/ - assert_select "p", /Declined/ + assert_select "div.content-heading" do + assert_select "dt", :count => 1, :text => /Contributor terms/ + assert_select "dd", /Declined/ end get user_path(not_seen_user) assert_response :success - assert_select "div#userinformation" do - assert_select "p", :count => 1, :text => /Contributor terms/ - assert_select "p", /Undecided/ + assert_select "div.content-heading" do + assert_select "dt", :count => 1, :text => /Contributor terms/ + assert_select "dd", /Undecided/ end end