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

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

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

15
  step 'I click link "All"' do
R
Riyad Preukschas 已提交
16
    click_link "All"
17 18
  end

19
  step 'I click link "Closed"' do
20 21 22
    click_link "Closed"
  end

23
  step 'I should see merge request "Wiki Feature"' do
24 25 26
    within '.merge-request' do
      page.should have_content "Wiki Feature"
    end
27 28
  end

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

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

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

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

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

R
Riyad Preukschas 已提交
51

52
  step 'I should not see "Bug NS-04" in merge requests' do
R
Riyad Preukschas 已提交
53
    page.should_not have_content "Bug NS-04"
54 55
  end

56
  step 'I click link "Close"' do
R
Riyad Preukschas 已提交
57
    click_link "Close"
58 59
  end

60
  step 'I submit new merge request "Wiki Feature"' do
61 62 63 64 65 66 67
    fill_in "merge_request_title", with: "Wiki Feature"

    # this must come first, so that the target branch is set
    # by the time the "select" for "notes_refactoring" is executed
    select project.path_with_namespace, from: "merge_request_target_project_id"
    select "master", from: "merge_request_source_branch"

I
Izaak Alpert 已提交
68 69 70
    find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s
    find(:select, "merge_request_source_project_id", {}).value.should == project.id.to_s

71 72
    # using "notes_refactoring" because "Bug NS-04" uses master/stable,
    # this will fail merge_request validation if the branches are the same
I
Izaak Alpert 已提交
73
    find(:select, "merge_request_target_branch", {}).find(:option, "notes_refactoring", {}).value.should == "notes_refactoring"
74
    select "notes_refactoring", from: "merge_request_target_branch"
I
Izaak Alpert 已提交
75

76
    click_button "Submit merge request"
77 78
  end

79
  step 'project "Shop" have "Bug NS-04" open merge request' do
A
Andrew8xx8 已提交
80
    create(:merge_request,
R
Riyad Preukschas 已提交
81
           title: "Bug NS-04",
I
Izaak Alpert 已提交
82 83
           source_project: project,
           target_project: project,
R
Riyad Preukschas 已提交
84 85 86
           author: project.users.first)
  end

87
  step 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
R
Riyad Preukschas 已提交
88 89
    create(:merge_request_with_diffs,
           title: "Bug NS-05",
I
Izaak Alpert 已提交
90 91
           source_project: project,
           target_project: project,
R
Riyad Preukschas 已提交
92
           author: project.users.first)
93 94
  end

95
  step 'project "Shop" have "Feature NS-03" closed merge request' do
A
Andrew8xx8 已提交
96
    create(:closed_merge_request,
R
Riyad Preukschas 已提交
97
           title: "Feature NS-03",
I
Izaak Alpert 已提交
98 99
           source_project: project,
           target_project: project,
A
Andrew8xx8 已提交
100
           author: project.users.first)
R
Riyad Preukschas 已提交
101 102
  end

103
  step 'I switch to the diff tab' do
104
    visit diffs_project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
105 106
  end

107
  step 'I switch to the merge request\'s comments tab' do
108
    visit project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
109 110
  end

111
  step 'I click on the first commit in the merge request' do
112
    click_link merge_request.commits.first.short_id(8)
R
Riyad Preukschas 已提交
113 114
  end

115
  step 'I leave a comment on the diff page' do
116
    init_diff_note
D
Dmitriy Zaporozhets 已提交
117

118
    within('.js-discussion-note-form') do
R
Riyad Preukschas 已提交
119 120 121
      fill_in "note_note", with: "One comment to rule them all"
      click_button "Add Comment"
    end
122 123 124 125

    within ".note-text" do
      page.should have_content "One comment to rule them all"
    end
R
Riyad Preukschas 已提交
126 127
  end

128
  step 'I leave a comment like "Line is wrong" on line 185 of the first file' do
129
    init_diff_note
R
Riyad Preukschas 已提交
130

131
    within(".js-discussion-note-form") do
R
Riyad Preukschas 已提交
132 133
      fill_in "note_note", with: "Line is wrong"
      click_button "Add Comment"
134 135 136 137
    end

    within ".note-text" do
      page.should have_content "Line is wrong"
R
Riyad Preukschas 已提交
138 139 140
    end
  end

141
  step 'I should see a discussion has started on line 185' do
R
Riyad Preukschas 已提交
142
    page.should have_content "#{current_user.name} started a discussion on this merge request diff"
D
Dmitriy Zaporozhets 已提交
143
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
144 145 146
    page.should have_content "Line is wrong"
  end

147
  step 'I should see a discussion has started on commit bcf03b5de6c:L185' do
R
Riyad Preukschas 已提交
148
    page.should have_content "#{current_user.name} started a discussion on commit"
D
Dmitriy Zaporozhets 已提交
149
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
150 151 152
    page.should have_content "Line is wrong"
  end

153
  step 'I should see a discussion has started on commit bcf03b5de6c' do
D
Dmitriy Zaporozhets 已提交
154
    page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c"
R
Riyad Preukschas 已提交
155
    page.should have_content "One comment to rule them all"
D
Dmitriy Zaporozhets 已提交
156
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
157
  end
158

159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
  step 'merge request is mergeable' do
    page.should have_content 'You can accept this request automatically'
  end

  step 'I modify merge commit message' do
    find('.modify-merge-commit-link').click
    fill_in 'merge_commit_message', with: "wow such merge"
  end

  step 'merge request "Bug NS-05" is mergeable' do
    merge_request.mark_as_mergeable
  end

  step 'I accept this merge request' do
    click_button "Accept Merge Request"
  end

  step 'I should see merged request' do
    within '.page-title' do
      page.should have_content "Merged"
    end
  end

182 183 184 185 186 187 188
  def project
    @project ||= Project.find_by_name!("Shop")
  end

  def merge_request
    @merge_request ||= MergeRequest.find_by_title!("Bug NS-05")
  end
189 190 191 192

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