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