2018-12-13 01:54:30 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe "User creates issue" do
|
|
|
|
let(:project) { create(:project_empty_repo, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
context "when signed in as guest" do
|
|
|
|
before do
|
|
|
|
project.add_guest(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(new_project_issue_path(project))
|
|
|
|
end
|
|
|
|
|
2018-12-21 05:37:53 -05:00
|
|
|
it "creates issue", :js do
|
2018-04-03 06:27:56 -04:00
|
|
|
page.within(".issue-form") do
|
|
|
|
expect(page).to have_no_content("Assign to")
|
|
|
|
.and have_no_content("Labels")
|
|
|
|
.and have_no_content("Milestone")
|
2018-06-29 13:30:00 -04:00
|
|
|
|
|
|
|
expect(page.find('#issue_title')['placeholder']).to eq 'Title'
|
|
|
|
expect(page.find('#issue_description')['placeholder']).to eq 'Write a comment or drag your files here…'
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
issue_title = "500 error on profile"
|
|
|
|
|
|
|
|
fill_in("Title", with: issue_title)
|
2018-12-21 05:37:53 -05:00
|
|
|
first('.js-md').click
|
|
|
|
first('.qa-issuable-form-description').native.send_keys('Description')
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
click_button("Submit issue")
|
|
|
|
|
|
|
|
expect(page).to have_content(issue_title)
|
|
|
|
.and have_content(user.name)
|
|
|
|
.and have_content(project.name)
|
2018-12-21 05:37:53 -05:00
|
|
|
expect(page).to have_selector('strong', text: 'Description')
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when signed in as developer", :js do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(new_project_issue_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when previewing" do
|
|
|
|
it "previews content" do
|
|
|
|
form = first(".gfm-form")
|
|
|
|
textarea = first(".gfm-form textarea")
|
|
|
|
|
|
|
|
page.within(form) do
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Preview")
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
|
|
|
|
|
|
|
|
expect(preview).to have_content("Nothing to preview.")
|
|
|
|
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Write")
|
2018-04-03 06:27:56 -04:00
|
|
|
fill_in("Description", with: "Bug fixed :smile:")
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Preview")
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
expect(preview).to have_css("gl-emoji")
|
|
|
|
expect(textarea).not_to be_visible
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with labels" do
|
2018-12-13 01:54:30 -05:00
|
|
|
let(:label_titles) { %w(bug feature enhancement) }
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
before do
|
2018-12-13 01:54:30 -05:00
|
|
|
label_titles.each do |title|
|
2018-04-03 06:27:56 -04:00
|
|
|
create(:label, project: project, title: title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates issue" do
|
|
|
|
issue_title = "500 error on profile"
|
|
|
|
|
|
|
|
fill_in("Title", with: issue_title)
|
|
|
|
click_button("Label")
|
2018-12-13 01:54:30 -05:00
|
|
|
click_link(label_titles.first)
|
2018-04-03 06:27:56 -04:00
|
|
|
click_button("Submit issue")
|
|
|
|
|
|
|
|
expect(page).to have_content(issue_title)
|
|
|
|
.and have_content(user.name)
|
|
|
|
.and have_content(project.name)
|
2018-12-13 01:54:30 -05:00
|
|
|
.and have_content(label_titles.first)
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-03-04 06:37:14 -05:00
|
|
|
|
|
|
|
context "when signed in as user with special characters in their name" do
|
|
|
|
let(:user_special) { create(:user, name: "Jon O'Shea") }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user_special)
|
|
|
|
sign_in(user_special)
|
|
|
|
|
|
|
|
visit(new_project_issue_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "will correctly escape user names with an apostrophe when clicking 'Assign to me'", :js do
|
|
|
|
first('.assign-to-me-link').click
|
|
|
|
|
|
|
|
expect(page).to have_content(user_special.name)
|
|
|
|
expect(page.find('input[name="issue[assignee_ids][]"]', visible: false)['data-meta']).to eq(user_special.name)
|
|
|
|
end
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|