Commit 974c3c13 authored by Shinya Maeda's avatar Shinya Maeda

Normalize wording

parent 2e43e50e
...@@ -23,7 +23,7 @@ describe PipelinesFinder do ...@@ -23,7 +23,7 @@ describe PipelinesFinder do
context 'when nothing is passed' do context 'when nothing is passed' do
let(:params) { {} } let(:params) { {} }
it 'selects all pipelines' do it 'returns all pipelines' do
expect(subject).to match_array(Ci::Pipeline.all) expect(subject).to match_array(Ci::Pipeline.all)
end end
...@@ -33,92 +33,92 @@ describe PipelinesFinder do ...@@ -33,92 +33,92 @@ describe PipelinesFinder do
end end
context 'when scope is passed' do context 'when scope is passed' do
context 'when selecting running' do context 'when scope is running' do
let(:params) { { scope: 'running' } } let(:params) { { scope: 'running' } }
it 'has only running status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.running) expect(subject).to match_array(Ci::Pipeline.running)
end end
end end
context 'when selecting pending' do context 'when scope is pending' do
let(:params) { { scope: 'pending' } } let(:params) { { scope: 'pending' } }
it 'has only pending status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.pending) expect(subject).to match_array(Ci::Pipeline.pending)
end end
end end
context 'when selecting finished' do context 'when scope is finished' do
let(:params) { { scope: 'finished' } } let(:params) { { scope: 'finished' } }
it 'has only finished status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.finished) expect(subject).to match_array(Ci::Pipeline.finished)
end end
end end
context 'when selecting branches' do context 'when scope is branches' do
let(:params) { { scope: 'branches' } } let(:params) { { scope: 'branches' } }
it 'excludes tags' do it 'returns matched pipelines' do
expect(subject).to eq([Ci::Pipeline.where(tag: false).last]) expect(subject).to eq([Ci::Pipeline.where(tag: false).last])
end end
end end
context 'when selecting tags' do context 'when scope is tags' do
let(:params) { { scope: 'tags' } } let(:params) { { scope: 'tags' } }
it 'excludes branches' do it 'returns matched pipelines' do
expect(subject).to eq([Ci::Pipeline.where(tag: true).last]) expect(subject).to eq([Ci::Pipeline.where(tag: true).last])
end end
end end
end end
context 'when status is passed' do context 'when status is passed' do
context 'when selecting running' do context 'when status is running' do
let(:params) { { status: 'running' } } let(:params) { { status: 'running' } }
it 'has only running status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.running) expect(subject).to match_array(Ci::Pipeline.running)
end end
end end
context 'when selecting pending' do context 'when status is pending' do
let(:params) { { status: 'pending' } } let(:params) { { status: 'pending' } }
it 'has only pending status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.pending) expect(subject).to match_array(Ci::Pipeline.pending)
end end
end end
context 'when selecting success' do context 'when status is success' do
let(:params) { { status: 'success' } } let(:params) { { status: 'success' } }
it 'has only success status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.success) expect(subject).to match_array(Ci::Pipeline.success)
end end
end end
context 'when selecting failed' do context 'when status is failed' do
let(:params) { { status: 'failed' } } let(:params) { { status: 'failed' } }
it 'has only failed status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.failed) expect(subject).to match_array(Ci::Pipeline.failed)
end end
end end
context 'when selecting canceled' do context 'when status is canceled' do
let(:params) { { status: 'canceled' } } let(:params) { { status: 'canceled' } }
it 'has only canceled status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.canceled) expect(subject).to match_array(Ci::Pipeline.canceled)
end end
end end
context 'when selecting skipped' do context 'when status is skipped' do
let(:params) { { status: 'skipped' } } let(:params) { { status: 'skipped' } }
it 'has only skipped status' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.skipped) expect(subject).to match_array(Ci::Pipeline.skipped)
end end
end end
...@@ -128,7 +128,7 @@ describe PipelinesFinder do ...@@ -128,7 +128,7 @@ describe PipelinesFinder do
context 'when ref exists' do context 'when ref exists' do
let(:params) { { ref: 'master' } } let(:params) { { ref: 'master' } }
it 'selects all pipelines which belong to the ref' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.where(ref: 'master')) expect(subject).to match_array(Ci::Pipeline.where(ref: 'master'))
end end
end end
...@@ -136,7 +136,7 @@ describe PipelinesFinder do ...@@ -136,7 +136,7 @@ describe PipelinesFinder do
context 'when ref does not exist' do context 'when ref does not exist' do
let(:params) { { ref: 'invalid-ref' } } let(:params) { { ref: 'invalid-ref' } }
it 'selects nothing' do it 'returns empty' do
expect(subject).to be_empty expect(subject).to be_empty
end end
end end
...@@ -146,7 +146,7 @@ describe PipelinesFinder do ...@@ -146,7 +146,7 @@ describe PipelinesFinder do
context 'when name exists' do context 'when name exists' do
let(:params) { { name: user1.name } } let(:params) { { name: user1.name } }
it 'selects all pipelines which belong to the name' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.where(user: user1)) expect(subject).to match_array(Ci::Pipeline.where(user: user1))
end end
end end
...@@ -154,7 +154,7 @@ describe PipelinesFinder do ...@@ -154,7 +154,7 @@ describe PipelinesFinder do
context 'when name does not exist' do context 'when name does not exist' do
let(:params) { { name: 'invalid-name' } } let(:params) { { name: 'invalid-name' } }
it 'selects nothing' do it 'returns empty' do
expect(subject).to be_empty expect(subject).to be_empty
end end
end end
...@@ -164,7 +164,7 @@ describe PipelinesFinder do ...@@ -164,7 +164,7 @@ describe PipelinesFinder do
context 'when username exists' do context 'when username exists' do
let(:params) { { username: user1.username } } let(:params) { { username: user1.username } }
it 'selects all pipelines which belong to the username' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.where(user: user1)) expect(subject).to match_array(Ci::Pipeline.where(user: user1))
end end
end end
...@@ -172,7 +172,7 @@ describe PipelinesFinder do ...@@ -172,7 +172,7 @@ describe PipelinesFinder do
context 'when username does not exist' do context 'when username does not exist' do
let(:params) { { username: 'invalid-username' } } let(:params) { { username: 'invalid-username' } }
it 'selects nothing' do it 'returns empty' do
expect(subject).to be_empty expect(subject).to be_empty
end end
end end
...@@ -182,7 +182,7 @@ describe PipelinesFinder do ...@@ -182,7 +182,7 @@ describe PipelinesFinder do
context 'when yaml_errors is true' do context 'when yaml_errors is true' do
let(:params) { { yaml_errors: true } } let(:params) { { yaml_errors: true } }
it 'selects only pipelines have yaml_errors' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.where("yaml_errors IS NOT NULL")) expect(subject).to match_array(Ci::Pipeline.where("yaml_errors IS NOT NULL"))
end end
end end
...@@ -190,49 +190,41 @@ describe PipelinesFinder do ...@@ -190,49 +190,41 @@ describe PipelinesFinder do
context 'when yaml_errors is false' do context 'when yaml_errors is false' do
let(:params) { { yaml_errors: false } } let(:params) { { yaml_errors: false } }
it 'selects only pipelines do not have yaml_errors' do it 'returns matched pipelines' do
expect(subject).to match_array(Ci::Pipeline.where("yaml_errors IS NULL")) expect(subject).to match_array(Ci::Pipeline.where("yaml_errors IS NULL"))
end end
end end
context 'when an argument is invalid' do context 'when yaml_errors is invalid' do
let(:params) { { yaml_errors: "UnexpectedValue" } } let(:params) { { yaml_errors: "UnexpectedValue" } }
it 'selects all pipelines' do it 'returns all pipelines' do
expect(subject).to match_array(Ci::Pipeline.all) expect(subject).to match_array(Ci::Pipeline.all)
end end
end end
end end
context 'when order_by and sort are passed' do context 'when order_by and sort are passed' do
context 'when order by created_at asc' do context 'when order_by and sort are valid' do
let(:params) { { order_by: 'created_at', sort: 'asc' } } let(:params) { { order_by: 'created_at', sort: 'asc' } }
it 'sorts by created_at asc' do it 'sorts pipelines' do
expect(subject).to eq(Ci::Pipeline.order(created_at: :asc)) expect(subject).to eq(Ci::Pipeline.order(created_at: :asc))
end end
end end
context 'when order by created_at desc' do context 'when order_by is invalid' do
let(:params) { { order_by: 'created_at', sort: 'desc' } }
it 'sorts by created_at desc' do
expect(subject).to eq(Ci::Pipeline.order(created_at: :desc))
end
end
context 'when order_by does not exist' do
let(:params) { { order_by: 'invalid_column', sort: 'desc' } } let(:params) { { order_by: 'invalid_column', sort: 'desc' } }
it 'sorts by default' do it 'sorts pipelines, but order_by is default' do
expect(subject).to eq(Ci::Pipeline.order(id: :desc)) expect(subject).to eq(Ci::Pipeline.order(id: :desc))
end end
end end
context 'when sort does not exist' do context 'when sort is invalid' do
let(:params) { { order_by: 'created_at', sort: 'invalid_sort' } } let(:params) { { order_by: 'created_at', sort: 'invalid_sort' } }
it 'sorts by default' do it 'sorts pipelines, but sort is default' do
expect(subject).to eq(Ci::Pipeline.order(created_at: :desc)) expect(subject).to eq(Ci::Pipeline.order(created_at: :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