]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/user_blocks_controller_test.rb
Merge remote-tracking branch 'upstream/pull/3770'
[rails.git] / test / controllers / user_blocks_controller_test.rb
index d5db896151fd08f14f181cb61fbdd4605e11d206..16a77624c75ee8dabc02fb62bb85242e44ee6631 100644 (file)
@@ -240,9 +240,9 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to user_block_path(:id => id)
     assert_equal "Created a block on user #{target_user.display_name}.", flash[:notice]
     b = UserBlock.find(id)
     assert_redirected_to user_block_path(:id => id)
     assert_equal "Created a block on user #{target_user.display_name}.", flash[:notice]
     b = UserBlock.find(id)
-    assert_in_delta Time.now, b.created_at, 1
-    assert_in_delta Time.now, b.updated_at, 1
-    assert_in_delta Time.now + 12.hours, b.ends_at, 1
+    assert_in_delta Time.now.utc, b.created_at, 1
+    assert_in_delta Time.now.utc, b.updated_at, 1
+    assert_in_delta Time.now.utc + 12.hours, b.ends_at, 1
     assert_not b.needs_view
     assert_equal "Vandalism", b.reason
     assert_equal "markdown", b.reason_format
     assert_not b.needs_view
     assert_equal "Vandalism", b.reason
     assert_equal "markdown", b.reason_format
@@ -311,7 +311,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to user_block_path(active_block)
     assert_equal "Block updated.", flash[:notice]
     b = UserBlock.find(active_block.id)
     assert_redirected_to user_block_path(active_block)
     assert_equal "Block updated.", flash[:notice]
     b = UserBlock.find(active_block.id)
-    assert_in_delta Time.now, b.updated_at, 1
+    assert_in_delta Time.now.utc, b.updated_at, 1
     assert b.needs_view
     assert_equal "Vandalism", b.reason
 
     assert b.needs_view
     assert_equal "Vandalism", b.reason
 
@@ -351,11 +351,18 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
       assert_select "input[type='submit'][value='Revoke!']", :count => 1
     end
 
       assert_select "input[type='submit'][value='Revoke!']", :count => 1
     end
 
-    # Check that revoking a block works
+    # Check that revoking a block using GET should fail
+    get revoke_user_block_path(:id => active_block, :confirm => true)
+    assert_response :success
+    assert_template "revoke"
+    b = UserBlock.find(active_block.id)
+    assert b.ends_at - Time.now.utc > 100
+
+    # Check that revoking a block works using POST
     post revoke_user_block_path(:id => active_block, :confirm => true)
     assert_redirected_to user_block_path(active_block)
     b = UserBlock.find(active_block.id)
     post revoke_user_block_path(:id => active_block, :confirm => true)
     assert_redirected_to user_block_path(active_block)
     b = UserBlock.find(active_block.id)
-    assert_in_delta Time.now, b.ends_at, 1
+    assert_in_delta Time.now.utc, b.ends_at, 1
 
     # We should get an error if the block doesn't exist
     get revoke_user_block_path(:id => 99999)
 
     # We should get an error if the block doesn't exist
     get revoke_user_block_path(:id => 99999)