2017-05-04 04:09:21 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-08-01 08:38:45 -04:00
|
|
|
feature 'Create Branch/Merge Request Dropdown on issue page', :feature, :js do
|
2017-05-04 04:09:21 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 17:49:06 -04:00
|
|
|
let!(:project) { create(:project, :repository) }
|
2017-05-04 04:09:21 -04:00
|
|
|
let(:issue) { create(:issue, project: project, title: 'Cherry-Coloured Funk') }
|
|
|
|
|
|
|
|
context 'for team members' do
|
|
|
|
before do
|
|
|
|
project.team << [user, :developer]
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-05-04 04:09:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows creating a merge request from the issue page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
|
2017-08-01 08:38:45 -04:00
|
|
|
perform_enqueued_jobs do
|
|
|
|
select_dropdown_option('create-mr')
|
|
|
|
|
|
|
|
expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"')
|
|
|
|
expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first))
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
2017-05-04 04:09:21 -04:00
|
|
|
|
2017-07-28 12:19:25 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("created branch 1-cherry-coloured-funk")
|
|
|
|
expect(page).to have_content("mentioned in merge request !1")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows creating a branch from the issue page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
|
|
|
|
select_dropdown_option('create-branch')
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-04 04:09:21 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector('.dropdown-toggle-text ', text: '1-cherry-coloured-funk')
|
2017-07-06 12:20:50 -04:00
|
|
|
expect(current_path).to eq project_tree_path(project, '1-cherry-coloured-funk')
|
2017-05-04 04:09:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when there is a referenced merge request" do
|
|
|
|
let!(:note) do
|
|
|
|
create(:note, :on_issue, :system, project: project, noteable: issue,
|
|
|
|
note: "mentioned in #{referenced_mr.to_reference}")
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:referenced_mr) do
|
|
|
|
create(:merge_request, :simple, source_project: project, target_project: project,
|
|
|
|
description: "Fixes #{issue.to_reference}", author: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
referenced_mr.cache_merge_request_closes_issues!(user)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'disables the create branch button' do
|
|
|
|
expect(page).to have_css('.create-mr-dropdown-wrap .unavailable:not(.hide)')
|
|
|
|
expect(page).to have_css('.create-mr-dropdown-wrap .available.hide', visible: false)
|
|
|
|
expect(page).to have_content /1 Related Merge Request/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when issue is confidential' do
|
|
|
|
it 'disables the create branch button' do
|
|
|
|
issue = create(:issue, :confidential, project: project)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_css('.create-mr-dropdown-wrap')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for visitors' do
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-04 04:09:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows no buttons' do
|
|
|
|
expect(page).not_to have_selector('.create-mr-dropdown-wrap')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def select_dropdown_option(option)
|
|
|
|
find('.create-mr-dropdown-wrap .dropdown-toggle').click
|
|
|
|
find("li[data-value='#{option}']").click
|
|
|
|
find('.js-create-merge-request').click
|
|
|
|
end
|
|
|
|
end
|