Commit 7fb3a78a authored by Shinya Maeda's avatar Shinya Maeda

Fix improper method name and spec description

parent c79c3895
...@@ -15,7 +15,7 @@ class PipelinesFinder ...@@ -15,7 +15,7 @@ class PipelinesFinder
items = by_name(items) items = by_name(items)
items = by_username(items) items = by_username(items)
items = by_yaml_errors(items) items = by_yaml_errors(items)
order_and_sort(items) sort_items(items)
end end
private private
...@@ -107,7 +107,7 @@ class PipelinesFinder ...@@ -107,7 +107,7 @@ class PipelinesFinder
end end
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 order_by = if %w[id status ref user_id].include?(params[:order_by]) # Allow only indexed columns
params[:order_by] params[:order_by]
else else
......
...@@ -208,7 +208,7 @@ describe PipelinesFinder do ...@@ -208,7 +208,7 @@ describe PipelinesFinder do
context 'when order_by and sort are valid' do context 'when order_by and sort are valid' do
let(:params) { { order_by: 'user_id', sort: 'asc' } } 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)) expect(subject).to eq(Ci::Pipeline.order(user_id: :asc))
end end
end end
...@@ -216,7 +216,7 @@ describe PipelinesFinder do ...@@ -216,7 +216,7 @@ describe PipelinesFinder do
context 'when order_by is invalid' do context 'when order_by is invalid' do
let(:params) { { order_by: 'invalid_column', sort: 'asc' } } 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)) expect(subject).to eq(Ci::Pipeline.order(id: :asc))
end end
end end
...@@ -224,7 +224,7 @@ describe PipelinesFinder do ...@@ -224,7 +224,7 @@ describe PipelinesFinder do
context 'when sort is invalid' do context 'when sort is invalid' do
let(:params) { { order_by: 'user_id', sort: 'invalid_sort' } } 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)) expect(subject).to eq(Ci::Pipeline.order(user_id: :desc))
end end
end end
......
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