diff --git a/lib/danbooru/paginator/active_record_extension.rb b/lib/danbooru/paginator/active_record_extension.rb index 1cd186eac..1864cc215 100644 --- a/lib/danbooru/paginator/active_record_extension.rb +++ b/lib/danbooru/paginator/active_record_extension.rb @@ -34,17 +34,17 @@ module Danbooru c = limit(records_per_page) if before_id.to_i > 0 - c = c.where("id < ?", before_id.to_i) + c = c.where("#{table_name}.id < ?", before_id.to_i) end - c.reorder("id desc").tap do |obj| + c.reorder("#{table_name}.id desc").tap do |obj| obj.extend(SequentialCollectionExtension) obj.sequential_paginator_mode = :before end end def paginate_sequential_after(after_id) - limit(records_per_page).where("id > ?", after_id.to_i).reorder("id asc").tap do |obj| + limit(records_per_page).where("#{table_name}.id > ?", after_id.to_i).reorder("#{table_name}.id asc").tap do |obj| obj.extend(SequentialCollectionExtension) obj.sequential_paginator_mode = :after end diff --git a/test/functional/dmails_controller_test.rb b/test/functional/dmails_controller_test.rb index 5690f2ed8..5644d798d 100644 --- a/test/functional/dmails_controller_test.rb +++ b/test/functional/dmails_controller_test.rb @@ -65,9 +65,8 @@ class DmailsControllerTest < ActionController::TestCase end should "not show dmails not owned by the current user" do - assert_raise(User::PrivilegeError) do - get :show, {:id => @dmail.id}, {:user_id => @unrelated_user.id} - end + get :show, {:id => @dmail.id}, {:user_id => @unrelated_user.id} + assert_redirected_to(new_session_path(:url => "/dmails/#{@dmail.id}")) end end @@ -95,9 +94,7 @@ class DmailsControllerTest < ActionController::TestCase should "not allow deletion if the dmail is not owned by the current user" do assert_difference("Dmail.count", 0) do - assert_raises(User::PrivilegeError) do - post :destroy, {:id => @dmail.id}, {:user_id => @unrelated_user.id} - end + post :destroy, {:id => @dmail.id}, {:user_id => @unrelated_user.id} end end end