Commit f81bc313 authored by Stan Hu's avatar Stan Hu

Merge branch 'id-fix-squash-messages' into 'master'

Fix suggested squashed messages for MR

See merge request gitlab-org/gitlab!43508
parents aa705838 3e8fec12
...@@ -15,7 +15,7 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity ...@@ -15,7 +15,7 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
expose :target_project_id expose :target_project_id
expose :squash expose :squash
expose :rebase_in_progress?, as: :rebase_in_progress expose :rebase_in_progress?, as: :rebase_in_progress
expose :default_squash_commit_message, if: -> (merge_request, _) { merge_request.mergeable? } expose :default_squash_commit_message
expose :commits_count expose :commits_count
expose :merge_ongoing?, as: :merge_ongoing expose :merge_ongoing?, as: :merge_ongoing
expose :work_in_progress?, as: :work_in_progress expose :work_in_progress?, as: :work_in_progress
...@@ -25,10 +25,10 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity ...@@ -25,10 +25,10 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
expose :source_branch_exists?, as: :source_branch_exists expose :source_branch_exists?, as: :source_branch_exists
expose :branch_missing?, as: :branch_missing expose :branch_missing?, as: :branch_missing
expose :commits_without_merge_commits, using: MergeRequestWidgetCommitEntity, expose :commits_without_merge_commits, using: MergeRequestWidgetCommitEntity do |merge_request|
if: -> (merge_request, _) { merge_request.mergeable? } do |merge_request|
merge_request.recent_commits.without_merge_commits merge_request.recent_commits.without_merge_commits
end end
expose :diff_head_sha do |merge_request| expose :diff_head_sha do |merge_request|
merge_request.diff_head_sha.presence merge_request.diff_head_sha.presence
end end
......
---
title: Fix suggested squashed messages for MR
merge_request: 43508
author:
type: fixed
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe MergeRequestPollCachedWidgetEntity do RSpec.describe MergeRequestPollCachedWidgetEntity do
include ProjectForksHelper
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let(:project) { create :project, :repository } let_it_be(:project, refind: true) { create :project, :repository }
let(:resource) { create(:merge_request, source_project: project, target_project: project) } let_it_be(:resource, refind: true) { create(:merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:request) { double('request', current_user: user, project: project) } let(:request) { double('request', current_user: user, project: project) }
...@@ -174,8 +173,6 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do ...@@ -174,8 +173,6 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
end end
context 'when auto merge is not enabled' do context 'when auto merge is not enabled' do
let(:resource) { create(:merge_request) }
it 'returns auto merge related information' do it 'returns auto merge related information' do
expect(subject[:auto_merge_enabled]).to be_falsy expect(subject[:auto_merge_enabled]).to be_falsy
end end
...@@ -215,16 +212,5 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do ...@@ -215,16 +212,5 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
expect(subject[:commits_without_merge_commits].size).to eq(12) expect(subject[:commits_without_merge_commits].size).to eq(12)
end end
end end
context 'when merge request is not mergeable' do
before do
allow(resource).to receive(:mergeable?).and_return(false)
end
it 'does not have default_squash_commit_message and commits_without_merge_commits' do
expect(subject[:default_squash_commit_message]).to eq(nil)
expect(subject[:commits_without_merge_commits]).to eq(nil)
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment