diff options
Diffstat (limited to 'spec/services/merge_requests/squash_service_spec.rb')
-rw-r--r-- | spec/services/merge_requests/squash_service_spec.rb | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/spec/services/merge_requests/squash_service_spec.rb b/spec/services/merge_requests/squash_service_spec.rb index a53314ed737..1ec1dc0f6eb 100644 --- a/spec/services/merge_requests/squash_service_spec.rb +++ b/spec/services/merge_requests/squash_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MergeRequests::SquashService do +RSpec.describe MergeRequests::SquashService do include GitHelpers let(:service) { described_class.new(project, user, { merge_request: merge_request }) } @@ -131,6 +131,42 @@ describe MergeRequests::SquashService do include_examples 'the squash succeeds' end + context 'when squashing is disabled by default on the project' do + # Squashing is disabled by default, but it should still allow you + # to squash-and-merge if selected through the UI + let(:merge_request) { merge_request_with_only_new_files } + + before do + merge_request.project.project_setting.squash_default_off! + end + + include_examples 'the squash succeeds' + end + + context 'when squashing is forbidden on the project' do + let(:merge_request) { merge_request_with_only_new_files } + + before do + merge_request.project.project_setting.squash_never! + end + + it 'raises a squash error' do + expect(service.execute).to match( + status: :error, + message: a_string_including('does not allow squashing commits when merge requests are accepted')) + end + end + + context 'when squashing is enabled by default on the project' do + let(:merge_request) { merge_request_with_only_new_files } + + before do + merge_request.project.project_setting.squash_always! + end + + include_examples 'the squash succeeds' + end + context 'when squashing with files too large to display' do let(:merge_request) { merge_request_with_large_files } |