diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb index 6a92aedc873..0c91c136a8f 100644 --- a/app/finders/pipelines_finder.rb +++ b/app/finders/pipelines_finder.rb @@ -15,7 +15,7 @@ class PipelinesFinder items = by_name(items) items = by_username(items) items = by_yaml_errors(items) - order_and_sort(items) + sort_items(items) end private @@ -107,7 +107,7 @@ class PipelinesFinder end end - def order_and_sort(items) + def sort_items(items) order_by = if %w[id status ref user_id].include?(params[:order_by]) # Allow only indexed columns params[:order_by] else diff --git a/spec/finders/pipelines_finder_spec.rb b/spec/finders/pipelines_finder_spec.rb index b5cb7d75c5e..ac64df8aeb8 100644 --- a/spec/finders/pipelines_finder_spec.rb +++ b/spec/finders/pipelines_finder_spec.rb @@ -208,7 +208,7 @@ describe PipelinesFinder do context 'when order_by and sort are valid' do let(:params) { { order_by: 'user_id', sort: 'asc' } } - it 'sorts pipelines by default' do + it 'sorts pipelines' do expect(subject).to eq(Ci::Pipeline.order(user_id: :asc)) end end @@ -216,7 +216,7 @@ describe PipelinesFinder do context 'when order_by is invalid' do let(:params) { { order_by: 'invalid_column', sort: 'asc' } } - it 'sorts pipelines with default order_by (id:)' do + it 'sorts pipelines with id: (default)' do expect(subject).to eq(Ci::Pipeline.order(id: :asc)) end end @@ -224,7 +224,7 @@ describe PipelinesFinder do context 'when sort is invalid' do let(:params) { { order_by: 'user_id', sort: 'invalid_sort' } } - it 'sorts pipelines with default sort (:desc)' do + it 'sorts pipelines with :desc (default)' do expect(subject).to eq(Ci::Pipeline.order(user_id: :desc)) end end