2016-07-27 10:55:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Merge Request versions', js: true, feature: true do
|
2016-10-01 03:32:21 -04:00
|
|
|
let(:merge_request) { create(:merge_request, importing: true) }
|
|
|
|
let(:project) { merge_request.source_project }
|
2016-11-18 08:33:42 -05:00
|
|
|
let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
|
|
|
|
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
|
|
|
|
let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
|
2016-10-01 03:32:21 -04:00
|
|
|
|
2016-07-27 10:55:12 -04:00
|
|
|
before do
|
|
|
|
login_as :admin
|
|
|
|
visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'show the latest version of the diff' do
|
2016-09-01 08:23:39 -04:00
|
|
|
page.within '.mr-version-dropdown' do
|
2016-09-06 13:08:06 -04:00
|
|
|
expect(page).to have_content 'latest version'
|
2016-07-27 10:55:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content '8 changed files'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'switch between versions' do
|
|
|
|
before do
|
2016-09-01 08:23:39 -04:00
|
|
|
page.within '.mr-version-dropdown' do
|
2016-09-14 07:55:07 -04:00
|
|
|
find('.btn-default').click
|
2016-12-29 11:02:08 -05:00
|
|
|
find(:link, 'version 1').trigger('click')
|
2016-07-27 10:55:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should show older version' do
|
2016-09-01 08:23:39 -04:00
|
|
|
page.within '.mr-version-dropdown' do
|
2016-09-06 13:08:06 -04:00
|
|
|
expect(page).to have_content 'version 1'
|
2016-09-01 08:23:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content '5 changed files'
|
|
|
|
end
|
2016-09-01 08:35:39 -04:00
|
|
|
|
|
|
|
it 'show the message about disabled comments' do
|
|
|
|
expect(page).to have_content 'Comments are disabled'
|
|
|
|
end
|
2016-09-01 08:23:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'compare with older version' do
|
|
|
|
before do
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
2016-09-14 07:55:07 -04:00
|
|
|
find('.btn-default').click
|
2016-12-29 11:02:08 -05:00
|
|
|
find(:link, 'version 1').trigger('click')
|
2016-09-01 08:23:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-01 03:32:21 -04:00
|
|
|
it 'has a path with comparison context' do
|
|
|
|
expect(page).to have_current_path diffs_namespace_project_merge_request_path(
|
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
merge_request.iid,
|
2016-11-18 08:33:42 -05:00
|
|
|
diff_id: merge_request_diff3.id,
|
2016-10-01 03:32:21 -04:00
|
|
|
start_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2016-09-14 07:55:07 -04:00
|
|
|
it 'should have correct value in the compare dropdown' do
|
2016-09-01 08:23:39 -04:00
|
|
|
page.within '.mr-version-compare-dropdown' do
|
2016-09-06 13:08:06 -04:00
|
|
|
expect(page).to have_content 'version 1'
|
2016-07-27 10:55:12 -04:00
|
|
|
end
|
2016-09-01 08:35:39 -04:00
|
|
|
end
|
2016-07-27 10:55:12 -04:00
|
|
|
|
2016-09-01 08:35:39 -04:00
|
|
|
it 'show the message about disabled comments' do
|
|
|
|
expect(page).to have_content 'Comments are disabled'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'show diff between new and old version' do
|
|
|
|
expect(page).to have_content '4 changed files with 15 additions and 6 deletions'
|
|
|
|
end
|
|
|
|
|
2016-09-14 07:55:07 -04:00
|
|
|
it 'should return to latest version when "Show latest version" button is clicked' do
|
|
|
|
click_link 'Show latest version'
|
|
|
|
page.within '.mr-version-dropdown' do
|
|
|
|
expect(page).to have_content 'latest version'
|
|
|
|
end
|
|
|
|
expect(page).to have_content '8 changed files'
|
|
|
|
end
|
2016-07-27 10:55:12 -04:00
|
|
|
end
|
2016-12-27 12:03:44 -05:00
|
|
|
|
|
|
|
describe 'compare with same version' do
|
|
|
|
before do
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
|
|
|
find('.btn-default').click
|
|
|
|
click_link 'version 1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have 0 chages between versions' do
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
|
|
|
expect(page).to have_content 'version 1'
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.mr-version-dropdown' do
|
|
|
|
find('.btn-default').click
|
|
|
|
find(:link, 'version 1').trigger('click')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content '0 changed files'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'compare with newer version' do
|
|
|
|
before do
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
|
|
|
find('.btn-default').click
|
|
|
|
click_link 'version 2'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should set the compared versions to be the same' do
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
|
|
|
expect(page).to have_content 'version 2'
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.mr-version-dropdown' do
|
|
|
|
find('.btn-default').click
|
|
|
|
find(:link, 'version 1').trigger('click')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.mr-version-compare-dropdown' do
|
|
|
|
expect(page).to have_content 'version 1'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content '0 changed files'
|
|
|
|
end
|
|
|
|
end
|
2016-07-27 10:55:12 -04:00
|
|
|
end
|