Test against all types and more status:
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18748231
This commit is contained in:
parent
9b1240783b
commit
d09d6ad01d
|
@ -124,12 +124,9 @@ describe HasStatus do
|
|||
end
|
||||
end
|
||||
|
||||
def self.random_type
|
||||
%i[ci_build generic_commit_status].sample
|
||||
end
|
||||
|
||||
context 'for scope with one status' do
|
||||
shared_examples 'having a job' do |type, status|
|
||||
shared_examples 'having a job' do |status|
|
||||
%i[ci_build generic_commit_status].each do |type|
|
||||
context "when it's #{status} #{type} job" do
|
||||
let!(:job) { create(type, status) }
|
||||
|
||||
|
@ -153,15 +150,17 @@ describe HasStatus do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%i[created running pending success
|
||||
failed canceled skipped].each do |status|
|
||||
it_behaves_like 'having a job', random_type, status
|
||||
it_behaves_like 'having a job', status
|
||||
end
|
||||
end
|
||||
|
||||
context 'for scope with more statuses' do
|
||||
shared_examples 'containing the job' do |type, status|
|
||||
shared_examples 'containing the job' do |status|
|
||||
%i[ci_build generic_commit_status].each do |type|
|
||||
context "when it's #{status} #{type} job" do
|
||||
let!(:job) { create(type, status) }
|
||||
|
||||
|
@ -170,8 +169,10 @@ describe HasStatus do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'not containing the job' do |type, status|
|
||||
shared_examples 'not containing the job' do |status|
|
||||
%i[ci_build generic_commit_status].each do |type|
|
||||
context "when it's #{status} #{type} job" do
|
||||
let!(:job) { create(type, status) }
|
||||
|
||||
|
@ -180,35 +181,42 @@ describe HasStatus do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.running_or_pending' do
|
||||
subject { CommitStatus.running_or_pending }
|
||||
|
||||
%i[running pending].each do |status|
|
||||
it_behaves_like 'containing the job', random_type, status
|
||||
it_behaves_like 'containing the job', status
|
||||
end
|
||||
|
||||
it_behaves_like 'not containing the job', random_type, :created
|
||||
%i[created failed success].each do |status|
|
||||
it_behaves_like 'not containing the job', status
|
||||
end
|
||||
end
|
||||
|
||||
describe '.finished' do
|
||||
subject { CommitStatus.finished }
|
||||
|
||||
%i[success failed canceled].each do |status|
|
||||
it_behaves_like 'containing the job', random_type, status
|
||||
it_behaves_like 'containing the job', status
|
||||
end
|
||||
|
||||
it_behaves_like 'not containing the job', random_type, :created
|
||||
%i[created running pending].each do |status|
|
||||
it_behaves_like 'not containing the job', status
|
||||
end
|
||||
end
|
||||
|
||||
describe '.cancelable' do
|
||||
subject { CommitStatus.cancelable }
|
||||
|
||||
%i[running pending created].each do |status|
|
||||
it_behaves_like 'containing the job', random_type, status
|
||||
it_behaves_like 'containing the job', status
|
||||
end
|
||||
|
||||
it_behaves_like 'not containing the job', random_type, :failed
|
||||
%i[failed success skipped canceled].each do |status|
|
||||
it_behaves_like 'not containing the job', status
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue