]> git.openstreetmap.org Git - rails.git/commitdiff
Don't assume we know what ID the new block will have
authorTom Hughes <tom@compton.nu>
Wed, 28 May 2014 08:55:34 +0000 (09:55 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 4 Jul 2014 18:24:25 +0000 (19:24 +0100)
test/controllers/user_blocks_controller_test.rb

index ffb5744ea25a510ef1f36fae293e826829b960b1..717f1167a20a2a501a083658a89de73c97abd9ea 100644 (file)
@@ -223,9 +223,10 @@ class UserBlocksControllerTest < ActionController::TestCase
         :user_block_period => "12",
         :user_block => { :needs_view => false, :reason => "Vandalism" }
     end
-    assert_redirected_to user_block_path(:id => 4)
+    id = UserBlock.order(:id).ids.last
+    assert_redirected_to user_block_path(:id => id)
     assert_equal "Created a block on user #{users(:unblocked_user).display_name}.", flash[:notice]
-    b = UserBlock.find(4)
+    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.hour, b.ends_at, 1