summaryrefslogtreecommitdiff
path: root/spec/features/issues/user_views_issue_spec.rb
blob: dd04ac94105b3c16740aad6f1870ebcaecca361a (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
# frozen_string_literal: true

require "spec_helper"

describe "User views issue" do
  let(:project) { create(:project_empty_repo, :public) }
  let(:user) { create(:user) }
  let(:issue) { create(:issue, project: project, description: "# Description header", author: user) }

  before do
    project.add_developer(user)
    sign_in(user)

    visit(project_issue_path(project, issue))
  end

  it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") }

  it 'shows the merge request and issue actions', :aggregate_failures do
    expect(page).to have_link('New issue')
    expect(page).to have_button('Create merge request')
    expect(page).to have_link('Close issue')
  end

  context 'when the project is archived' do
    let(:project) { create(:project, :public, :archived) }

    it 'hides the merge request and issue actions', :aggregate_failures do
      expect(page).not_to have_link('New issue')
      expect(page).not_to have_button('Create merge request')
      expect(page).not_to have_link('Close issue')
    end
  end

  describe 'user status' do
    subject { visit(project_issue_path(project, issue)) }

    describe 'showing status of the author of the issue' do
      it_behaves_like 'showing user status' do
        let(:user_with_status) { issue.author }
      end
    end

    describe 'showing status of a user who commented on an issue', :js do
      let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) }

      it_behaves_like 'showing user status' do
        let(:user_with_status) { create(:user) }
      end
    end
  end
end