diff options
author | Robert Speicher <robert@gitlab.com> | 2018-05-08 01:17:55 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-05-08 01:17:55 +0300 |
commit | b69ade5dd1eca99bff388240a184b6a579196f9d (patch) | |
tree | bc568a5af275a74d29c92235a9695f47aca13378 /spec | |
parent | 4ac42e48344d4971913e8ed4afca27d0bdf07929 (diff) | |
parent | 3063225ca289e87c3f590e1722451a1c674e2ac9 (diff) |
Merge branch '43557-osw-present-merge-sha-commit' into 'master'
Resolve "Display merge commit SHA in merge widget after merge"
Closes #43557
See merge request gitlab-org/gitlab-ce!18722
Diffstat (limited to 'spec')
5 files changed, 51 insertions, 0 deletions
diff --git a/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb b/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb index c35ba2d7016..01aeed93947 100644 --- a/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb +++ b/spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb @@ -10,6 +10,15 @@ describe 'User accepts a merge request', :js do sign_in(user) end + it 'presents merged merge request content' do + visit(merge_request_path(merge_request)) + + click_button('Merge') + + expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with \ + #{merge_request.short_merge_commit_sha}") + end + context 'with removing the source branch' do before do visit(merge_request_path(merge_request)) diff --git a/spec/fixtures/api/schemas/entities/merge_request_widget.json b/spec/fixtures/api/schemas/entities/merge_request_widget.json index a622bf88b13..233102c4314 100644 --- a/spec/fixtures/api/schemas/entities/merge_request_widget.json +++ b/spec/fixtures/api/schemas/entities/merge_request_widget.json @@ -22,6 +22,7 @@ "in_progress_merge_commit_sha": { "type": ["string", "null"] }, "merge_error": { "type": ["string", "null"] }, "merge_commit_sha": { "type": ["string", "null"] }, + "short_merge_commit_sha": { "type": ["string", "null"] }, "merge_params": { "type": ["object", "null"] }, "merge_status": { "type": "string" }, "merge_user_id": { "type": ["integer", "null"] }, @@ -100,6 +101,7 @@ "merge_commit_message_with_description": { "type": "string" }, "diverged_commits_count": { "type": "integer" }, "commit_change_content_path": { "type": "string" }, + "merge_commit_path": { "type": ["string", "null"] }, "remove_wip_path": { "type": ["string", "null"] }, "commits_count": { "type": "integer" }, "remove_source_branch": { "type": ["boolean", "null"] }, diff --git a/spec/javascripts/vue_mr_widget/components/states/mr_widget_merged_spec.js b/spec/javascripts/vue_mr_widget/components/states/mr_widget_merged_spec.js index c2c92d8ac56..adeea03481f 100644 --- a/spec/javascripts/vue_mr_widget/components/states/mr_widget_merged_spec.js +++ b/spec/javascripts/vue_mr_widget/components/states/mr_widget_merged_spec.js @@ -6,6 +6,14 @@ import mountComponent from 'spec/helpers/vue_mount_component_helper'; describe('MRWidgetMerged', () => { let vm; const targetBranch = 'foo'; + const selectors = { + get copyMergeShaButton() { + return vm.$el.querySelector('button.js-mr-merged-copy-sha'); + }, + get mergeCommitShaLink() { + return vm.$el.querySelector('a.js-mr-merged-commit-sha'); + }, + }; beforeEach(() => { const Component = Vue.extend(mergedComponent); @@ -31,6 +39,9 @@ describe('MRWidgetMerged', () => { readableClosedAt: '', }, updatedAt: 'mergedUpdatedAt', + shortMergeCommitSha: 'asdf1234', + mergeCommitPath: 'http://localhost:3000/root/nautilus/commit/f7ce827c314c9340b075657fd61c789fb01cf74d', + sourceBranch: 'bar', targetBranch, }; @@ -140,6 +151,17 @@ describe('MRWidgetMerged', () => { expect(vm.$el.textContent).toContain('Cherry-pick'); }); + it('shows button to copy commit SHA to clipboard', () => { + expect(selectors.copyMergeShaButton).toExist(); + expect(selectors.copyMergeShaButton.getAttribute('data-clipboard-text')).toBe(vm.mr.shortMergeCommitSha); + }); + + it('shows merge commit SHA link', () => { + expect(selectors.mergeCommitShaLink).toExist(); + expect(selectors.mergeCommitShaLink.text).toContain(vm.mr.shortMergeCommitSha); + expect(selectors.mergeCommitShaLink.href).toBe(vm.mr.mergeCommitPath); + }); + it('should not show source branch removed text', (done) => { vm.mr.sourceBranchRemoved = false; diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index 3fc7663b9c2..9d2a15ff009 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -18,6 +18,7 @@ export default { human_total_time_spent: null, in_progress_merge_commit_sha: null, merge_commit_sha: '53027d060246c8f47e4a9310fb332aa52f221775', + short_merge_commit_sha: '53027d06', merge_error: null, merge_params: { force_remove_source_branch: null, @@ -215,4 +216,5 @@ export default { diverged_commits_count: 0, only_allow_merge_if_pipeline_succeeds: false, commit_change_content_path: '/root/acets-app/merge_requests/22/commit_change_content', + merge_commit_path: 'http://localhost:3000/root/acets-app/commit/53027d060246c8f47e4a9310fb332aa52f221775', }; diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 5a9aa7c7d1b..04379e7d2c3 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1069,6 +1069,22 @@ describe MergeRequest do end end + describe '#short_merge_commit_sha' do + let(:merge_request) { build_stubbed(:merge_request) } + + it 'returns short id when there is a merge_commit_sha' do + merge_request.merge_commit_sha = 'f7ce827c314c9340b075657fd61c789fb01cf74d' + + expect(merge_request.short_merge_commit_sha).to eq('f7ce827c') + end + + it 'returns nil when there is no merge_commit_sha' do + merge_request.merge_commit_sha = nil + + expect(merge_request.short_merge_commit_sha).to be_nil + end + end + describe '#can_be_reverted?' do context 'when there is no merge_commit for the MR' do before do |