Commit 07885680 authored by James Fargher's avatar James Fargher

Order storage moves API by default

parent ff1b5ceb
......@@ -52,4 +52,6 @@ class ProjectRepositoryStorageMove < ApplicationRecord
state :finished, value: 4
state :failed, value: 5
end
scope :order_created_at_desc, -> { order(created_at: :desc) }
end
......@@ -15,7 +15,7 @@ module API
use :pagination
end
get do
storage_moves = ProjectRepositoryStorageMove.all
storage_moves = ProjectRepositoryStorageMove.order_created_at_desc
present paginate(storage_moves), with: Entities::ProjectRepositoryStorageMove, current_user: current_user
end
......
......@@ -29,6 +29,20 @@ describe API::ProjectRepositoryStorageMoves do
expect { get_project_repository_storage_moves }.not_to exceed_query_limit(control)
end
it 'returns the most recently created first' do
storage_move_oldest = create(:project_repository_storage_move, :scheduled, created_at: 2.days.ago)
storage_move_middle = create(:project_repository_storage_move, :scheduled, created_at: 1.day.ago)
get api('/project_repository_storage_moves', user)
json_ids = json_response.map {|storage_move| storage_move['id'] }
expect(json_ids).to eq([
storage_move.id,
storage_move_middle.id,
storage_move_oldest.id
])
end
end
describe 'GET /project_repository_storage_moves/:id' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment