2016-08-24 12:49:21 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'Diffs URL', js: true do
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
context 'when visit with */* as accept header' do
|
|
|
|
before(:each) do
|
|
|
|
page.driver.add_header('Accept', '*/*')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the notes' do
|
2017-08-17 22:00:37 +05:30
|
|
|
create :note_on_merge_request, project: project, noteable: merge_request, note: 'Rebasing with master'
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
# 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
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
|
2017-08-17 22:00:37 +05:30
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows expanded note' do
|
|
|
|
expect(page).to have_selector(fragment, visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when merge request has overflow' do
|
|
|
|
it 'displays warning' do
|
|
|
|
allow(Commit).to receive(:max_diff_options).and_return(max_files: 3)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
page.within('.alert') do
|
|
|
|
expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve
|
|
|
|
performance only 3 of 3+ files are displayed.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when editing file' do
|
|
|
|
let(:author_user) { create(:user) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:forked_project) { Projects::ForkService.new(project, author_user).execute }
|
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
forked_project.repository.after_import
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'as author' do
|
|
|
|
it 'shows direct edit link' do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(author_user)
|
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
# 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-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
|
|
|
|
find("[id=\"#{changelog_id}\"] .js-edit-blob").click
|
|
|
|
|
|
|
|
expect(page).to have_selector('.js-fork-suggestion-button', count: 1)
|
|
|
|
expect(page).to have_selector('.js-cancel-fork-suggestion-button', count: 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|