gitlab-org--gitlab-foss/spec/features/issues/new_branch_button_spec.rb
Yorick Peterse 0426647069 Load the "New Branch" button asynchronously
This button depends on Issue#can_be_worked_on? which in turn depends on
Issue#related_branches. By rendering this button asynchronously we can
finally remove all usages of Issue#related_branches and
Issue#referenced_merge_requests from the issues "show" page.
2016-04-28 16:13:48 -04:00

50 lines
1.5 KiB
Ruby

require 'rails_helper'
feature 'Start new branch from an issue', feature: true do
let!(:project) { create(:project) }
let!(:issue) { create(:issue, project: project) }
let!(:user) { create(:user)}
context "for team members" do
before do
project.team << [user, :master]
login_as(user)
end
it 'shows the new branch button', js: true do
visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).to have_css('#new-branch .available')
end
context "when there is a referenced merge request" do
let(:note) do
create(:note, :on_issue, :system, project: project,
note: "mentioned in !#{referenced_mr.iid}")
end
let(:referenced_mr) do
create(:merge_request, :simple, source_project: project, target_project: project,
description: "Fixes ##{issue.iid}", author: user)
end
before do
issue.notes << note
visit namespace_project_issue_path(project.namespace, project, issue)
end
it "hides the new branch button", js: true do
expect(page).not_to have_css('#new-branch .available')
expect(page).to have_content /1 Related Merge Request/
end
end
end
context "for visiters" do
it 'no button is shown', js: true do
visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).not_to have_css('#new-branch')
end
end
end