Commit 0b3df2f1 authored by Riyad Preukschas's avatar Riyad Preukschas

Add merge request note feature

parent 7971383d
...@@ -35,8 +35,34 @@ Feature: Project Merge Requests ...@@ -35,8 +35,34 @@ Feature: Project Merge Requests
Then I should see merge request "Wiki Feature" Then I should see merge request "Wiki Feature"
@javascript @javascript
Scenario: I comment merge request Scenario: I comment on a merge request
Given I visit merge request page "Bug NS-04" Given I visit merge request page "Bug NS-04"
And I leave a comment like "XML attached" And I leave a comment like "XML attached"
Then I should see comment "XML attached" Then I should see comment "XML attached"
@javascript
Scenario: I comment on a merge request diff
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I switch to the diff tab
And I leave a comment like "Line is wrong" on line 185 of the first file
And I switch to the merge request's comments tab
Then I should see a discussion has started on line 185
@javascript
Scenario: I comment on a line of a commit in merge request
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I click on the first commit in the merge request
And I leave a comment like "Line is wrong" on line 185 of the first file
And I switch to the merge request's comments tab
Then I should see a discussion has started on commit bcf03b5de6c:L185
@javascript
Scenario: I comment on a commit in merge request
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I click on the first commit in the merge request
And I leave a comment on the diff page
And I switch to the merge request's comments tab
Then I should see a discussion has started on commit bcf03b5de6c
...@@ -4,77 +4,148 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -4,77 +4,148 @@ class ProjectMergeRequests < Spinach::FeatureSteps
include SharedNote include SharedNote
include SharedPaths include SharedPaths
Then 'I should see "Bug NS-04" in merge requests' do Given 'I click link "New Merge Request"' do
page.should have_content "Bug NS-04" click_link "New Merge Request"
end end
And 'I should not see "Feature NS-03" in merge requests' do Given 'I click link "Bug NS-04"' do
page.should_not have_content "Feature NS-03" click_link "Bug NS-04"
end
Given 'I click link "All"' do
click_link "All"
end end
Given 'I click link "Closed"' do Given 'I click link "Closed"' do
click_link "Closed" click_link "Closed"
end end
Then 'I should see "Feature NS-03" in merge requests' do Then 'I should see merge request "Wiki Feature"' do
page.should have_content "Feature NS-03" page.should have_content "Wiki Feature"
end end
And 'I should not see "Bug NS-04" in merge requests' do Then 'I should see closed merge request "Bug NS-04"' do
page.should_not have_content "Bug NS-04" mr = MergeRequest.find_by_title("Bug NS-04")
mr.closed.should be_true
page.should have_content "Closed by"
end end
Given 'I click link "All"' do Then 'I should see merge request "Bug NS-04"' do
click_link "All" page.should have_content "Bug NS-04"
end end
Given 'I click link "Bug NS-04"' do Then 'I should see "Bug NS-04" in merge requests' do
click_link "Bug NS-04" page.should have_content "Bug NS-04"
end end
Then 'I should see merge request "Bug NS-04"' do Then 'I should see "Feature NS-03" in merge requests' do
page.should have_content "Bug NS-04" page.should have_content "Feature NS-03"
end end
And 'I click link "Close"' do And 'I should not see "Feature NS-03" in merge requests' do
click_link "Close" page.should_not have_content "Feature NS-03"
end end
Then 'I should see closed merge request "Bug NS-04"' do
mr = MergeRequest.find_by_title("Bug NS-04") And 'I should not see "Bug NS-04" in merge requests' do
mr.closed.should be_true page.should_not have_content "Bug NS-04"
page.should have_content "Closed by"
end end
Given 'I click link "New Merge Request"' do And 'I click link "Close"' do
click_link "New Merge Request" click_link "Close"
end end
And 'I submit new merge request "Wiki Feature"' do And 'I submit new merge request "Wiki Feature"' do
fill_in "merge_request_title", :with => "Wiki Feature" fill_in "merge_request_title", with: "Wiki Feature"
select "master", :from => "merge_request_source_branch" select "master", from: "merge_request_source_branch"
select "stable", :from => "merge_request_target_branch" select "stable", from: "merge_request_target_branch"
click_button "Save" click_button "Save"
end end
Then 'I should see merge request "Wiki Feature"' do
page.should have_content "Wiki Feature"
end
And 'project "Shop" have "Bug NS-04" open merge request' do And 'project "Shop" have "Bug NS-04" open merge request' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
create(:merge_request, create(:merge_request,
:title => "Bug NS-04", title: "Bug NS-04",
:project => project, project: project,
:author => project.users.first) author: project.users.first)
end
And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
project = Project.find_by_name("Shop")
create(:merge_request_with_diffs,
title: "Bug NS-05",
project: project,
author: project.users.first)
end end
And 'project "Shop" have "Feature NS-03" closed merge request' do And 'project "Shop" have "Feature NS-03" closed merge request' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
create(:merge_request, create(:merge_request,
:title => "Feature NS-03", title: "Feature NS-03",
:project => project, project: project,
:author => project.users.first, author: project.users.first,
:closed => true) closed: true)
end
And 'I switch to the diff tab' do
mr = MergeRequest.find_by_title("Bug NS-05")
visit diffs_project_merge_request_path(mr.project, mr)
end
And 'I switch to the merge request\'s comments tab' do
mr = MergeRequest.find_by_title("Bug NS-05")
visit project_merge_request_path(mr.project, mr)
end
And 'I click on the first commit in the merge request' do
mr = MergeRequest.find_by_title("Bug NS-05")
click_link mr.commits.first.short_id(8)
end
And 'I leave a comment on the diff page' do
within(:xpath, "//div[@class='note-form-holder']") do
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
within(:xpath, "//div[@class='diff_file'][1]") do
click_link "add-diff-line-note-0_185_185"
end
within(:xpath, "//div[@class='line-note-form-holder']") do
fill_in "note_note", with: "Line is wrong"
click_button "Add Comment"
end
end
Then 'I should see a discussion has started on line 185' do
mr = MergeRequest.find_by_title("Bug NS-05")
first_commit = mr.commits.first
first_diff = mr.diffs.first
page.should have_content "#{current_user.name} started a discussion on this merge request diff"
page.should have_content "#{first_diff.b_path}:L185"
page.should have_content "Line is wrong"
end
Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
mr = MergeRequest.find_by_title("Bug NS-05")
first_commit = mr.commits.first
first_diff = mr.diffs.first
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content first_commit.short_id(8)
page.should have_content "#{first_diff.b_path}:L185"
page.should have_content "Line is wrong"
end
Then 'I should see a discussion has started on commit bcf03b5de6c' do
mr = MergeRequest.find_by_title("Bug NS-05")
first_commit = mr.st_commits.first
first_diff = mr.diffs.first
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content first_commit.short_id(8)
page.should have_content "One comment to rule them all"
page.should_not have_content "#{first_diff.b_path}:L185"
end end
end end
...@@ -215,6 +215,11 @@ module SharedPaths ...@@ -215,6 +215,11 @@ module SharedPaths
visit project_merge_request_path(mr.project, mr) visit project_merge_request_path(mr.project, mr)
end end
Given 'I visit merge request page "Bug NS-05"' do
mr = MergeRequest.find_by_title("Bug NS-05")
visit project_merge_request_path(mr.project, mr)
end
And 'I visit project "Shop" merge requests page' do And 'I visit project "Shop" merge requests page' do
visit project_merge_requests_path(Project.find_by_name("Shop")) visit project_merge_requests_path(Project.find_by_name("Shop"))
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment