summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-05-03 18:37:34 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-05-03 21:25:57 +0100
commit268ec199da09f3d2c3e93b1f3546f2c3c89c48d0 (patch)
treec92d198186f7606279d17321d99d284c944ce714 /spec
parent3ff8d8020e495df319f0b0921bc94b1c3470f6f0 (diff)
downloadgitlab-ce-268ec199da09f3d2c3e93b1f3546f2c3c89c48d0.tar.gz
removes the possibility of commit messages having carriage returns
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 74d5ebc6db0..d145ed136fe 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1098,21 +1098,33 @@ describe Repository, models: true do
end
describe '#merge' do
- it 'merges the code and return the commit id' do
+ let(:merge_request) { create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project) }
+
+ let(:commit_options) do
+ author = repository.user_to_committer(user)
+ { message: 'Test \r\n\r\n message', committer: author, author: author }
+ end
+
+ it 'merges the code and returns the commit id' do
expect(merge_commit).to be_present
expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
end
it 'sets the `in_progress_merge_commit_sha` flag for the given merge request' do
- merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
-
- merge_commit_id = repository.merge(user,
- merge_request.diff_head_sha,
- merge_request,
- commit_options)
+ merge_commit_id = merge(repository, user, merge_request, commit_options)
expect(merge_request.in_progress_merge_commit_sha).to eq(merge_commit_id)
end
+
+ it 'removes carriage returns from commit message' do
+ merge_commit_id = merge(repository, user, merge_request, commit_options)
+
+ expect(repository.commit(merge_commit_id).message).to eq(commit_options[:message].delete("\r"))
+ end
+
+ def merge(repository, user, merge_request, options = {})
+ repository.merge(user, merge_request.diff_head_sha, merge_request, options)
+ end
end
describe '#revert' do