2016-07-12 08:29:26 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
feature 'Diffs URL', :js do
|
2017-09-29 04:04:50 -04:00
|
|
|
include ProjectForksHelper
|
|
|
|
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-04-20 10:47:32 -04:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2016-07-12 08:29:26 -04:00
|
|
|
|
|
|
|
context 'when visit with */* as accept header' do
|
|
|
|
it 'renders the notes' do
|
2017-04-22 01:54:03 -04:00
|
|
|
create :note_on_merge_request, project: project, noteable: merge_request, note: 'Rebasing with master'
|
2016-07-12 08:29:26 -04:00
|
|
|
|
2017-11-02 14:54:36 -04:00
|
|
|
inspect_requests(inject_headers: { 'Accept' => '*/*' }) do
|
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
|
|
|
end
|
2016-07-12 08:29:26 -04:00
|
|
|
|
|
|
|
# Load notes and diff through AJAX
|
|
|
|
expect(page).to have_css('.note-text', visible: false, text: 'Rebasing with master')
|
|
|
|
expect(page).to have_css('.diffs.tab-pane.active')
|
|
|
|
end
|
|
|
|
end
|
2016-12-30 14:16:25 -05:00
|
|
|
|
2017-05-17 15:58:47 -04:00
|
|
|
context 'when linking to note' do
|
|
|
|
describe 'with unresolved note' do
|
|
|
|
let(:note) { create :diff_note_on_merge_request, project: project, noteable: merge_request }
|
|
|
|
let(:fragment) { "#note_#{note.id}" }
|
|
|
|
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
|
2017-05-17 15:58:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows expanded note' do
|
|
|
|
expect(page).to have_selector(fragment, visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with resolved note' do
|
|
|
|
let(:note) { create :diff_note_on_merge_request, :resolved, project: project, noteable: merge_request }
|
|
|
|
let(:fragment) { "#note_#{note.id}" }
|
|
|
|
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
|
2017-05-17 15:58:47 -04:00
|
|
|
end
|
|
|
|
|
2017-10-10 11:36:32 -04:00
|
|
|
it 'shows expanded note' do
|
|
|
|
expect(page).to have_selector(fragment, visible: true)
|
2017-05-17 15:58:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-30 14:16:25 -05:00
|
|
|
context 'when merge request has overflow' do
|
|
|
|
it 'displays warning' do
|
2017-04-20 10:47:32 -04:00
|
|
|
allow(Commit).to receive(:max_diff_options).and_return(max_files: 3)
|
2016-12-30 14:16:25 -05:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2016-12-30 14:16:25 -05:00
|
|
|
|
|
|
|
page.within('.alert') do
|
|
|
|
expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve
|
2017-04-20 10:47:32 -04:00
|
|
|
performance only 3 of 3+ files are displayed.")
|
2017-04-22 01:54:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-20 10:47:32 -04:00
|
|
|
context 'when editing file' do
|
|
|
|
let(:author_user) { create(:user) }
|
|
|
|
let(:user) { create(:user) }
|
2017-09-29 04:04:50 -04:00
|
|
|
let(:forked_project) { fork_project(project, author_user, repository: true) }
|
2017-04-20 10:47:32 -04:00
|
|
|
let(:merge_request) { create(:merge_request_with_diffs, source_project: forked_project, target_project: project, author: author_user) }
|
|
|
|
let(:changelog_id) { Digest::SHA1.hexdigest("CHANGELOG") }
|
2017-04-22 01:54:03 -04:00
|
|
|
|
2017-06-01 10:27:35 -04:00
|
|
|
before do
|
|
|
|
forked_project.repository.after_import
|
|
|
|
end
|
|
|
|
|
2017-04-22 01:54:03 -04:00
|
|
|
context 'as author' do
|
|
|
|
it 'shows direct edit link' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(author_user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-04-22 01:54:03 -04:00
|
|
|
|
|
|
|
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
|
|
|
|
expect(page).to have_selector("[id=\"#{changelog_id}\"] a.js-edit-blob")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'as user who needs to fork' do
|
|
|
|
it 'shows fork/cancel confirmation' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-04-22 01:54:03 -04:00
|
|
|
|
|
|
|
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
|
2017-09-19 13:51:16 -04:00
|
|
|
find("[id=\"#{changelog_id}\"] .js-edit-blob").click
|
2017-04-22 01:54:03 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector('.js-fork-suggestion-button', count: 1)
|
|
|
|
expect(page).to have_selector('.js-cancel-fork-suggestion-button', count: 1)
|
2016-12-30 14:16:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-07-12 08:29:26 -04:00
|
|
|
end
|