2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
require "spec_helper"
|
2017-10-11 00:26:04 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe "User views issues" do
|
2018-04-03 06:27:56 -04:00
|
|
|
let!(:closed_issue) { create(:closed_issue, project: project) }
|
|
|
|
let!(:open_issue1) { create(:issue, project: project) }
|
|
|
|
let!(:open_issue2) { create(:issue, project: project) }
|
2020-07-01 17:08:51 -04:00
|
|
|
let!(:moved_open_issue) { create(:issue, project: project, moved_to: create(:issue)) }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2020-02-26 13:09:24 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
2017-10-11 00:26:04 -04:00
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
shared_examples "opens issue from list" do
|
|
|
|
it "opens issue" do
|
|
|
|
click_link(issue.title)
|
|
|
|
|
|
|
|
expect(page).to have_content(issue.title)
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
shared_examples "open issues" do
|
|
|
|
context "open issues" do
|
|
|
|
let(:label) { create(:label, project: project, title: "bug") }
|
2017-10-11 00:26:04 -04:00
|
|
|
|
|
|
|
before do
|
2018-04-03 06:27:56 -04:00
|
|
|
open_issue1.labels << label
|
|
|
|
|
|
|
|
visit(project_issues_path(project, state: :opened))
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
it "shows open issues" do
|
|
|
|
expect(page).to have_content(project.name)
|
|
|
|
.and have_content(open_issue1.title)
|
|
|
|
.and have_content(open_issue2.title)
|
|
|
|
.and have_no_content(closed_issue.title)
|
2020-07-01 17:08:51 -04:00
|
|
|
.and have_content(moved_open_issue.title)
|
2018-04-03 06:27:56 -04:00
|
|
|
.and have_no_selector(".js-new-board-list")
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
it "opens issues by label" do
|
|
|
|
page.within(".issues-list") do
|
|
|
|
click_link(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content(open_issue1.title)
|
|
|
|
.and have_no_content(open_issue2.title)
|
|
|
|
.and have_no_content(closed_issue.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples "opens issue from list" do
|
|
|
|
let(:issue) { open_issue1 }
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
shared_examples "closed issues" do
|
|
|
|
context "closed issues" do
|
2017-10-11 00:26:04 -04:00
|
|
|
before do
|
2018-04-03 06:27:56 -04:00
|
|
|
visit(project_issues_path(project, state: :closed))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows closed issues" do
|
|
|
|
expect(page).to have_content(project.name)
|
|
|
|
.and have_content(closed_issue.title)
|
|
|
|
.and have_no_content(open_issue1.title)
|
|
|
|
.and have_no_content(open_issue2.title)
|
2020-07-01 17:08:51 -04:00
|
|
|
.and have_no_content(moved_open_issue.title)
|
2018-04-03 06:27:56 -04:00
|
|
|
.and have_no_selector(".js-new-board-list")
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
include_examples "opens issue from list" do
|
|
|
|
let(:issue) { closed_issue }
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
shared_examples "all issues" do
|
|
|
|
context "all issues" do
|
2017-10-11 00:26:04 -04:00
|
|
|
before do
|
2018-04-03 06:27:56 -04:00
|
|
|
visit(project_issues_path(project, state: :all))
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
it "shows all issues" do
|
|
|
|
expect(page).to have_content(project.name)
|
|
|
|
.and have_content(closed_issue.title)
|
|
|
|
.and have_content(open_issue1.title)
|
|
|
|
.and have_content(open_issue2.title)
|
2020-07-01 17:08:51 -04:00
|
|
|
.and have_content(moved_open_issue.title)
|
|
|
|
.and have_no_content('CLOSED (MOVED)')
|
2018-04-03 06:27:56 -04:00
|
|
|
.and have_no_selector(".js-new-board-list")
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
include_examples "opens issue from list" do
|
|
|
|
let(:issue) { closed_issue }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%w[internal public].each do |visibility|
|
|
|
|
shared_examples "#{visibility} project" do
|
|
|
|
context "when project is #{visibility}" do
|
|
|
|
let(:project) { create(:project_empty_repo, :"#{visibility}") }
|
|
|
|
|
|
|
|
include_examples "open issues"
|
|
|
|
include_examples "closed issues"
|
|
|
|
include_examples "all issues"
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
|
2020-07-29 14:09:50 -04:00
|
|
|
context "when signed in as developer", :js do
|
2018-04-03 06:27:56 -04:00
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples "public project"
|
|
|
|
include_examples "internal project"
|
|
|
|
end
|
|
|
|
|
2020-07-29 14:09:50 -04:00
|
|
|
context "when not signed in", :js do
|
2018-04-03 06:27:56 -04:00
|
|
|
include_examples "public project"
|
|
|
|
end
|
2017-10-11 00:26:04 -04:00
|
|
|
end
|