X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3893fd72a953beba360fd205ca9fcc2abf623024..a182820139de22196d7f30e06047a81afc7323f5:/test/controllers/user_controller_test.rb diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index 7c79717f3..48e8b4119 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -20,6 +20,10 @@ class UserControllerTest < ActionController::TestCase { :path => "/api/0.6/user/gpx_files", :method => :get }, { :controller => "user", :action => "api_gpx_files" } ) + assert_routing( + { :path => "/api/0.6/users", :method => :get }, + { :controller => "user", :action => "api_users" } + ) assert_routing( { :path => "/login", :method => :get }, @@ -126,7 +130,7 @@ class UserControllerTest < ActionController::TestCase assert_routing( { :path => "/user/username", :method => :get }, - { :controller => "user", :action => "view", :display_name => "username" } + { :controller => "user", :action => "show", :display_name => "username" } ) assert_routing( @@ -241,7 +245,7 @@ class UserControllerTest < ActionController::TestCase register_email = ActionMailer::Base.deliveries.first assert_equal register_email.to[0], user.email - assert_match /#{@url}/, register_email.body.to_s + assert_match(/#{@url}/, register_email.body.to_s) # Check the page assert_redirected_to :action => "confirm", :display_name => user.display_name @@ -400,7 +404,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string } assert_redirected_to login_path - assert_match /Confirmed your account/, flash[:notice] + assert_match(/Confirmed your account/, flash[:notice]) end def test_confirm_success_good_token_no_referer @@ -423,7 +427,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token } assert_redirected_to login_path - assert_match /Confirmed your account/, flash[:notice] + assert_match(/Confirmed your account/, flash[:notice]) end def test_confirm_success_no_token_with_referer @@ -434,7 +438,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string } assert_redirected_to login_path(:referer => diary_new_path) - assert_match /Confirmed your account/, flash[:notice] + assert_match(/Confirmed your account/, flash[:notice]) end def test_confirm_success_good_token_with_referer @@ -457,7 +461,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token } assert_redirected_to login_path(:referer => diary_new_path) - assert_match /Confirmed your account/, flash[:notice] + assert_match(/Confirmed your account/, flash[:notice]) end def test_confirm_expired_token @@ -467,7 +471,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string } assert_redirected_to :action => "confirm" - assert_match /confirmation code has expired/, flash[:error] + assert_match(/confirmation code has expired/, flash[:error]) end def test_confirm_already_confirmed @@ -477,7 +481,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string } assert_redirected_to :action => "login" - assert_match /already been confirmed/, flash[:error] + assert_match(/already been confirmed/, flash[:error]) end def test_confirm_resend_success @@ -490,7 +494,7 @@ class UserControllerTest < ActionController::TestCase assert_response :redirect assert_redirected_to login_path - assert_match /sent a new confirmation/, flash[:notice] + assert_match(/sent a new confirmation/, flash[:notice]) email = ActionMailer::Base.deliveries.last @@ -537,7 +541,7 @@ class UserControllerTest < ActionController::TestCase post :confirm_email, :params => { :confirm_string => confirm_string } assert_response :redirect assert_redirected_to :action => :account, :display_name => user.display_name - assert_match /Confirmed your change of email address/, flash[:notice] + assert_match(/Confirmed your change of email address/, flash[:notice]) end def test_confirm_email_already_confirmed @@ -547,14 +551,14 @@ class UserControllerTest < ActionController::TestCase post :confirm_email, :params => { :confirm_string => confirm_string } assert_response :redirect assert_redirected_to :action => :account, :display_name => user.display_name - assert_match /already been confirmed/, flash[:error] + assert_match(/already been confirmed/, flash[:error]) end def test_confirm_email_bad_token post :confirm_email, :params => { :confirm_string => "XXXXX" } assert_response :success assert_template :confirm_email - assert_match /confirmation code has expired or does not exist/, flash[:error] + assert_match(/confirmation code has expired or does not exist/, flash[:error]) end ## @@ -567,11 +571,11 @@ class UserControllerTest < ActionController::TestCase stub_gravatar_request(user.new_email, 200) confirm_string = user.tokens.create.token # precondition gravatar should be turned off - assert !user.image_use_gravatar + assert_not user.image_use_gravatar post :confirm_email, :params => { :confirm_string => confirm_string } assert_response :redirect assert_redirected_to :action => :account, :display_name => user.display_name - assert_match /Confirmed your change of email address/, flash[:notice] + assert_match(/Confirmed your change of email address/, flash[:notice]) # gravatar use should now be enabled assert User.find(user.id).image_use_gravatar end @@ -586,9 +590,9 @@ class UserControllerTest < ActionController::TestCase post :confirm_email, :params => { :confirm_string => confirm_string } assert_response :redirect assert_redirected_to :action => :account, :display_name => user.display_name - assert_match /Confirmed your change of email address/, flash[:notice] + assert_match(/Confirmed your change of email address/, flash[:notice]) # gravatar use should now be disabled - assert !User.find(user.id).image_use_gravatar + assert_not User.find(user.id).image_use_gravatar end def test_terms_new_user @@ -674,7 +678,7 @@ class UserControllerTest < ActionController::TestCase end assert_response :redirect assert_redirected_to :action => :login - assert_match /^Sorry you lost it/, flash[:notice] + assert_match(/^Sorry you lost it/, flash[:notice]) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count assert_equal user.email, email.to.first @@ -687,7 +691,7 @@ class UserControllerTest < ActionController::TestCase end assert_response :redirect assert_redirected_to :action => :login - assert_match /^Sorry you lost it/, flash[:notice] + assert_match(/^Sorry you lost it/, flash[:notice]) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count assert_equal uppercase_user.email, email.to.first @@ -710,7 +714,7 @@ class UserControllerTest < ActionController::TestCase end assert_response :redirect assert_redirected_to :action => :login - assert_match /^Sorry you lost it/, flash[:notice] + assert_match(/^Sorry you lost it/, flash[:notice]) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count assert_equal third_user.email, email.to.first @@ -723,7 +727,7 @@ class UserControllerTest < ActionController::TestCase end assert_response :redirect assert_redirected_to :action => :login - assert_match /^Sorry you lost it/, flash[:notice] + assert_match(/^Sorry you lost it/, flash[:notice]) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count assert_equal third_user.email, email.to.first @@ -749,6 +753,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 @@ -772,7 +782,7 @@ class UserControllerTest < ActionController::TestCase # you are not logged in get :account, :params => { :display_name => user.display_name } assert_response :redirect - assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{URI.encode(user.display_name)}/account" + assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{ERB::Util.u(user.display_name)}/account" # Make sure that you are blocked when not logged in as the right user get :account, :params => { :display_name => user.display_name }, :session => { :user => create(:user) } @@ -782,6 +792,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/#{ERB::Util.u(user.display_name)}/account", form.attr("action").to_s + end # Updating the description should work user.description = "new description" @@ -848,7 +863,7 @@ class UserControllerTest < ActionController::TestCase # Adding external authentication should redirect to the auth provider post :account, :params => { :display_name => user.display_name, :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }, :session => { :user => user } assert_response :redirect - assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{URI.encode(user.display_name)}/account") + assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{ERB::Util.u(user.display_name)}/account") # Changing name to one that exists should fail new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name) @@ -920,90 +935,118 @@ class UserControllerTest < ActionController::TestCase # Check that the user account page will display and contains some relevant # information for the user - def test_view + def test_show # Test a non-existent user - get :view, :params => { :display_name => "unknown" } + get :show, :params => { :display_name => "unknown" } assert_response :not_found # Test a normal user user = create(:user) - get :view, :params => { :display_name => user.display_name } + get :show, :params => { :display_name => user.display_name } assert_response :success assert_select "div#userinformation" do - assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/traces']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 0 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 0 + 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 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 + assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 end # Test a user who has been blocked blocked_user = create(:user) create(:user_block, :user => blocked_user) - get :view, :params => { :display_name => blocked_user.display_name } + get :show, :params => { :display_name => blocked_user.display_name } assert_response :success assert_select "div#userinformation" do - assert_select "a[href^='/user/#{URI.encode(blocked_user.display_name)}/history']", 1 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/traces']", 1 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/diary']", 1 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/diary/comments']", 1 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/account']", 0 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/blocks']", 1 - assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{URI.encode(blocked_user.display_name)}']", 0 + 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 + assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary/comments']", 1 + assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']", 0 + assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']", 1 + assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']", 0 + assert_select "a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0 end # Test a moderator who has applied blocks moderator_user = create(:moderator_user) create(:user_block, :creator => moderator_user) - get :view, :params => { :display_name => moderator_user.display_name } + get :show, :params => { :display_name => moderator_user.display_name } assert_response :success assert_select "div#userinformation" do - assert_select "a[href^='/user/#{URI.encode(moderator_user.display_name)}/history']", 1 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/traces']", 1 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/diary']", 1 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/diary/comments']", 1 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/account']", 0 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/blocks']", 0 - assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/blocks_by']", 1 - assert_select "a[href='/blocks/new/#{URI.encode(moderator_user.display_name)}']", 0 + 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 + assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary/comments']", 1 + assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']", 0 + assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']", 0 + assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']", 1 + assert_select "a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0 end # Login as a normal user session[:user] = user.id # Test the normal user - get :view, :params => { :display_name => user.display_name } + get :show, :params => { :display_name => user.display_name } assert_response :success assert_select "div#userinformation" do - assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1 + 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/#{URI.encode(user.display_name)}/diary']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 1 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 + assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 end # Login as a moderator session[:user] = create(:moderator_user).id # Test the normal user - get :view, :params => { :display_name => user.display_name } + get :show, :params => { :display_name => user.display_name } + assert_response :success + assert_select "div#userinformation" 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 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 + assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 + assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1 + 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 :show, :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 :show, :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 :show, :params => { :display_name => not_seen_user.display_name } assert_response :success assert_select "div#userinformation" do - assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/traces']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 0 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0 - assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0 - assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 1 + assert_select "p", :count => 1, :text => /Contributor terms/ + assert_select "p", /Undecided/ end end @@ -1065,7 +1108,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 @@ -1107,6 +1150,48 @@ class UserControllerTest < ActionController::TestCase end end + def test_api_users + user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday) + user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday) + user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday) + + get :api_users, :params => { :users => user1.id } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 1 do + assert_select "user[id='#{user1.id}']", :count => 1 + assert_select "user[id='#{user2.id}']", :count => 0 + assert_select "user[id='#{user3.id}']", :count => 0 + end + + get :api_users, :params => { :users => user2.id } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 1 do + assert_select "user[id='#{user1.id}']", :count => 0 + assert_select "user[id='#{user2.id}']", :count => 1 + assert_select "user[id='#{user3.id}']", :count => 0 + end + + get :api_users, :params => { :users => "#{user1.id},#{user3.id}" } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 2 do + assert_select "user[id='#{user1.id}']", :count => 1 + assert_select "user[id='#{user2.id}']", :count => 0 + assert_select "user[id='#{user3.id}']", :count => 1 + end + + get :api_users, :params => { :users => create(:user, :suspended).id } + assert_response :not_found + + get :api_users, :params => { :users => create(:user, :deleted).id } + assert_response :not_found + + get :api_users, :params => { :users => 0 } + assert_response :not_found + end + def test_api_gpx_files user = create(:user) trace1 = create(:trace, :user => user) do |trace| @@ -1120,7 +1205,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 @@ -1166,7 +1251,7 @@ class UserControllerTest < ActionController::TestCase post :make_friend, :params => { :display_name => friend.display_name }, :session => { :user => user } end assert_redirected_to user_path(:display_name => friend.display_name) - assert_match /is now your friend/, flash[:notice] + assert_match(/is now your friend/, flash[:notice]) assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count @@ -1178,7 +1263,7 @@ class UserControllerTest < ActionController::TestCase post :make_friend, :params => { :display_name => friend.display_name }, :session => { :user => user } end assert_redirected_to user_path(:display_name => friend.display_name) - assert_match /You are already friends with/, flash[:warning] + assert_match(/You are already friends with/, flash[:warning]) assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first end @@ -1205,7 +1290,7 @@ class UserControllerTest < ActionController::TestCase post :make_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user } end assert_redirected_to "/test" - assert_match /is now your friend/, flash[:notice] + assert_match(/is now your friend/, flash[:notice]) assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count @@ -1251,13 +1336,13 @@ class UserControllerTest < ActionController::TestCase # When logged in a POST should remove the friendship post :remove_friend, :params => { :display_name => friend.display_name }, :session => { :user => user } assert_redirected_to user_path(:display_name => friend.display_name) - assert_match /was removed from your friends/, flash[:notice] + assert_match(/was removed from your friends/, flash[:notice]) assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first # A second POST should report that the friendship does not exist post :remove_friend, :params => { :display_name => friend.display_name }, :session => { :user => user } assert_redirected_to user_path(:display_name => friend.display_name) - assert_match /is not one of your friends/, flash[:error] + assert_match(/is not one of your friends/, flash[:error]) assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first end @@ -1283,7 +1368,7 @@ class UserControllerTest < ActionController::TestCase # When logged in a POST should remove the friendship and refer post :remove_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user } assert_redirected_to "/test" - assert_match /was removed from your friends/, flash[:notice] + assert_match(/was removed from your friends/, flash[:notice]) assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first end @@ -1305,12 +1390,12 @@ class UserControllerTest < ActionController::TestCase # Now try as a normal user get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user } assert_response :redirect - assert_redirected_to :action => :view, :display_name => user.display_name + assert_redirected_to :action => :show, :display_name => user.display_name # Finally try as an administrator get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) } assert_response :redirect - assert_redirected_to :action => :view, :display_name => user.display_name + assert_redirected_to :action => :show, :display_name => user.display_name assert_equal "suspended", User.find(user.id).status end @@ -1325,12 +1410,12 @@ class UserControllerTest < ActionController::TestCase # Now try as a normal user get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user } assert_response :redirect - assert_redirected_to :action => :view, :display_name => user.display_name + assert_redirected_to :action => :show, :display_name => user.display_name # Finally try as an administrator get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) } assert_response :redirect - assert_redirected_to :action => :view, :display_name => user.display_name + assert_redirected_to :action => :show, :display_name => user.display_name # Check that the user was deleted properly user.reload