summaryrefslogtreecommitdiff
path: root/spec/models/ci/stage_spec.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-20 13:05:26 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-20 13:05:26 +0200
commit0605cdd7590b12bad073bf41f3e793274e931a80 (patch)
treee43f62381853abc6a4a7127f8e6e07ecfd155744 /spec/models/ci/stage_spec.rb
parentc7a7ef044cf79dcd5ffd25b9fb325cd0abd612b2 (diff)
downloadgitlab-ce-0605cdd7590b12bad073bf41f3e793274e931a80.tar.gz
Implement proper associations with a persisted stage
Diffstat (limited to 'spec/models/ci/stage_spec.rb')
-rw-r--r--spec/models/ci/stage_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb
index 911c468ff1a..49573175266 100644
--- a/spec/models/ci/stage_spec.rb
+++ b/spec/models/ci/stage_spec.rb
@@ -1,6 +1,27 @@
require 'spec_helper'
describe Ci::Stage, :models do
+ describe 'associations' do
+ let(:stage) { create(:ci_stage_entity) }
+
+ before do
+ create(:ci_build, stage_id: stage.id)
+ create(:commit_status, stage_id: stage.id)
+ end
+
+ describe '#commit_statuses' do
+ it 'returns all commit statuses' do
+ expect(stage.commit_statuses.count).to be 2
+ end
+ end
+
+ describe '#builds' do
+ it 'returns only builds' do
+ expect(stage.builds).to be_one
+ end
+ end
+ end
+
describe '#status' do
context 'when stage is pending' do
let(:stage) { create(:ci_stage_entity, status: 'pending') }