merge_requests.rb 1.83 KB
Newer Older
1
class DashboardMergeRequests < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedPaths

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
  step 'I should see merge requests assigned to me' do
    should_see(assigned_merge_request)
    should_not_see(authored_merge_request)
    should_not_see(other_merge_request)
  end

  step 'I should see merge requests authored by me' do
    should_see(authored_merge_request)
    should_not_see(assigned_merge_request)
    should_not_see(other_merge_request)
  end

  step 'I should see all merge requests' do
    should_see(authored_merge_request)
    should_see(assigned_merge_request)
    should_see(other_merge_request)
  end

  step 'I have authored merge requests' do
    authored_merge_request
  end

  step 'I have assigned merge requests' do
    assigned_merge_request
  end

  step 'I have other merge requests' do
    other_merge_request
  end

  step 'I click "Authored by me" link' do
    within ".scope-filter" do
37
      click_link 'Created by me'
38 39 40 41 42
    end
  end

  step 'I click "All" link' do
    within ".scope-filter" do
43
      click_link "Everyone's"
44 45 46
    end
  end

47 48 49
  def should_see(merge_request)
    page.should have_content(merge_request.title[0..10])
  end
50

51 52 53
  def should_not_see(merge_request)
    page.should_not have_content(merge_request.title[0..10])
  end
54

55 56 57 58 59 60 61 62 63 64 65
  def assigned_merge_request
    @assigned_merge_request ||= create :merge_request, assignee: current_user, target_project: project
  end

  def authored_merge_request
    @authored_merge_request ||= create :merge_request, author: current_user, target_project: project
  end

  def other_merge_request
    @other_merge_request ||= create :merge_request, target_project: project
  end
66

67 68
  def project
    @project ||= begin
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
69
                   project =create :project
70 71 72
                   project.team << [current_user, :master]
                   project
                 end
73 74
  end
end