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 | 34 | And I submit new merge request "Wiki Feature" |
35 | 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 | 43 | @javascript |
44 | 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 | 25 | end |
26 | 26 | |
27 | 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 | 30 | page.should have_content "Closed by" |
31 | 31 | end |
32 | 32 | |
... | ... | @@ -63,7 +63,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
63 | 63 | end |
64 | 64 | |
65 | 65 | And 'project "Shop" have "Bug NS-04" open merge request' do |
66 | - project = Project.find_by_name("Shop") | |
67 | 66 | create(:merge_request, |
68 | 67 | title: "Bug NS-04", |
69 | 68 | project: project, |
... | ... | @@ -71,7 +70,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
71 | 70 | end |
72 | 71 | |
73 | 72 | And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do |
74 | - project = Project.find_by_name("Shop") | |
75 | 73 | create(:merge_request_with_diffs, |
76 | 74 | title: "Bug NS-05", |
77 | 75 | project: project, |
... | ... | @@ -79,7 +77,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
79 | 77 | end |
80 | 78 | |
81 | 79 | And 'project "Shop" have "Feature NS-03" closed merge request' do |
82 | - project = Project.find_by_name("Shop") | |
83 | 80 | create(:closed_merge_request, |
84 | 81 | title: "Feature NS-03", |
85 | 82 | project: project, |
... | ... | @@ -87,18 +84,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
87 | 84 | end |
88 | 85 | |
89 | 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 | 88 | end |
93 | 89 | |
94 | 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 | 92 | end |
98 | 93 | |
99 | 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 | 97 | end |
103 | 98 | |
104 | 99 | And 'I leave a comment on the diff page' do |
... | ... | @@ -121,8 +116,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
121 | 116 | end |
122 | 117 | |
123 | 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 | 120 | first_diff = first_commit.diffs.first |
127 | 121 | page.should have_content "#{current_user.name} started a discussion on this merge request diff" |
128 | 122 | page.should have_content "#{first_diff.b_path}:L185" |
... | ... | @@ -130,8 +124,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
130 | 124 | end |
131 | 125 | |
132 | 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 | 128 | first_diff = first_commit.diffs.first |
136 | 129 | page.should have_content "#{current_user.name} started a discussion on commit" |
137 | 130 | page.should have_content first_commit.short_id(8) |
... | ... | @@ -140,12 +133,19 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
140 | 133 | end |
141 | 134 | |
142 | 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 | 137 | first_diff = first_commit.diffs.first |
146 | 138 | page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" |
147 | 139 | page.should have_content first_commit.short_id(8) |
148 | 140 | page.should have_content "One comment to rule them all" |
149 | 141 | page.should have_content "#{first_diff.b_path}:L185" |
150 | 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 | 151 | end | ... | ... |