Just pass the object, rather than the id, to _path methods where possible

This commit is contained in:
Andy Allan 2018-09-10 11:09:19 +08:00
parent 4dd4831c0a
commit 100babbe6c
2 changed files with 6 additions and 6 deletions

View file

@ -14,7 +14,7 @@
<%= content_tag "li", :id => "changeset_#{changeset.id}", :data => {:changeset => changeset_data} do %> <%= content_tag "li", :id => "changeset_#{changeset.id}", :data => {:changeset => changeset_data} do %>
<h4> <h4>
<a class="changeset_id" href="<%= changeset_path(changeset.id) %>"> <a class="changeset_id" href="<%= changeset_path(changeset) %>">
<%= changeset.tags['comment'].to_s.presence || t('browse.no_comment') %> <%= changeset.tags['comment'].to_s.presence || t('browse.no_comment') %>
</a> </a>
</h4> </h4>

View file

@ -182,7 +182,7 @@ class UserBlocksControllerTest < ActionController::TestCase
# Check that the block edit page requires us to login # Check that the block edit page requires us to login
get :edit, :params => { :id => active_block.id } get :edit, :params => { :id => active_block.id }
assert_redirected_to login_path(:referer => edit_user_block_path(:id => active_block.id)) assert_redirected_to login_path(:referer => edit_user_block_path(active_block))
# Login as a normal user # Login as a normal user
session[:user] = create(:user).id session[:user] = create(:user).id
@ -306,7 +306,7 @@ class UserBlocksControllerTest < ActionController::TestCase
:user_block_period => "12", :user_block_period => "12",
:user_block => { :needs_view => true, :reason => "Vandalism" } } :user_block => { :needs_view => true, :reason => "Vandalism" } }
end end
assert_redirected_to edit_user_block_path(:id => active_block.id) assert_redirected_to edit_user_block_path(active_block)
assert_equal "Only the moderator who created this block can edit it.", flash[:error] assert_equal "Only the moderator who created this block can edit it.", flash[:error]
# Login as the correct moderator # Login as the correct moderator
@ -318,7 +318,7 @@ class UserBlocksControllerTest < ActionController::TestCase
:params => { :id => active_block.id, :params => { :id => active_block.id,
:user_block_period => "99" } :user_block_period => "99" }
end end
assert_redirected_to edit_user_block_path(:id => active_block.id) assert_redirected_to edit_user_block_path(active_block)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error] assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that updating a block works # Check that updating a block works
@ -328,7 +328,7 @@ class UserBlocksControllerTest < ActionController::TestCase
:user_block_period => "12", :user_block_period => "12",
:user_block => { :needs_view => true, :reason => "Vandalism" } } :user_block => { :needs_view => true, :reason => "Vandalism" } }
end end
assert_redirected_to user_block_path(:id => active_block.id) assert_redirected_to user_block_path(active_block)
assert_equal "Block updated.", flash[:notice] assert_equal "Block updated.", flash[:notice]
b = UserBlock.find(active_block.id) b = UserBlock.find(active_block.id)
assert_in_delta Time.now, b.updated_at, 1 assert_in_delta Time.now, b.updated_at, 1
@ -378,7 +378,7 @@ class UserBlocksControllerTest < ActionController::TestCase
# Check that revoking a block works # Check that revoking a block works
post :revoke, :params => { :id => active_block.id, :confirm => true } post :revoke, :params => { :id => active_block.id, :confirm => true }
assert_redirected_to user_block_path(:id => active_block.id) assert_redirected_to user_block_path(active_block)
b = UserBlock.find(active_block.id) b = UserBlock.find(active_block.id)
assert_in_delta Time.now, b.ends_at, 1 assert_in_delta Time.now, b.ends_at, 1