diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 18:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 18:08:59 +0300 |
commit | 23288f62da73fb0e30d8e7ce306665e8fda1b932 (patch) | |
tree | 2baf1339e4d7c7c35d6b8a52cfb90597a5d4cdf1 /spec/models/merge_request_context_commit_spec.rb | |
parent | 7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/merge_request_context_commit_spec.rb')
-rw-r--r-- | spec/models/merge_request_context_commit_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/merge_request_context_commit_spec.rb b/spec/models/merge_request_context_commit_spec.rb new file mode 100644 index 00000000000..5a1bf9874ac --- /dev/null +++ b/spec/models/merge_request_context_commit_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe MergeRequestContextCommit do + let(:merge_request) { create(:merge_request) } + let(:project) { merge_request.project } + let(:raw_repository) { project.repository.raw_repository } + let(:commits) do + [ + project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e'), + project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') + ] + end + + describe 'associations' do + it { is_expected.to belong_to(:merge_request) } + it { is_expected.to have_many(:diff_files).class_name("MergeRequestContextCommitDiffFile") } + end + + describe '.delete_bulk' do + let(:context_commit1) { create(:merge_request_context_commit, merge_request: merge_request, sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') } + let(:context_commit2) { create(:merge_request_context_commit, merge_request: merge_request, sha: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d') } + + it 'deletes context commits for given commit sha\'s and returns the commit' do + expect(described_class.delete_bulk(merge_request, [context_commit1, context_commit2])).to eq(2) + end + + it 'doesn\'t delete context commits when commit sha\'s are not passed' do + expect(described_class.delete_bulk(merge_request, [])).to eq(0) + end + end +end |