Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_views_issues_spec.rb « issues « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 56afa7eb6ba87e3d335bd07d333d1c1c22c6c981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# frozen_string_literal: true

require "spec_helper"

RSpec.describe "User views issues" do
  let!(:closed_issue) { create(:closed_issue, project: project) }
  let!(:open_issue1) { create(:issue, project: project) }
  let!(:open_issue2) { create(:issue, project: project) }
  let!(:moved_open_issue) { create(:issue, project: project, moved_to: create(:issue)) }

  let_it_be(:user) { create(:user) }

  shared_examples "opens issue from list" do
    it "opens issue" do
      click_link(issue.title)

      expect(page).to have_content(issue.title)
    end
  end

  shared_examples "open issues" do
    context "open issues" do
      let(:label) { create(:label, project: project, title: "bug") }

      before do
        open_issue1.labels << label

        visit(project_issues_path(project, state: :opened))
      end

      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)
          .and have_content(moved_open_issue.title)
          .and have_no_content('Create list')
      end

      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
    end
  end

  shared_examples "closed issues" do
    context "closed issues" do
      before do
        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)
          .and have_no_content(moved_open_issue.title)
          .and have_no_content('Create list')
      end

      include_examples "opens issue from list" do
        let(:issue) { closed_issue }
      end
    end
  end

  shared_examples "all issues" do
    context "all issues" do
      before do
        visit(project_issues_path(project, state: :all))
      end

      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)
          .and have_content(moved_open_issue.title)
          .and have_no_content('CLOSED (MOVED)')
          .and have_no_content('Create list')
      end

      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
    end
  end

  context "when signed in as developer", :js do
    before do
      project.add_developer(user)
      sign_in(user)
    end

    include_examples "public project"
    include_examples "internal project"
  end

  context "when not signed in", :js do
    include_examples "public project"
  end
end