summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-01-16 08:15:04 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-01-16 08:15:04 +0000
commit0de7ae34cdb06f72d5f674c056f28cd32c03bda3 (patch)
tree6fa53101590354b3703233d7b1ea8fe152b7896a /spec
parent9e70ff345fa68d700b77b5939d34870ee61cb131 (diff)
parent0fd0000b8c1661930ce7f7427ad26a5081fbcd78 (diff)
downloadgitlab-ce-0de7ae34cdb06f72d5f674c056f28cd32c03bda3.tar.gz
Merge branch 'sh-optimize-ci-build-project' into 'master'
Ensure CI pipelines and builds have the correction project associations See merge request gitlab-org/gitlab-ce!16448
Diffstat (limited to 'spec')
-rw-r--r--spec/models/ci/build_spec.rb7
-rw-r--r--spec/models/ci/pipeline_spec.rb7
2 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 3eaeeebf97d..45a606c1ea8 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -25,6 +25,13 @@ describe Ci::Build do
it { is_expected.to be_a(ArtifactMigratable) }
+ describe 'associations' do
+ it 'has a bidirectional relationship with projects' do
+ expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:builds)
+ expect(Project.reflect_on_association(:builds).has_inverse?).to eq(:project)
+ end
+ end
+
describe 'callbacks' do
context 'when running after_create callback' do
it 'triggers asynchronous build hooks worker' do
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 7bef798a782..14d234f6aab 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -28,6 +28,13 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to respond_to :short_sha }
it { is_expected.to delegate_method(:full_path).to(:project).with_prefix }
+ describe 'associations' do
+ it 'has a bidirectional relationship with projects' do
+ expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:pipelines)
+ expect(Project.reflect_on_association(:pipelines).has_inverse?).to eq(:project)
+ end
+ end
+
describe '#source' do
context 'when creating new pipeline' do
let(:pipeline) do