From 21f3e9ce2617b8869583bdae60cc619bcd0a29bd Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 8 May 2017 14:26:08 +0200 Subject: Move custom compound status method to commit status --- spec/models/commit_status_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/models/commit_status_spec.rb') diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 9262ce08987..2ee9620228c 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -284,6 +284,30 @@ describe CommitStatus, :models do end end + describe '.status' do + context 'when there are multiple statuses present' do + before do + create_status(status: 'running') + create_status(status: 'success') + create_status(allow_failure: true, status: 'failed') + end + + it 'returns a correct compound status' do + expect(described_class.all.status).to eq 'running' + end + end + + context 'when there are only allowed to fail commit statuses present' do + before do + create_status(allow_failure: true, status: 'failed') + end + + it 'returns status that indicates success' do + expect(described_class.all.status).to eq 'success' + end + end + end + describe '#before_sha' do subject { commit_status.before_sha } -- cgit v1.2.1 From e538963d80872e3844ba345967cfa0bf3821c82a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 8 May 2017 14:32:14 +0200 Subject: Add test for using overridden status method with scopes --- spec/models/commit_status_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/models/commit_status_spec.rb') diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 2ee9620228c..dc348f6cd33 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -306,6 +306,17 @@ describe CommitStatus, :models do expect(described_class.all.status).to eq 'success' end end + + context 'when using a scope to select latest statuses' do + before do + create_status(name: 'test', status: 'failed') + create_status(allow_failure: true, name: 'test', status: 'failed') + end + + it 'returns status according to the scope' do + expect(described_class.latest.status).to eq 'success' + end + end end describe '#before_sha' do -- cgit v1.2.1 From caf6b9918e3f7a79c9ffcffd1880f29422d50eb5 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 15 Jun 2017 14:43:47 +0200 Subject: Check warnings when building compound status SQL query --- spec/models/commit_status_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/models/commit_status_spec.rb') diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index dc348f6cd33..1e074c7ad26 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -309,7 +309,7 @@ describe CommitStatus, :models do context 'when using a scope to select latest statuses' do before do - create_status(name: 'test', status: 'failed') + create_status(name: 'test', retried: true, status: 'failed') create_status(allow_failure: true, name: 'test', status: 'failed') end -- cgit v1.2.1