Commit 0b3df2f12849a98c92e53d6d28a43b27c71608bd

Authored by Riyad Preukschas
1 parent 7971383d

Add merge request note feature

features/project/merge_requests.feature
@@ -35,8 +35,34 @@ Feature: Project Merge Requests @@ -35,8 +35,34 @@ Feature: Project Merge Requests
35 Then I should see merge request "Wiki Feature" 35 Then I should see merge request "Wiki Feature"
36 36
37 @javascript 37 @javascript
38 - Scenario: I comment merge request 38 + Scenario: I comment on a merge request
39 Given I visit merge request page "Bug NS-04" 39 Given I visit merge request page "Bug NS-04"
40 And I leave a comment like "XML attached" 40 And I leave a comment like "XML attached"
41 Then I should see comment "XML attached" 41 Then I should see comment "XML attached"
42 42
  43 + @javascript
  44 + Scenario: I comment on a merge request diff
  45 + Given project "Shop" have "Bug NS-05" open merge request with diffs inside
  46 + And I visit merge request page "Bug NS-05"
  47 + And I switch to the diff tab
  48 + And I leave a comment like "Line is wrong" on line 185 of the first file
  49 + And I switch to the merge request's comments tab
  50 + Then I should see a discussion has started on line 185
  51 +
  52 + @javascript
  53 + Scenario: I comment on a line of a commit in merge request
  54 + Given project "Shop" have "Bug NS-05" open merge request with diffs inside
  55 + And I visit merge request page "Bug NS-05"
  56 + And I click on the first commit in the merge request
  57 + And I leave a comment like "Line is wrong" on line 185 of the first file
  58 + And I switch to the merge request's comments tab
  59 + Then I should see a discussion has started on commit bcf03b5de6c:L185
  60 +
  61 + @javascript
  62 + Scenario: I comment on a commit in merge request
  63 + Given project "Shop" have "Bug NS-05" open merge request with diffs inside
  64 + And I visit merge request page "Bug NS-05"
  65 + And I click on the first commit in the merge request
  66 + And I leave a comment on the diff page
  67 + And I switch to the merge request's comments tab
  68 + Then I should see a discussion has started on commit bcf03b5de6c
features/steps/project/project_merge_requests.rb
@@ -4,77 +4,148 @@ class ProjectMergeRequests < Spinach::FeatureSteps @@ -4,77 +4,148 @@ class ProjectMergeRequests < Spinach::FeatureSteps
4 include SharedNote 4 include SharedNote
5 include SharedPaths 5 include SharedPaths
6 6
7 - Then 'I should see "Bug NS-04" in merge requests' do  
8 - page.should have_content "Bug NS-04" 7 + Given 'I click link "New Merge Request"' do
  8 + click_link "New Merge Request"
9 end 9 end
10 10
11 - And 'I should not see "Feature NS-03" in merge requests' do  
12 - page.should_not have_content "Feature NS-03" 11 + Given 'I click link "Bug NS-04"' do
  12 + click_link "Bug NS-04"
  13 + end
  14 +
  15 + Given 'I click link "All"' do
  16 + click_link "All"
13 end 17 end
14 18
15 Given 'I click link "Closed"' do 19 Given 'I click link "Closed"' do
16 click_link "Closed" 20 click_link "Closed"
17 end 21 end
18 22
19 - Then 'I should see "Feature NS-03" in merge requests' do  
20 - page.should have_content "Feature NS-03" 23 + Then 'I should see merge request "Wiki Feature"' do
  24 + page.should have_content "Wiki Feature"
21 end 25 end
22 26
23 - And 'I should not see "Bug NS-04" in merge requests' do  
24 - page.should_not have_content "Bug NS-04" 27 + Then 'I should see closed merge request "Bug NS-04"' do
  28 + mr = MergeRequest.find_by_title("Bug NS-04")
  29 + mr.closed.should be_true
  30 + page.should have_content "Closed by"
25 end 31 end
26 32
27 - Given 'I click link "All"' do  
28 - click_link "All" 33 + Then 'I should see merge request "Bug NS-04"' do
  34 + page.should have_content "Bug NS-04"
29 end 35 end
30 36
31 - Given 'I click link "Bug NS-04"' do  
32 - click_link "Bug NS-04" 37 + Then 'I should see "Bug NS-04" in merge requests' do
  38 + page.should have_content "Bug NS-04"
33 end 39 end
34 40
35 - Then 'I should see merge request "Bug NS-04"' do  
36 - page.should have_content "Bug NS-04" 41 + Then 'I should see "Feature NS-03" in merge requests' do
  42 + page.should have_content "Feature NS-03"
37 end 43 end
38 44
39 - And 'I click link "Close"' do  
40 - click_link "Close" 45 + And 'I should not see "Feature NS-03" in merge requests' do
  46 + page.should_not have_content "Feature NS-03"
41 end 47 end
42 48
43 - Then 'I should see closed merge request "Bug NS-04"' do  
44 - mr = MergeRequest.find_by_title("Bug NS-04")  
45 - mr.closed.should be_true  
46 - page.should have_content "Closed by" 49 +
  50 + And 'I should not see "Bug NS-04" in merge requests' do
  51 + page.should_not have_content "Bug NS-04"
47 end 52 end
48 53
49 - Given 'I click link "New Merge Request"' do  
50 - click_link "New Merge Request" 54 + And 'I click link "Close"' do
  55 + click_link "Close"
