Commit e6b5f4ade9d7dc5aae1bcb41be4fc74cf751fb92
1 parent
51b547f8
Exists in
master
and in
4 other branches
refactor finders in spianch:merge_request.feature
Showing
2 changed files
with
22 additions
and
22 deletions
Show diff stats
features/project/merge_requests.feature
@@ -34,11 +34,11 @@ Feature: Project Merge Requests | @@ -34,11 +34,11 @@ Feature: Project Merge Requests | ||
34 | And I submit new merge request "Wiki Feature" | 34 | And I submit new merge request "Wiki Feature" |
35 | Then I should see merge request "Wiki Feature" | 35 | Then I should see merge request "Wiki Feature" |
36 | 36 | ||
37 | - #@javascript | ||
38 | - #Scenario: I comment on a merge request | ||
39 | - #Given I visit merge request page "Bug NS-04" | ||
40 | - #And I leave a comment like "XML attached" | ||
41 | - #Then I should see comment "XML attached" | 37 | + @javascript |
38 | + Scenario: I comment on a merge request | ||
39 | + Given I visit merge request page "Bug NS-04" | ||
40 | + And I leave a comment like "XML attached" | ||
41 | + Then I should see comment "XML attached" | ||
42 | 42 | ||
43 | @javascript | 43 | @javascript |
44 | Scenario: I comment on a merge request diff | 44 | Scenario: I comment on a merge request diff |
features/steps/project/project_merge_requests.rb
@@ -25,8 +25,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps | @@ -25,8 +25,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps | ||
25 | end | 25 | end |
26 | 26 | ||
27 | Then 'I should see closed merge request "Bug NS-04"' do | 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 | 28 | + merge_request = MergeRequest.find_by_title!("Bug NS-04") |
29 | + merge_request.closed?.should be_true | ||
30 | page.should have_content "Closed by" | 30 | page.should have_content "Closed by" |
31 | end | 31 | end |
32 | 32 | ||
@@ -63,7 +63,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | @@ -63,7 +63,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | ||
63 | end | 63 | end |
64 | 64 | ||
65 | And 'project "Shop" have "Bug NS-04" open merge request' do | 65 | And 'project "Shop" have "Bug NS-04" open merge request' do |
66 | - project = Project.find_by_name("Shop") | ||
67 | create(:merge_request, | 66 | create(:merge_request, |
68 | title: "Bug NS-04", | 67 | title: "Bug NS-04", |
69 | project: project, | 68 | project: project, |
@@ -71,7 +70,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | @@ -71,7 +70,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | ||
71 | end | 70 | end |
72 | 71 | ||
73 | And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do | 72 | 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, | 73 | create(:merge_request_with_diffs, |
76 | title: "Bug NS-05", | 74 | title: "Bug NS-05", |
77 | project: project, | 75 | project: project, |
@@ -79,7 +77,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | @@ -79,7 +77,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps | ||
79 | end | 77 | end |
80 | 78 | ||
81 | And 'project "Shop" have "Feature NS-03" closed merge request' do | 79 | And 'project "Shop" have "Feature NS-03" closed merge request' do |
82 | - project = Project.find_by_name("Shop") | ||
83 | create(:closed_merge_request, | 80 | create(:closed_merge_request, |
84 | title: "Feature NS-03", | 81 | title: "Feature NS-03", |
85 | project: project, | 82 | project: project, |
@@ -87,18 +84,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps | @@ -87,18 +84,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps | ||
87 | end | 84 | end |
88 | 85 | ||
89 | And 'I switch to the diff tab' do | 86 | And 'I switch to the diff tab' do |
90 | - mr = MergeRequest.find_by_title("Bug NS-05") | ||
91 | - visit diffs_project_merge_request_path(mr.project, mr) | 87 | + visit diffs_project_merge_request_path(merge_request.project, merge_request) |
92 | end | 88 | end |
93 | 89 | ||
94 | And 'I switch to the merge request\'s comments tab' do | 90 | And 'I switch to the merge request\'s comments tab' do |
95 | - mr = MergeRequest.find_by_title("Bug NS-05") | ||
96 | - visit project_merge_request_path(mr.project, mr) | 91 | + visit project_merge_request_path(merge_request.project, merge_request) |
97 | end | 92 | end |
98 | 93 | ||
99 | And 'I click on the first commit in the merge request' do | 94 | And 'I click on the first commit in the merge request' do |
100 | - mr = MergeRequest.find_by_title("Bug NS-05") | ||
101 | - click_link mr.commits.first.short_id(8) | 95 | + |
96 | + click_link merge_request.commits.first.short_id(8) | ||
102 | end | 97 | end |
103 | 98 | ||
104 | And 'I leave a comment on the diff page' do | 99 | 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 | ||
121 | end | 116 | end |
122 | 117 | ||
123 | Then 'I should see a discussion has started on line 185' do | 118 | 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 | 119 | + first_commit = merge_request.commits.first |
126 | first_diff = first_commit.diffs.first | 120 | first_diff = first_commit.diffs.first |
127 | page.should have_content "#{current_user.name} started a discussion on this merge request diff" | 121 | 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" | 122 | 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 | ||
130 | end | 124 | end |
131 | 125 | ||
132 | Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do | 126 | 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 | 127 | + first_commit = merge_request.commits.first |
135 | first_diff = first_commit.diffs.first | 128 | first_diff = first_commit.diffs.first |
136 | page.should have_content "#{current_user.name} started a discussion on commit" | 129 | page.should have_content "#{current_user.name} started a discussion on commit" |
137 | page.should have_content first_commit.short_id(8) | 130 | 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 | ||
140 | end | 133 | end |
141 | 134 | ||
142 | Then 'I should see a discussion has started on commit bcf03b5de6c' do | 135 | 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 | 136 | + first_commit = merge_request.st_commits.first |
145 | first_diff = first_commit.diffs.first | 137 | first_diff = first_commit.diffs.first |
146 | page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" | 138 | page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" |
147 | page.should have_content first_commit.short_id(8) | 139 | page.should have_content first_commit.short_id(8) |
148 | page.should have_content "One comment to rule them all" | 140 | page.should have_content "One comment to rule them all" |
149 | page.should have_content "#{first_diff.b_path}:L185" | 141 | page.should have_content "#{first_diff.b_path}:L185" |
150 | end | 142 | end |
143 | + | ||
144 | + def project | ||
145 | + @project ||= Project.find_by_name!("Shop") | ||
146 | + end | ||
147 | + | ||
148 | + def merge_request | ||
149 | + @merge_request ||= MergeRequest.find_by_title!("Bug NS-05") | ||
150 | + end | ||
151 | end | 151 | end |