From: Tom Hughes Date: Thu, 22 Mar 2012 19:23:43 +0000 (+0000) Subject: Test that viewing a block marks it as seen X-Git-Tag: live~5672 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2b037e2892e78192a2525b7ddaa2abb7340e65f1?hp=b63a7cb447b149a499141d0b9e40a7dbf4e838aa Test that viewing a block marks it as seen --- diff --git a/test/fixtures/user_blocks.yml b/test/fixtures/user_blocks.yml index c29252916..4f631b356 100644 --- a/test/fixtures/user_blocks.yml +++ b/test/fixtures/user_blocks.yml @@ -5,7 +5,7 @@ active_block: reason: "Active block" reason_format: "markdown" ends_at: "2012-05-01 11:22:33" - needs_view: false + needs_view: true revoker_id: expired_block: diff --git a/test/functional/user_blocks_controller_test.rb b/test/functional/user_blocks_controller_test.rb index 4029fca26..e3b786795 100644 --- a/test/functional/user_blocks_controller_test.rb +++ b/test/functional/user_blocks_controller_test.rb @@ -87,10 +87,6 @@ class UserBlocksControllerTest < ActionController::TestCase assert_template "not_found" assert_select "p", "Sorry, the user block with ID 99999 could not be found." - # Viewing an active block should work - get :show, :id => user_blocks(:active_block) - assert_response :success - # Viewing an expired block should work get :show, :id => user_blocks(:expired_block) assert_response :success @@ -98,6 +94,20 @@ class UserBlocksControllerTest < ActionController::TestCase # Viewing a revoked block should work get :show, :id => user_blocks(:revoked_block) assert_response :success + + # Viewing an active block should work, but shouldn't mark it as seen + get :show, :id => user_blocks(:active_block) + assert_response :success + assert_equal true, UserBlock.find(user_blocks(:active_block).id).needs_view + + # Login as the blocked user + session[:user] = users(:blocked_user).id + cookies["_osm_username"] = users(:blocked_user).display_name + + # Now viewing it should mark it as seen + get :show, :id => user_blocks(:active_block) + assert_response :success + assert_equal false, UserBlock.find(user_blocks(:active_block).id).needs_view end ##