51 end 56 end
52 57
53 And 'I submit new merge request "Wiki Feature"' do 58 And 'I submit new merge request "Wiki Feature"' do
54 - fill_in "merge_request_title", :with => "Wiki Feature"  
55 - select "master", :from => "merge_request_source_branch"  
56 - select "stable", :from => "merge_request_target_branch" 59 + fill_in "merge_request_title", with: "Wiki Feature"
  60 + select "master", from: "merge_request_source_branch"
  61 + select "stable", from: "merge_request_target_branch"
57 click_button "Save" 62 click_button "Save"
58 end 63 end
59 64
60 - Then 'I should see merge request "Wiki Feature"' do  
61 - page.should have_content "Wiki Feature"  
62 - end  
63 -  
64 And 'project "Shop" have "Bug NS-04" open merge request' do 65 And 'project "Shop" have "Bug NS-04" open merge request' do
65 project = Project.find_by_name("Shop") 66 project = Project.find_by_name("Shop")
66 create(:merge_request, 67 create(:merge_request,
67 - :title => "Bug NS-04",  
68 - :project => project,  
69 - :author => project.users.first) 68 + title: "Bug NS-04",
  69 + project: project,
  70 + author: project.users.first)
  71 + end
  72 +
  73 + And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
  74 + project = Project.find_by_name("Shop")
  75 + create(:merge_request_with_diffs,
  76 + title: "Bug NS-05",
  77 + project: project,
  78 + author: project.users.first)
70 end 79 end
71 80
72 And 'project "Shop" have "Feature NS-03" closed merge request' do 81 And 'project "Shop" have "Feature NS-03" closed merge request' do
73 project = Project.find_by_name("Shop") 82 project = Project.find_by_name("Shop")
74 create(:merge_request, 83 create(:merge_request,
75 - :title => "Feature NS-03",  
76 - :project => project,  
77 - :author => project.users.first,  
78 - :closed => true) 84 + title: "Feature NS-03",
  85 + project: project,
  86 + author: project.users.first,
  87 + closed: true)
  88 + end
  89 +
  90 + And 'I switch to the diff tab' do
  91 + mr = MergeRequest.find_by_title("Bug NS-05")
  92 + visit diffs_project_merge_request_path(mr.project, mr)
  93 + end
  94 +
  95 + And 'I switch to the merge request\'s comments tab' do
  96 + mr = MergeRequest.find_by_title("Bug NS-05")
  97 + visit project_merge_request_path(mr.project, mr)
  98 + end
  99 +
  100 + And 'I click on the first commit in the merge request' do
  101 + mr = MergeRequest.find_by_title("Bug NS-05")
  102 + click_link mr.commits.first.short_id(8)
  103 + end
  104 +
  105 + And 'I leave a comment on the diff page' do
  106 + within(:xpath, "//div[@class='note-form-holder']") do
  107 + fill_in "note_note", with: "One comment to rule them all"
  108 + click_button "Add Comment"
  109 + end
  110 + end
  111 +
  112 + And 'I leave a comment like "Line is wrong" on line 185 of the first file' do
  113 + within(:xpath, "//div[@class='diff_file'][1]") do
  114 + click_link "add-diff-line-note-0_185_185"
  115 + end
  116 +
  117 + within(:xpath, "//div[@class='line-note-form-holder']") do
  118 + fill_in "note_note", with: "Line is wrong"
  119 + click_button "Add Comment"
  120 + end
  121 + end
  122 +
  123 + Then 'I should see a discussion has started on line 185' do
  124 + mr = MergeRequest.find_by_title("Bug NS-05")
  125 + first_commit = mr.commits.first
  126 + first_diff = mr.diffs.first
  127 + page.should have_content "#{current_user.name} started a discussion on this merge request diff"
  128 + page.should have_content "#{first_diff.b_path}:L185"
  129 + page.should have_content "Line is wrong"
  130 + end
  131 +
  132 + Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
  133 + mr = MergeRequest.find_by_title("Bug NS-05")
  134 + first_commit = mr.commits.first
  135 + first_diff = mr.diffs.first
  136 + page.should have_content "#{current_user.name} started a discussion on commit"
  137 + page.should have_content first_commit.short_id(8)
  138 + page.should have_content "#{first_diff.b_path}:L185"
  139 + page.should have_content "Line is wrong"
  140 + end
  141 +
  142 + Then 'I should see a discussion has started on commit bcf03b5de6c' do
  143 + mr = MergeRequest.find_by_title("Bug NS-05")
  144 + first_commit = mr.st_commits.first
  145 + first_diff = mr.diffs.first
  146 + page.should have_content "#{current_user.name} started a discussion on commit"
  147 + page.should have_content first_commit.short_id(8)
  148 + page.should have_content "One comment to rule them all"
  149 + page.should_not have_content "#{first_diff.b_path}:L185"
79 end 150 end
80 end 151 end
features/steps/shared/paths.rb
@@ -215,6 +215,11 @@ module SharedPaths @@ -215,6 +215,11 @@ module SharedPaths
215 visit project_merge_request_path(mr.project, mr) 215 visit project_merge_request_path(mr.project, mr)
216 end 216 end
217 217
  218 + Given 'I visit merge request page "Bug NS-05"' do
  219 + mr = MergeRequest.find_by_title("Bug NS-05")
  220 + visit project_merge_request_path(mr.project, mr)
  221 + end
  222 +
218 And 'I visit project "Shop" merge requests page' do 223 And 'I visit project "Shop" merge requests page' do
219 visit project_merge_requests_path(Project.find_by_name("Shop")) 224 visit project_merge_requests_path(Project.find_by_name("Shop"))
220 end 225 end