diff options
author | Mark Chao <mchao@gitlab.com> | 2018-12-07 12:58:39 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-12-07 16:00:47 +0300 |
commit | 2f7563a6746519516c1464ac2a74b7e3c0eca63f (patch) | |
tree | ed057c8bdc47af8aec18a1addc0624df3c3e26c5 /spec/services/merge_requests/refresh_service_spec.rb | |
parent | c6c53d1c7418b2c83410a21bce068a6dfd7858b0 (diff) |
Guard with feature flag
Diffstat (limited to 'spec/services/merge_requests/refresh_service_spec.rb')
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 493d3eb7392..1d9c75dedce 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -654,20 +654,44 @@ describe MergeRequests::RefreshService do subject { service.execute(oldrev, newrev, 'refs/heads/merge-commit-analyze-before') } - it "updates merge requests' merge_commits" do - expect(Gitlab::BranchPushMergeCommitAnalyzer).to receive(:new).and_wrap_original do |original_method, commits| - expect(commits.map(&:id)).to eq(%w{646ece5cfed840eca0a4feb21bcd6a81bb19bda3 29284d9bcc350bcae005872d0be6edd016e2efb5 5f82584f0a907f3b30cfce5bb8df371454a90051 8a994512e8c8f0dfcf22bb16df6e876be7a61036 689600b91aabec706e657e38ea706ece1ee8268f db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9}) + context 'feature enabled' do + before do + stub_feature_flags(branch_push_merge_commit_analyze: true) + end + + it "updates merge requests' merge_commits" do + expect(Gitlab::BranchPushMergeCommitAnalyzer).to receive(:new).and_wrap_original do |original_method, commits| + expect(commits.map(&:id)).to eq(%w{646ece5cfed840eca0a4feb21bcd6a81bb19bda3 29284d9bcc350bcae005872d0be6edd016e2efb5 5f82584f0a907f3b30cfce5bb8df371454a90051 8a994512e8c8f0dfcf22bb16df6e876be7a61036 689600b91aabec706e657e38ea706ece1ee8268f db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9}) + + original_method.call(commits) + end + + subject + + merge_request.reload + merge_request_side_branch.reload - original_method.call(commits) + expect(merge_request.merge_commit.id).to eq('646ece5cfed840eca0a4feb21bcd6a81bb19bda3') + expect(merge_request_side_branch.merge_commit.id).to eq('29284d9bcc350bcae005872d0be6edd016e2efb5') end + end + + context 'when feature is disabled' do + before do + stub_feature_flags(branch_push_merge_commit_analyze: false) + end + + it "does not trigger analysis" do + expect(Gitlab::BranchPushMergeCommitAnalyzer).not_to receive(:new) - subject + subject - merge_request.reload - merge_request_side_branch.reload + merge_request.reload + merge_request_side_branch.reload - expect(merge_request.merge_commit.id).to eq('646ece5cfed840eca0a4feb21bcd6a81bb19bda3') - expect(merge_request_side_branch.merge_commit.id).to eq('29284d9bcc350bcae005872d0be6edd016e2efb5') + expect(merge_request.merge_commit).to eq(nil) + expect(merge_request_side_branch.merge_commit).to eq(nil) + end end end end |