summaryrefslogtreecommitdiff
path: root/spec/models/ci/project_mirror_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/models/ci/project_mirror_spec.rb
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/models/ci/project_mirror_spec.rb')
-rw-r--r--spec/models/ci/project_mirror_spec.rb34
1 files changed, 27 insertions, 7 deletions
diff --git a/spec/models/ci/project_mirror_spec.rb b/spec/models/ci/project_mirror_spec.rb
index 199285b036c..5ef520b4230 100644
--- a/spec/models/ci/project_mirror_spec.rb
+++ b/spec/models/ci/project_mirror_spec.rb
@@ -8,12 +8,36 @@ RSpec.describe Ci::ProjectMirror do
let!(:project) { create(:project, namespace: group2) }
+ context 'scopes' do
+ let_it_be(:another_project) { create(:project, namespace: group1) }
+
+ describe '.by_project_id' do
+ subject(:result) { described_class.by_project_id(project.id) }
+
+ it 'returns project mirrors of project' do
+ expect(result.pluck(:project_id)).to contain_exactly(project.id)
+ end
+ end
+
+ describe '.by_namespace_id' do
+ subject(:result) { described_class.by_namespace_id(group2.id) }
+
+ it 'returns project mirrors of namespace id' do
+ expect(result).to contain_exactly(project.ci_project_mirror)
+ end
+ end
+ end
+
describe '.sync!' do
let!(:event) { Projects::SyncEvent.create!(project: project) }
- subject(:sync) { described_class.sync!(event.reload) }
+ subject(:sync) { described_class.sync!(event) }
+
+ context 'when project mirror does not exist in the first place' do
+ before do
+ project.ci_project_mirror.destroy!
+ end
- context 'when project hierarchy does not exist in the first place' do
it 'creates a ci_projects record' do
expect { sync }.to change { described_class.count }.from(0).to(1)
@@ -21,11 +45,7 @@ RSpec.describe Ci::ProjectMirror do
end
end
- context 'when project hierarchy does already exist' do
- before do
- described_class.create!(project_id: project.id, namespace_id: group1.id)
- end
-
+ context 'when project mirror does already exist' do
it 'updates the related ci_projects record' do
expect { sync }.not_to change { described_class.count }