diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index 0d9390541..7b3d8e134 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -18,7 +18,7 @@ class BulkUpdateRequest < ApplicationRecord before_save :update_tags, if: :script_changed? after_create :create_forum_topic - scope :pending_first, -> { order(Arel.sql("(case status when 'failed' then 0 when 'processing' then 1 when 'pending' then 2 when 'approved' then 3 when 'rejected' then 4 else 5 end)")) } + scope :pending_first, -> { order(Arel.sql("(case status when 'processing' then 0 when 'pending' then 1 when 'approved' then 2 when 'rejected' then 3 when 'failed' then 4 else 5 end)")) } scope :pending, -> {where(status: "pending")} scope :approved, -> { where(status: "approved") } scope :rejected, -> { where(status: "rejected") } @@ -27,10 +27,6 @@ class BulkUpdateRequest < ApplicationRecord scope :has_topic, -> { where.not(forum_topic: nil) } module SearchMethods - def default_order - pending_first.order(id: :desc) - end - def search(params = {}) q = search_attributes(params, :id, :created_at, :updated_at, :script, :tags, :user, :forum_topic, :forum_post, :approver) q = q.text_attribute_matches(:script, params[:script_matches]) diff --git a/test/functional/bulk_update_requests_controller_test.rb b/test/functional/bulk_update_requests_controller_test.rb index af94b1c2f..ee867f518 100644 --- a/test/functional/bulk_update_requests_controller_test.rb +++ b/test/functional/bulk_update_requests_controller_test.rb @@ -85,7 +85,7 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest assert_response :success end - should respond_to_search({}).with { [@other_BUR, @bulk_update_request, @approved_BUR, @rejected_BUR] } + should respond_to_search({}).with { [@approved_BUR, @rejected_BUR, @other_BUR, @bulk_update_request] } should respond_to_search(order: "id_desc").with { [@approved_BUR, @rejected_BUR, @other_BUR, @bulk_update_request] } should respond_to_search(status: "pending").with { [@other_BUR, @bulk_update_request] } should respond_to_search(script_matches: "cirno -> 9").with { @other_BUR } @@ -97,7 +97,7 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest should respond_to_search(user_id: 999).with { @bulk_update_request } should respond_to_search(user: {level: User::Levels::BUILDER}).with { @other_BUR } should respond_to_search(has_approver: "true").with { @approved_BUR } - should respond_to_search(has_approver: "false").with { [@other_BUR, @bulk_update_request, @rejected_BUR] } + should respond_to_search(has_approver: "false").with { [@rejected_BUR, @other_BUR, @bulk_update_request] } end end