summaryrefslogtreecommitdiff
path: root/spec/features/todos/target_state_spec.rb
blob: 99b70b3d3a16e805243fcf56e3234e5b08a17b87 (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
require 'rails_helper'

feature 'Todo target states', feature: true do
  let(:user)    { create(:user) }
  let(:author)  { create(:user) }
  let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }

  before do
    gitlab_sign_in user
  end

  scenario 'on a closed issue todo has closed label' do
    issue_closed = create(:issue, state: 'closed')
    create_todo issue_closed
    visit dashboard_todos_path

    page.within '.todos-list' do
      expect(page).to have_content('Closed')
    end
  end

  scenario 'on an open issue todo does not have an open label' do
    issue_open = create(:issue)
    create_todo issue_open
    visit dashboard_todos_path

    page.within '.todos-list' do
      expect(page).not_to have_content('Open')
    end
  end

  scenario 'on a merged merge request todo has merged label' do
    mr_merged = create(:merge_request, :simple, author: user, state: 'merged')
    create_todo mr_merged
    visit dashboard_todos_path

    page.within '.todos-list' do
      expect(page).to have_content('Merged')
    end
  end

  scenario 'on a closed merge request todo has closed label' do
    mr_closed = create(:merge_request, :simple, author: user, state: 'closed')
    create_todo mr_closed
    visit dashboard_todos_path

    page.within '.todos-list' do
      expect(page).to have_content('Closed')
    end
  end

  scenario 'on an open merge request todo does not have an open label' do
    mr_open = create(:merge_request, :simple, author: user)
    create_todo mr_open
    visit dashboard_todos_path

    page.within '.todos-list' do
      expect(page).not_to have_content('Open')
    end
  end

  def create_todo(target)
    create(:todo, :mentioned, user: user, project: project, target: target, author: author)
  end
end