BigW Consortium Gitlab

issues.rb 2.42 KB
Newer Older
1
class Spinach::Features::DashboardIssues < Spinach::FeatureSteps
Nihad Abbasov committed
2 3
  include SharedAuthentication
  include SharedPaths
4
  include Select2Helper
Nihad Abbasov committed
5

6 7 8 9 10 11 12 13
  step 'I should see issues assigned to me' do
    should_see(assigned_issue)
    should_not_see(authored_issue)
    should_not_see(other_issue)
  end

  step 'I should see issues authored by me' do
    should_see(authored_issue)
14
    should_see(authored_issue_on_public_project)
15 16 17 18 19 20 21 22 23 24 25 26
    should_not_see(assigned_issue)
    should_not_see(other_issue)
  end

  step 'I should see all issues' do
    should_see(authored_issue)
    should_see(assigned_issue)
    should_see(other_issue)
  end

  step 'I have authored issues' do
    authored_issue
27
    authored_issue_on_public_project
28 29 30 31 32 33 34 35 36 37 38
  end

  step 'I have assigned issues' do
    assigned_issue
  end

  step 'I have other issues' do
    other_issue
  end

  step 'I click "Authored by me" link' do
39 40 41
    find("#assignee_id").set("")
    find(".js-author-search", match: :first).click
    find(".dropdown-menu-author li a", match: :first, text: current_user.to_reference).click
42 43
  end

44
  step 'I click "All" link' do
Alfredo Sumaran committed
45
    find(".js-author-search").click
Phil Hughes committed
46
    expect(page).to have_selector(".dropdown-menu-author li a")
Alfredo Sumaran committed
47
    find(".dropdown-menu-author li a", match: :first).click
Phil Hughes committed
48 49
    expect(page).not_to have_selector(".dropdown-menu-author li a")

Alfredo Sumaran committed
50
    find(".js-assignee-search").click
Phil Hughes committed
51
    expect(page).to have_selector(".dropdown-menu-assignee li a")
Alfredo Sumaran committed
52
    find(".dropdown-menu-assignee li a", match: :first).click
Phil Hughes committed
53
    expect(page).not_to have_selector(".dropdown-menu-assignee li a")
54 55 56
  end

  def should_see(issue)
57
    expect(page).to have_content(issue.title[0..10])
58 59 60
  end

  def should_not_see(issue)
61
    expect(page).not_to have_content(issue.title[0..10])
62 63 64 65 66 67 68 69 70 71 72 73 74
  end

  def assigned_issue
    @assigned_issue ||= create :issue, assignee: current_user, project: project
  end

  def authored_issue
    @authored_issue ||= create :issue, author: current_user, project: project
  end

  def other_issue
    @other_issue ||= create :issue, project: project
  end
75

76 77 78 79
  def authored_issue_on_public_project
    @authored_issue_on_public_project ||= create :issue, author: current_user, project: public_project
  end

80 81
  def project
    @project ||= begin
82
                   project = create(:empty_project)
83 84 85
                   project.team << [current_user, :master]
                   project
                 end
86
  end
87 88

  def public_project
89
    @public_project ||= create(:empty_project, :public)
90
  end
91
end