project_merge_requests.rb 4.1 KB
Newer Older
1
class ProjectMergeRequests < Spinach::FeatureSteps
N
Nihad Abbasov 已提交
2 3 4 5 6
  include SharedAuthentication
  include SharedProject
  include SharedNote
  include SharedPaths

R
Riyad Preukschas 已提交
7 8
  Given 'I click link "New Merge Request"' do
    click_link "New Merge Request"
9 10
  end

R
Riyad Preukschas 已提交
11 12 13 14 15 16
  Given 'I click link "Bug NS-04"' do
    click_link "Bug NS-04"
  end

  Given 'I click link "All"' do
    click_link "All"
17 18 19 20 21 22
  end

  Given 'I click link "Closed"' do
    click_link "Closed"
  end

R
Riyad Preukschas 已提交
23 24
  Then 'I should see merge request "Wiki Feature"' do
    page.should have_content "Wiki Feature"
25 26
  end

R
Riyad Preukschas 已提交
27
  Then 'I should see closed merge request "Bug NS-04"' do
28 29
    merge_request = MergeRequest.find_by_title!("Bug NS-04")
    merge_request.closed?.should be_true
R
Riyad Preukschas 已提交
30
    page.should have_content "Closed by"
31 32
  end

R
Riyad Preukschas 已提交
33 34
  Then 'I should see merge request "Bug NS-04"' do
    page.should have_content "Bug NS-04"
35 36
  end

R
Riyad Preukschas 已提交
37 38
  Then 'I should see "Bug NS-04" in merge requests' do
    page.should have_content "Bug NS-04"
39 40
  end

R
Riyad Preukschas 已提交
41 42
  Then 'I should see "Feature NS-03" in merge requests' do
    page.should have_content "Feature NS-03"
43 44
  end

R
Riyad Preukschas 已提交
45 46
  And 'I should not see "Feature NS-03" in merge requests' do
    page.should_not have_content "Feature NS-03"
47 48
  end

R
Riyad Preukschas 已提交
49 50 51

  And 'I should not see "Bug NS-04" in merge requests' do
    page.should_not have_content "Bug NS-04"
52 53
  end

R
Riyad Preukschas 已提交
54 55
  And 'I click link "Close"' do
    click_link "Close"
56 57 58
  end

  And 'I submit new merge request "Wiki Feature"' do
59
    fill_in "merge_request_title", with: "Wiki Feature"
D
Dmitriy Zaporozhets 已提交
60 61
    select "bootstrap", from: "merge_request_source_branch"
    select "master", from: "merge_request_target_branch"
62
    click_button "Submit merge request"
63 64 65
  end

  And 'project "Shop" have "Bug NS-04" open merge request' do
A
Andrew8xx8 已提交
66
    create(:merge_request,
R
Riyad Preukschas 已提交
67 68 69 70 71 72 73 74 75 76
           title: "Bug NS-04",
           project: project,
           author: project.users.first)
  end

  And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
    create(:merge_request_with_diffs,
           title: "Bug NS-05",
           project: project,
           author: project.users.first)
77 78 79
  end

  And 'project "Shop" have "Feature NS-03" closed merge request' do
A
Andrew8xx8 已提交
80
    create(:closed_merge_request,
R
Riyad Preukschas 已提交
81 82
           title: "Feature NS-03",
           project: project,
A
Andrew8xx8 已提交
83
           author: project.users.first)
R
Riyad Preukschas 已提交
84 85 86
  end

  And 'I switch to the diff tab' do
87
    visit diffs_project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
88 89 90
  end

  And 'I switch to the merge request\'s comments tab' do
91
    visit project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
92 93 94
  end

  And 'I click on the first commit in the merge request' do
95 96

    click_link merge_request.commits.first.short_id(8)
R
Riyad Preukschas 已提交
97 98 99
  end

  And 'I leave a comment on the diff page' do
100
    init_diff_note
D
Dmitriy Zaporozhets 已提交
101

D
Dmitriy Zaporozhets 已提交
102
    within('.js-temp-notes-holder') do
R
Riyad Preukschas 已提交
103 104 105 106 107 108
      fill_in "note_note", with: "One comment to rule them all"
      click_button "Add Comment"
    end
  end

  And 'I leave a comment like "Line is wrong" on line 185 of the first file' do
109
    init_diff_note
R
Riyad Preukschas 已提交
110

D
Dmitriy Zaporozhets 已提交
111
    within(".js-temp-notes-holder") do
R
Riyad Preukschas 已提交
112 113
      fill_in "note_note", with: "Line is wrong"
      click_button "Add Comment"
D
Dmitriy Zaporozhets 已提交
114
      sleep 0.05
R
Riyad Preukschas 已提交
115 116 117 118 119
    end
  end

  Then 'I should see a discussion has started on line 185' do
    page.should have_content "#{current_user.name} started a discussion on this merge request diff"
D
Dmitriy Zaporozhets 已提交
120
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
121 122 123 124 125
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
    page.should have_content "#{current_user.name} started a discussion on commit"
D
Dmitriy Zaporozhets 已提交
126
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
127 128 129 130
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c' do
D
Dmitriy Zaporozhets 已提交
131
    page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c"
R
Riyad Preukschas 已提交
132
    page.should have_content "One comment to rule them all"
D
Dmitriy Zaporozhets 已提交
133
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
134
  end
135 136 137 138 139 140 141 142

  def project
    @project ||= Project.find_by_name!("Shop")
  end

  def merge_request
    @merge_request ||= MergeRequest.find_by_title!("Bug NS-05")
  end
143 144 145 146

  def init_diff_note
    find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
  end
147
end