Commit ceac0ae6 authored by Phil Hughes's avatar Phil Hughes

Merge branch '41117-empty-state' into 'master'

Only render signout screen when user is signed out

Closes #41117 and #39843

See merge request gitlab-org/gitlab-ce!15935
parents c9041508 e4b72248
...@@ -8,16 +8,17 @@ ...@@ -8,16 +8,17 @@
= image_tag 'illustrations/issues.svg' = image_tag 'illustrations/issues.svg'
.col-xs-12 .col-xs-12
.text-content .text-content
- if has_button && current_user - if current_user
%h4 %h4
= _("The Issue Tracker is the place to add things that need to be improved or solved in a project") = _("The Issue Tracker is the place to add things that need to be improved or solved in a project")
%p %p
= _("Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.") = _("Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.")
.text-center - if has_button
- if project_select_button .text-center
= render 'shared/new_project_item_select', path: 'issues/new', label: 'New issue', type: :issues - if project_select_button
- else = render 'shared/new_project_item_select', path: 'issues/new', label: 'New issue', type: :issues
= link_to 'New issue', button_path, class: 'btn btn-success', title: 'New issue', id: 'new_issue_link' - else
= link_to 'New issue', button_path, class: 'btn btn-success', title: 'New issue', id: 'new_issue_link'
- else - else
%h4.text-center= _("There are no issues to show") %h4.text-center= _("There are no issues to show")
%p %p
......
...@@ -8,729 +8,753 @@ describe 'Issues' do ...@@ -8,729 +8,753 @@ describe 'Issues' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
before do describe 'while user is signed out' do
sign_in(user) describe 'empty state' do
user2 = create(:user) it 'user sees empty state' do
visit project_issues_path(project)
project.team << [[user, user2], :developer]
end
describe 'Edit issue' do expect(page).to have_content('Register / Sign In')
let!(:issue) do expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project.')
create(:issue, expect(page).to have_content('You can register or sign in to create issues for this project.')
author: user, end
assignees: [user],
project: project)
end end
end
describe 'while user is signed in' do
before do before do
visit edit_project_issue_path(project, issue) sign_in(user)
find('.js-zen-enter').click user2 = create(:user)
end
it 'opens new issue popup' do
expect(page).to have_content("Issue ##{issue.iid}")
end
end
describe 'Editing issue assignee' do project.team << [[user, user2], :developer]
let!(:issue) do
create(:issue,
author: user,
assignees: [user],
project: project)
end end
it 'allows user to select unassigned', :js do describe 'empty state' do
visit edit_project_issue_path(project, issue) it 'user sees empty state' do
visit project_issues_path(project)
expect(page).to have_content "Assignee #{user.name}"
first('.js-user-search').click expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project')
click_link 'Unassigned' expect(page).to have_content('Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.')
expect(page).to have_content('New issue')
end
end
click_button 'Save changes' describe 'Edit issue' do
let!(:issue) do
create(:issue,
author: user,
assignees: [user],
project: project)
end
page.within('.assignee') do before do
expect(page).to have_content 'No assignee - assign yourself' visit edit_project_issue_path(project, issue)
find('.js-zen-enter').click
end end
expect(issue.reload.assignees).to be_empty it 'opens new issue popup' do
expect(page).to have_content("Issue ##{issue.iid}")
end
end end
end
describe 'due date', :js do describe 'Editing issue assignee' do
context 'on new form' do let!(:issue) do
before do create(:issue,
visit new_project_issue_path(project) author: user,
assignees: [user],
project: project)
end end
it 'saves with due date' do it 'allows user to select unassigned', :js do
date = Date.today.at_beginning_of_month visit edit_project_issue_path(project, issue)
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
find('#issuable-due-date').click
page.within '.pika-single' do expect(page).to have_content "Assignee #{user.name}"
click_button date.day
end
expect(find('#issuable-due-date').value).to eq date.to_s first('.js-user-search').click
click_link 'Unassigned'
click_button 'Submit issue' click_button 'Save changes'
page.within '.issuable-sidebar' do page.within('.assignee') do
expect(page).to have_content date.to_s(:medium) expect(page).to have_content 'No assignee - assign yourself'
end end
expect(issue.reload.assignees).to be_empty
end end
end end
context 'on edit form' do describe 'due date', :js do
let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) } context 'on new form' do
before do
visit new_project_issue_path(project)
end
before do it 'saves with due date' do
visit edit_project_issue_path(project, issue) date = Date.today.at_beginning_of_month
end
it 'saves with due date' do fill_in 'issue_title', with: 'bug 345'
date = Date.today.at_beginning_of_month fill_in 'issue_description', with: 'bug description'
find('#issuable-due-date').click
expect(find('#issuable-due-date').value).to eq date.to_s page.within '.pika-single' do
click_button date.day
end
date = date.tomorrow expect(find('#issuable-due-date').value).to eq date.to_s
fill_in 'issue_title', with: 'bug 345' click_button 'Submit issue'
fill_in 'issue_description', with: 'bug description'
find('#issuable-due-date').click
page.within '.pika-single' do page.within '.issuable-sidebar' do
click_button date.day expect(page).to have_content date.to_s(:medium)
end
end end
end
expect(find('#issuable-due-date').value).to eq date.to_s context 'on edit form' do
let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) }
click_button 'Save changes' before do
visit edit_project_issue_path(project, issue)
page.within '.issuable-sidebar' do
expect(page).to have_content date.to_s(:medium)
end end
end
it 'warns about version conflict' do it 'saves with due date' do
issue.update(title: "New title") date = Date.today.at_beginning_of_month
fill_in 'issue_title', with: 'bug 345' expect(find('#issuable-due-date').value).to eq date.to_s
fill_in 'issue_description', with: 'bug description'
click_button 'Save changes' date = date.tomorrow
expect(page).to have_content 'Someone edited the issue the same time you did' fill_in 'issue_title', with: 'bug 345'
end fill_in 'issue_description', with: 'bug description'
end find('#issuable-due-date').click
end
page.within '.pika-single' do
click_button date.day
end
describe 'Issue info' do expect(find('#issuable-due-date').value).to eq date.to_s
it 'links to current issue in breadcrubs' do
issue = create(:issue, project: project)
visit project_issue_path(project, issue) click_button 'Save changes'
expect(find('.breadcrumbs-sub-title a')[:href]).to end_with(issue_path(issue)) page.within '.issuable-sidebar' do
end expect(page).to have_content date.to_s(:medium)
end
end
it 'excludes award_emoji from comment count' do it 'warns about version conflict' do
issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar') issue.update(title: "New title")
create(:award_emoji, awardable: issue)
visit project_issues_path(project, assignee_id: user.id) fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
expect(page).to have_content 'foobar' click_button 'Save changes'
expect(page.all('.no-comments').first.text).to eq "0"
end
end
describe 'Filter issue' do expect(page).to have_content 'Someone edited the issue the same time you did'
before do end
%w(foobar barbaz gitlab).each do |title|
create(:issue,
author: user,
assignees: [user],
project: project,
title: title)
end end
@issue = Issue.find_by(title: 'foobar')
@issue.milestone = create(:milestone, project: project)
@issue.assignees = []
@issue.save
end end
let(:issue) { @issue } describe 'Issue info' do
it 'links to current issue in breadcrubs' do
issue = create(:issue, project: project)
it 'allows filtering by issues with no specified assignee' do visit project_issue_path(project, issue)
visit project_issues_path(project, assignee_id: IssuableFinder::NONE)
expect(page).to have_content 'foobar' expect(find('.breadcrumbs-sub-title a')[:href]).to end_with(issue_path(issue))
expect(page).not_to have_content 'barbaz' end
expect(page).not_to have_content 'gitlab'
end
it 'allows filtering by a specified assignee' do it 'excludes award_emoji from comment count' do
visit project_issues_path(project, assignee_id: user.id) issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar')
create(:award_emoji, awardable: issue)
expect(page).not_to have_content 'foobar' visit project_issues_path(project, assignee_id: user.id)
expect(page).to have_content 'barbaz'
expect(page).to have_content 'gitlab'
end
end
describe 'filter issue' do expect(page).to have_content 'foobar'
titles = %w[foo bar baz] expect(page.all('.no-comments').first.text).to eq "0"
titles.each_with_index do |title, index|
let!(title.to_sym) do
create(:issue, title: title,
project: project,
created_at: Time.now - (index * 60))
end end
end end
let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
it 'sorts by newest' do describe 'Filter issue' do
visit project_issues_path(project, sort: sort_value_created_date) before do
%w(foobar barbaz gitlab).each do |title|
create(:issue,
author: user,
assignees: [user],
project: project,
title: title)
end
expect(first_issue).to include('foo') @issue = Issue.find_by(title: 'foobar')
expect(last_issue).to include('baz') @issue.milestone = create(:milestone, project: project)
end @issue.assignees = []
@issue.save
end
it 'sorts by most recently updated' do let(:issue) { @issue }
baz.updated_at = Time.now + 100
baz.save
visit project_issues_path(project, sort: sort_value_recently_updated)
expect(first_issue).to include('baz') it 'allows filtering by issues with no specified assignee' do
end visit project_issues_path(project, assignee_id: IssuableFinder::NONE)
describe 'sorting by due date' do expect(page).to have_content 'foobar'
before do expect(page).not_to have_content 'barbaz'
foo.update(due_date: 1.day.from_now) expect(page).not_to have_content 'gitlab'
bar.update(due_date: 6.days.from_now)
end end
it 'sorts by due date' do it 'allows filtering by a specified assignee' do
visit project_issues_path(project, sort: sort_value_due_date) visit project_issues_path(project, assignee_id: user.id)
expect(first_issue).to include('foo') expect(page).not_to have_content 'foobar'
expect(page).to have_content 'barbaz'
expect(page).to have_content 'gitlab'
end end
end
it 'sorts by due date by excluding nil due dates' do describe 'filter issue' do
bar.update(due_date: nil) titles = %w[foo bar baz]
titles.each_with_index do |title, index|
let!(title.to_sym) do
create(:issue, title: title,
project: project,
created_at: Time.now - (index * 60))
end
end
let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
visit project_issues_path(project, sort: sort_value_due_date) it 'sorts by newest' do
visit project_issues_path(project, sort: sort_value_created_date)
expect(first_issue).to include('foo') expect(first_issue).to include('foo')
expect(last_issue).to include('baz')
end end
context 'with a filter on labels' do it 'sorts by most recently updated' do
let(:label) { create(:label, project: project) } baz.updated_at = Time.now + 100
baz.save
visit project_issues_path(project, sort: sort_value_recently_updated)
expect(first_issue).to include('baz')
end
describe 'sorting by due date' do
before do before do
create(:label_link, label: label, target: foo) foo.update(due_date: 1.day.from_now)
bar.update(due_date: 6.days.from_now)
end
it 'sorts by due date' do
visit project_issues_path(project, sort: sort_value_due_date)
expect(first_issue).to include('foo')
end end
it 'sorts by least recently due date by excluding nil due dates' do it 'sorts by due date by excluding nil due dates' do
bar.update(due_date: nil) bar.update(due_date: nil)
visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later) visit project_issues_path(project, sort: sort_value_due_date)
expect(first_issue).to include('foo') expect(first_issue).to include('foo')
end end
end
end
describe 'filtering by due date' do context 'with a filter on labels' do
before do let(:label) { create(:label, project: project) }
foo.update(due_date: 1.day.from_now)
bar.update(due_date: 6.days.from_now) before do
end create(:label_link, label: label, target: foo)
end
it 'sorts by least recently due date by excluding nil due dates' do
bar.update(due_date: nil)
it 'filters by none' do visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
visit project_issues_path(project, due_date: Issue::NoDueDate.name)
page.within '.issues-holder' do expect(first_issue).to include('foo')
expect(page).not_to have_content('foo') end
expect(page).not_to have_content('bar')
expect(page).to have_content('baz')
end end
end end
it 'filters by any' do describe 'filtering by due date' do
visit project_issues_path(project, due_date: Issue::AnyDueDate.name) before do
foo.update(due_date: 1.day.from_now)
bar.update(due_date: 6.days.from_now)
end
it 'filters by none' do
visit project_issues_path(project, due_date: Issue::NoDueDate.name)
page.within '.issues-holder' do page.within '.issues-holder' do
expect(page).to have_content('foo') expect(page).not_to have_content('foo')
expect(page).to have_content('bar') expect(page).not_to have_content('bar')
expect(page).to have_content('baz') expect(page).to have_content('baz')
end
end
it 'filters by any' do
visit project_issues_path(project, due_date: Issue::AnyDueDate.name)
page.within '.issues-holder' do
expect(page).to have_content('foo')
expect(page).to have_content('bar')
expect(page).to have_content('baz')
end
end end
end
it 'filters by due this week' do it 'filters by due this week' do
foo.update(due_date: Date.today.beginning_of_week + 2.days) foo.update(due_date: Date.today.beginning_of_week + 2.days)
bar.update(due_date: Date.today.end_of_week) bar.update(due_date: Date.today.end_of_week)
baz.update(due_date: Date.today - 8.days) baz.update(due_date: Date.today - 8.days)
visit project_issues_path(project, due_date: Issue::DueThisWeek.name) visit project_issues_path(project, due_date: Issue::DueThisWeek.name)
page.within '.issues-holder' do page.within '.issues-holder' do
expect(page).to have_content('foo') expect(page).to have_content('foo')
expect(page).to have_content('bar') expect(page).to have_content('bar')
expect(page).not_to have_content('baz') expect(page).not_to have_content('baz')
end
end end
end
it 'filters by due this month' do it 'filters by due this month' do
foo.update(due_date: Date.today.beginning_of_month + 2.days) foo.update(due_date: Date.today.beginning_of_month + 2.days)
bar.update(due_date: Date.today.end_of_month) bar.update(due_date: Date.today.end_of_month)
baz.update(due_date: Date.today - 50.days) baz.update(due_date: Date.today - 50.days)
visit project_issues_path(project, due_date: Issue::DueThisMonth.name) visit project_issues_path(project, due_date: Issue::DueThisMonth.name)
page.within '.issues-holder' do page.within '.issues-holder' do
expect(page).to have_content('foo') expect(page).to have_content('foo')
expect(page).to have_content('bar') expect(page).to have_content('bar')
expect(page).not_to have_content('baz') expect(page).not_to have_content('baz')
end
end end
end
it 'filters by overdue' do it 'filters by overdue' do
foo.update(due_date: Date.today + 2.days) foo.update(due_date: Date.today + 2.days)
bar.update(due_date: Date.today + 20.days) bar.update(due_date: Date.today + 20.days)
baz.update(due_date: Date.yesterday) baz.update(due_date: Date.yesterday)
visit project_issues_path(project, due_date: Issue::Overdue.name) visit project_issues_path(project, due_date: Issue::Overdue.name)
page.within '.issues-holder' do page.within '.issues-holder' do
expect(page).not_to have_content('foo') expect(page).not_to have_content('foo')
expect(page).not_to have_content('bar') expect(page).not_to have_content('bar')
expect(page).to have_content('baz') expect(page).to have_content('baz')
end
end end
end end
end
describe 'sorting by milestone' do describe 'sorting by milestone' do
before do before do
foo.milestone = newer_due_milestone foo.milestone = newer_due_milestone
foo.save foo.save
bar.milestone = later_due_milestone bar.milestone = later_due_milestone
bar.save bar.save
end end
it 'sorts by milestone' do it 'sorts by milestone' do
visit project_issues_path(project, sort: sort_value_milestone) visit project_issues_path(project, sort: sort_value_milestone)
expect(first_issue).to include('foo') expect(first_issue).to include('foo')
expect(last_issue).to include('baz') expect(last_issue).to include('baz')
end
end end
end
describe 'combine filter and sort' do describe 'combine filter and sort' do
let(:user2) { create(:user) } let(:user2) { create(:user) }
before do before do
foo.assignees << user2 foo.assignees << user2
foo.save foo.save
bar.assignees << user2 bar.assignees << user2
bar.save bar.save
end end
it 'sorts with a filter applied' do it 'sorts with a filter applied' do
visit project_issues_path(project, sort: sort_value_created_date, assignee_id: user2.id) visit project_issues_path(project, sort: sort_value_created_date, assignee_id: user2.id)
expect(first_issue).to include('foo') expect(first_issue).to include('foo')
expect(last_issue).to include('bar') expect(last_issue).to include('bar')
expect(page).not_to have_content('baz') expect(page).not_to have_content('baz')
end
end end
end end
end
describe 'when I want to reset my incoming email token' do describe 'when I want to reset my incoming email token' do
let(:project1) { create(:project, namespace: user.namespace) } let(:project1) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, project: project1) } let!(:issue) { create(:issue, project: project1) }
before do before do
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab") stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
project1.team << [user, :master] project1.team << [user, :master]
visit namespace_project_issues_path(user.namespace, project1) visit namespace_project_issues_path(user.namespace, project1)
end end
it 'changes incoming email address token', :js do it 'changes incoming email address token', :js do
find('.issuable-email-modal-btn').click find('.issuable-email-modal-btn').click
previous_token = find('input#issuable_email').value previous_token = find('input#issuable_email').value
find('.incoming-email-token-reset').click find('.incoming-email-token-reset').click
wait_for_requests wait_for_requests
expect(page).to have_no_field('issuable_email', with: previous_token) expect(page).to have_no_field('issuable_email', with: previous_token)
new_token = project1.new_issuable_address(user.reload, 'issue') new_token = project1.new_issuable_address(user.reload, 'issue')
expect(page).to have_field( expect(page).to have_field(
'issuable_email', 'issuable_email',
with: new_token with: new_token
) )
end
end end
end
describe 'update labels from issue#show', :js do describe 'update labels from issue#show', :js do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
let!(:label) { create(:label, project: project) } let!(:label) { create(:label, project: project) }
before do before do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
end end
it 'will not send ajax request when no data is changed' do it 'will not send ajax request when no data is changed' do
page.within '.labels' do page.within '.labels' do
click_link 'Edit' click_link 'Edit'
find('.dropdown-menu-close', match: :first).click find('.dropdown-menu-close', match: :first).click
expect(page).not_to have_selector('.block-loading') expect(page).not_to have_selector('.block-loading')
end
end end
end end
end
describe 'update assignee from issue#show' do describe 'update assignee from issue#show' do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
context 'by authorized user' do context 'by authorized user' do
it 'allows user to select unassigned', :js do it 'allows user to select unassigned', :js do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
page.within('.assignee') do page.within('.assignee') do
expect(page).to have_content "#{user.name}" expect(page).to have_content "#{user.name}"
click_link 'Edit' click_link 'Edit'
click_link 'Unassigned' click_link 'Unassigned'
first('.title').click first('.title').click
expect(page).to have_content 'No assignee' expect(page).to have_content 'No assignee'
end end
# wait_for_requests does not work with vue-resource at the moment # wait_for_requests does not work with vue-resource at the moment
sleep 1 sleep 1
expect(issue.reload.assignees).to be_empty expect(issue.reload.assignees).to be_empty
end end
it 'allows user to select an assignee', :js do it 'allows user to select an assignee', :js do
issue2 = create(:issue, project: project, author: user) issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2) visit project_issue_path(project, issue2)
page.within('.assignee') do page.within('.assignee') do
expect(page).to have_content "No assignee" expect(page).to have_content "No assignee"
end end
page.within '.assignee' do page.within '.assignee' do
click_link 'Edit' click_link 'Edit'
end end
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
click_link user.name click_link user.name
end end
page.within('.assignee') do page.within('.assignee') do
expect(page).to have_content user.name expect(page).to have_content user.name
end
end end
end
it 'allows user to unselect themselves', :js do it 'allows user to unselect themselves', :js do
issue2 = create(:issue, project: project, author: user) issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2) visit project_issue_path(project, issue2)
page.within '.assignee' do page.within '.assignee' do
click_link 'Edit' click_link 'Edit'
click_link user.name click_link user.name
page.within '.value .author' do page.within '.value .author' do
expect(page).to have_content user.name expect(page).to have_content user.name
end end
click_link 'Edit' click_link 'Edit'
click_link user.name click_link user.name
page.within '.value .assign-yourself' do page.within '.value .assign-yourself' do
expect(page).to have_content "No assignee" expect(page).to have_content "No assignee"
end
end end
end end
end end
end
context 'by unauthorized user' do context 'by unauthorized user' do
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
project.team << [[guest], :guest] project.team << [[guest], :guest]
end end
it 'shows assignee text', :js do it 'shows assignee text', :js do
sign_out(:user) sign_out(:user)
sign_in(guest) sign_in(guest)
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name expect(page).to have_content issue.assignees.first.name
end
end end
end end
end
describe 'update milestone from issue#show' do describe 'update milestone from issue#show' do
let!(:issue) { create(:issue, project: project, author: user) } let!(:issue) { create(:issue, project: project, author: user) }
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
context 'by authorized user' do context 'by authorized user' do
it 'allows user to select unassigned', :js do it 'allows user to select unassigned', :js do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
page.within('.milestone') do page.within('.milestone') do
expect(page).to have_content "None" expect(page).to have_content "None"
end end
find('.block.milestone .edit-link').click find('.block.milestone .edit-link').click
sleep 2 # wait for ajax stuff to complete sleep 2 # wait for ajax stuff to complete
first('.dropdown-content li').click first('.dropdown-content li').click
sleep 2 sleep 2
page.within('.milestone') do page.within('.milestone') do
expect(page).to have_content 'None' expect(page).to have_content 'None'
end
expect(issue.reload.milestone).to be_nil
end end
expect(issue.reload.milestone).to be_nil it 'allows user to de-select milestone', :js do
end visit project_issue_path(project, issue)
it 'allows user to de-select milestone', :js do page.within('.milestone') do
visit project_issue_path(project, issue) click_link 'Edit'
click_link milestone.title
page.within('.milestone') do page.within '.value' do
click_link 'Edit' expect(page).to have_content milestone.title
click_link milestone.title end
page.within '.value' do
expect(page).to have_content milestone.title
end
click_link 'Edit' click_link 'Edit'
click_link milestone.title click_link milestone.title
page.within '.value' do page.within '.value' do
expect(page).to have_content 'None' expect(page).to have_content 'None'
end
end end
end end
end end
end
context 'by unauthorized user' do context 'by unauthorized user' do
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
project.team << [guest, :guest] project.team << [guest, :guest]
issue.milestone = milestone issue.milestone = milestone
issue.save issue.save
end end
it 'shows milestone text', :js do it 'shows milestone text', :js do
sign_out(:user) sign_out(:user)
sign_in(guest) sign_in(guest)
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).to have_content milestone.title expect(page).to have_content milestone.title
end
end end
end end
end
describe 'new issue' do describe 'new issue' do
let!(:issue) { create(:issue, project: project) } let!(:issue) { create(:issue, project: project) }
context 'by unauthenticated user' do context 'by unauthenticated user' do
before do before do
sign_out(:user) sign_out(:user)
end end
it 'redirects to signin then back to new issue after signin' do it 'redirects to signin then back to new issue after signin' do
visit project_issues_path(project) visit project_issues_path(project)
page.within '.nav-controls' do page.within '.nav-controls' do
click_link 'New issue' click_link 'New issue'
end end
expect(current_path).to eq new_user_session_path expect(current_path).to eq new_user_session_path
gitlab_sign_in(create(:user)) gitlab_sign_in(create(:user))
expect(current_path).to eq new_project_issue_path(project) expect(current_path).to eq new_project_issue_path(project)
end
end end
end
context 'dropzone upload file', :js do context 'dropzone upload file', :js do
before do before do
visit new_project_issue_path(project) visit new_project_issue_path(project)
end end
it 'uploads file when dragging into textarea' do it 'uploads file when dragging into textarea' do
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
expect(page.find_field("issue_description").value).to have_content 'banana_sample' expect(page.find_field("issue_description").value).to have_content 'banana_sample'
end end
it "doesn't add double newline to end of a single attachment markdown" do it "doesn't add double newline to end of a single attachment markdown" do
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
expect(page.find_field("issue_description").value).not_to match /\n\n$/ expect(page.find_field("issue_description").value).not_to match /\n\n$/
end end
it "cancels a file upload correctly" do it "cancels a file upload correctly" do
slow_requests do slow_requests do
dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false) dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
click_button 'Cancel' click_button 'Cancel'
end end
expect(page).to have_button('Attach a file') expect(page).to have_button('Attach a file')
expect(page).not_to have_button('Cancel') expect(page).not_to have_button('Cancel')
expect(page).not_to have_selector('.uploading-progress-container', visible: true) expect(page).not_to have_selector('.uploading-progress-container', visible: true)
end
end end
end
context 'form filled by URL parameters' do context 'form filled by URL parameters' do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
before do before do
project.repository.create_file( project.repository.create_file(
user, user,
'.gitlab/issue_templates/bug.md', '.gitlab/issue_templates/bug.md',
'this is a test "bug" template', 'this is a test "bug" template',
message: 'added issue template', message: 'added issue template',
branch_name: 'master') branch_name: 'master')
visit new_project_issue_path(project, issuable_template: 'bug') visit new_project_issue_path(project, issuable_template: 'bug')
end end
it 'fills in template' do it 'fills in template' do
expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug') expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
end
end end
end end
end
describe 'new issue by email' do describe 'new issue by email' do
shared_examples 'show the email in the modal' do shared_examples 'show the email in the modal' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
before do before do
project.issues << issue project.issues << issue
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab") stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
visit project_issues_path(project) visit project_issues_path(project)
click_button('Email a new issue') click_button('Email a new issue')
end end
it 'click the button to show modal for the new email' do it 'click the button to show modal for the new email' do
page.within '#issuable-email-modal' do page.within '#issuable-email-modal' do
email = project.new_issuable_address(user, 'issue') email = project.new_issuable_address(user, 'issue')
expect(page).to have_selector("input[value='#{email}']") expect(page).to have_selector("input[value='#{email}']")
end
end end
end end
end
context 'with existing issues' do context 'with existing issues' do
let!(:issue) { create(:issue, project: project, author: user) } let!(:issue) { create(:issue, project: project, author: user) }
it_behaves_like 'show the email in the modal' it_behaves_like 'show the email in the modal'
end end
context 'without existing issues' do context 'without existing issues' do
it_behaves_like 'show the email in the modal' it_behaves_like 'show the email in the modal'
end
end end
end
describe 'due date' do describe 'due date' do
context 'update due on issue#show', :js do context 'update due on issue#show', :js do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
before do before do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
end end
it 'adds due date to issue' do it 'adds due date to issue' do
date = Date.today.at_beginning_of_month + 2.days date = Date.today.at_beginning_of_month + 2.days
page.within '.due_date' do page.within '.due_date' do
click_link 'Edit' click_link 'Edit'
page.within '.pika-single' do page.within '.pika-single' do
click_button date.day click_button date.day
end end
wait_for_requests wait_for_requests
expect(find('.value').text).to have_content date.strftime('%b %-d, %Y') expect(find('.value').text).to have_content date.strftime('%b %-d, %Y')
end
end end
end
it 'removes due date from issue' do it 'removes due date from issue' do
date = Date.today.at_beginning_of_month + 2.days date = Date.today.at_beginning_of_month + 2.days
page.within '.due_date' do page.within '.due_date' do
click_link 'Edit' click_link 'Edit'
page.within '.pika-single' do page.within '.pika-single' do
click_button date.day click_button date.day
end end
wait_for_requests wait_for_requests
expect(page).to have_no_content 'No due date' expect(page).to have_no_content 'No due date'
click_link 'remove due date' click_link 'remove due date'
expect(page).to have_content 'No due date' expect(page).to have_content 'No due date'
end
end end
end end
end end
end
describe 'title issue#show', :js do describe 'title issue#show', :js do
it 'updates the title', :js do it 'updates the title', :js do
issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title') issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title')
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).to have_text("new title") expect(page).to have_text("new title")
issue.update(title: "updated title") issue.update(title: "updated title")
wait_for_requests wait_for_requests
expect(page).to have_text("updated title") expect(page).to have_text("updated title")
end
end end
end
describe 'confidential issue#show', :js do describe 'confidential issue#show', :js do
it 'shows confidential sibebar information as confidential and can be turned off' do it 'shows confidential sibebar information as confidential and can be turned off' do
issue = create(:issue, :confidential, project: project) issue = create(:issue, :confidential, project: project)
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).to have_css('.issuable-note-warning') expect(page).to have_css('.issuable-note-warning')
expect(find('.issuable-sidebar-item.confidentiality')).to have_css('.is-active') expect(find('.issuable-sidebar-item.confidentiality')).to have_css('.is-active')
expect(find('.issuable-sidebar-item.confidentiality')).not_to have_css('.not-active') expect(find('.issuable-sidebar-item.confidentiality')).not_to have_css('.not-active')
find('.confidential-edit').click find('.confidential-edit').click
expect(page).to have_css('.sidebar-item-warning-message') expect(page).to have_css('.sidebar-item-warning-message')
within('.sidebar-item-warning-message') do within('.sidebar-item-warning-message') do
find('.btn-close').click find('.btn-close').click
end end
wait_for_requests wait_for_requests
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).not_to have_css('.is-active') expect(page).not_to have_css('.is-active')
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment