Commit e6b5f4ad authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

refactor finders in spianch:merge_request.feature

parent 51b547f8
...@@ -34,11 +34,11 @@ Feature: Project Merge Requests ...@@ -34,11 +34,11 @@ Feature: Project Merge Requests
And I submit new merge request "Wiki Feature" And I submit new merge request "Wiki Feature"
Then I should see merge request "Wiki Feature" Then I should see merge request "Wiki Feature"
#@javascript @javascript
#Scenario: I comment on a 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 @javascript
Scenario: I comment on a merge request diff Scenario: I comment on a merge request diff
......
...@@ -25,8 +25,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -25,8 +25,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
Then 'I should see closed merge request "Bug NS-04"' do Then 'I should see closed merge request "Bug NS-04"' do
mr = MergeRequest.find_by_title("Bug NS-04") merge_request = MergeRequest.find_by_title!("Bug NS-04")
mr.closed?.should be_true merge_request.closed?.should be_true
page.should have_content "Closed by" page.should have_content "Closed by"
end end
...@@ -63,7 +63,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -63,7 +63,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end 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")
create(:merge_request, create(:merge_request,
title: "Bug NS-04", title: "Bug NS-04",
project: project, project: project,
...@@ -71,7 +70,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -71,7 +70,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do 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, create(:merge_request_with_diffs,
title: "Bug NS-05", title: "Bug NS-05",
project: project, project: project,
...@@ -79,7 +77,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -79,7 +77,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps
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")
create(:closed_merge_request, create(:closed_merge_request,
title: "Feature NS-03", title: "Feature NS-03",
project: project, project: project,
...@@ -87,18 +84,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -87,18 +84,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
And 'I switch to the diff tab' do And 'I switch to the diff tab' do
mr = MergeRequest.find_by_title("Bug NS-05") visit diffs_project_merge_request_path(merge_request.project, merge_request)
visit diffs_project_merge_request_path(mr.project, mr)
end end
And 'I switch to the merge request\'s comments tab' do And 'I switch to the merge request\'s comments tab' do
mr = MergeRequest.find_by_title("Bug NS-05") visit project_merge_request_path(merge_request.project, merge_request)
visit project_merge_request_path(mr.project, mr)
end end
And 'I click on the first commit in the merge request' do 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) click_link merge_request.commits.first.short_id(8)
end end
And 'I leave a comment on the diff page' do And 'I leave a comment on the diff page' do
...@@ -121,8 +116,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -121,8 +116,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
Then 'I should see a discussion has started on line 185' do Then 'I should see a discussion has started on line 185' do
mr = MergeRequest.find_by_title("Bug NS-05") first_commit = merge_request.commits.first
first_commit = mr.commits.first
first_diff = first_commit.diffs.first first_diff = first_commit.diffs.first
page.should have_content "#{current_user.name} started a discussion on this merge request diff" 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 "#{first_diff.b_path}:L185"
...@@ -130,8 +124,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -130,8 +124,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
mr = MergeRequest.find_by_title("Bug NS-05") first_commit = merge_request.commits.first
first_commit = mr.commits.first
first_diff = first_commit.diffs.first first_diff = first_commit.diffs.first
page.should have_content "#{current_user.name} started a discussion on commit" 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_commit.short_id(8)
...@@ -140,12 +133,19 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -140,12 +133,19 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
Then 'I should see a discussion has started on commit bcf03b5de6c' do Then 'I should see a discussion has started on commit bcf03b5de6c' do
mr = MergeRequest.find_by_title("Bug NS-05") first_commit = merge_request.st_commits.first
first_commit = mr.st_commits.first
first_diff = first_commit.diffs.first first_diff = first_commit.diffs.first
page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c"
page.should have_content first_commit.short_id(8) page.should have_content first_commit.short_id(8)
page.should have_content "One comment to rule them all" page.should have_content "One comment to rule them all"
page.should have_content "#{first_diff.b_path}:L185" page.should have_content "#{first_diff.b_path}:L185"
end end
def project
@project ||= Project.find_by_name!("Shop")
end
def merge_request
@merge_request ||= MergeRequest.find_by_title!("Bug NS-05")
end
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