Commit 70fb26a6b7091aee9875970f070a6801e35de764
1 parent
75cecf36
Exists in
spb-stable
and in
3 other branches
Extract projects and mr into methods in features.
Showing
2 changed files
with
45 additions
and
51 deletions
Show diff stats
features/public/public_projects.feature
... | ... | @@ -84,15 +84,18 @@ Feature: Public Projects Feature |
84 | 84 | Given I sign in as a user |
85 | 85 | Given I visit project "Community" page |
86 | 86 | And I visit "Community" merge requests page |
87 | + And project "Community" has "Bug fix" open merge request | |
87 | 88 | Then I should see list of merge requests for "Community" project |
88 | 89 | |
89 | 90 | Scenario: I visit public project merge requests page as a non authorized user |
90 | 91 | Given I visit project "Community" page |
91 | 92 | And I visit "Community" merge requests page |
93 | + And project "Community" has "Bug fix" open merge request | |
92 | 94 | Then I should see list of merge requests for "Community" project |
93 | 95 | |
94 | 96 | Scenario: I visit internal project merge requests page as an authorized user |
95 | 97 | Given I sign in as a user |
96 | 98 | Given I visit project "Internal" page |
97 | 99 | And I visit "Internal" merge requests page |
100 | + And project "Internal" has "Feature implemented" open merge request | |
98 | 101 | Then I should see list of merge requests for "Internal" project | ... | ... |
features/steps/public/projects_feature.rb
... | ... | @@ -109,101 +109,92 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps |
109 | 109 | end |
110 | 110 | |
111 | 111 | step 'I visit "Community" issues page' do |
112 | - project = Project.find_by(name: 'Community') | |
113 | 112 | create(:issue, |
114 | 113 | title: "Bug", |
115 | - project: project | |
114 | + project: public_project | |
116 | 115 | ) |
117 | 116 | create(:issue, |
118 | 117 | title: "New feature", |
119 | - project: project | |
118 | + project: public_project | |
120 | 119 | ) |
121 | - visit project_issues_path(project) | |
120 | + visit project_issues_path(public_project) | |
122 | 121 | end |
123 | 122 | |
124 | 123 | |
125 | 124 | step 'I should see list of issues for "Community" project' do |
126 | - project = Project.find_by(name: 'Community') | |
127 | - | |
128 | 125 | page.should have_content "Bug" |
129 | - page.should have_content project.name | |
126 | + page.should have_content public_project.name | |
130 | 127 | page.should have_content "New feature" |
131 | 128 | end |
132 | 129 | |
133 | 130 | step 'I visit "Internal" issues page' do |
134 | - project = Project.find_by(name: 'Internal') | |
135 | 131 | create(:issue, |
136 | 132 | title: "Internal Bug", |
137 | - project: project | |
133 | + project: internal_project | |
138 | 134 | ) |
139 | 135 | create(:issue, |
140 | 136 | title: "New internal feature", |
141 | - project: project | |
137 | + project: internal_project | |
142 | 138 | ) |
143 | - visit project_issues_path(project) | |
139 | + visit project_issues_path(internal_project) | |
144 | 140 | end |
145 | 141 | |
146 | 142 | |
147 | 143 | step 'I should see list of issues for "Internal" project' do |
148 | - project = Project.find_by(name: 'Internal') | |
149 | - | |
150 | 144 | page.should have_content "Internal Bug" |
151 | - page.should have_content project.name | |
145 | + page.should have_content internal_project.name | |
152 | 146 | page.should have_content "New internal feature" |
153 | 147 | end |
154 | 148 | |
155 | 149 | step 'I visit "Community" merge requests page' do |
156 | - project = Project.find_by(name: 'Community') | |
157 | - create(:merge_request, | |
158 | - title: "Bug fix", | |
159 | - source_project: project, | |
160 | - target_project: project, | |
161 | - source_branch: 'stable', | |
162 | - target_branch: 'master', | |
163 | - ) | |
150 | + visit project_merge_requests_path(public_project) | |
151 | + end | |
152 | + | |
153 | + step 'project "Community" has "Bug fix" open merge request' do | |
164 | 154 | create(:merge_request, |
165 | - title: "Feature created", | |
166 | - source_project: project, | |
167 | - target_project: project, | |
168 | - source_branch: 'stable', | |
169 | - target_branch: 'master', | |
155 | + title: "Bug fix for public project", | |
156 | + source_project: public_project, | |
157 | + target_project: public_project, | |
170 | 158 | ) |
171 | - visit project_merge_requests_path(project) | |
172 | 159 | end |
173 | 160 | |
174 | 161 | step 'I should see list of merge requests for "Community" project' do |
175 | - project = Project.find_by(name: 'Community') | |
176 | - | |
177 | - page.should have_content "Bug fix" | |
178 | - page.should have_content project.name | |
179 | - page.should have_content "Feature created" | |
162 | + page.should have_content public_project.name | |
163 | + page.should have_content public_merge_request.source_project.name | |
180 | 164 | end |
181 | 165 | |
182 | 166 | step 'I visit "Internal" merge requests page' do |
183 | - project = Project.find_by(name: 'Internal') | |
184 | - create(:merge_request, | |
185 | - title: "Bug fix internal", | |
186 | - source_project: project, | |
187 | - target_project: project, | |
188 | - source_branch: 'stable', | |
189 | - target_branch: 'master', | |
190 | - ) | |
167 | + visit project_merge_requests_path(internal_project) | |
168 | + end | |
169 | + | |
170 | + step 'project "Internal" has "Feature implemented" open merge request' do | |
191 | 171 | create(:merge_request, |
192 | - title: "Feature created for internal", | |
193 | - source_project: project, | |
194 | - target_project: project, | |
195 | - source_branch: 'stable', | |
196 | - target_branch: 'master', | |
172 | + title: "Feature implemented", | |
173 | + source_project: internal_project, | |
174 | + target_project: internal_project | |
197 | 175 | ) |
198 | - visit project_merge_requests_path(project) | |
199 | 176 | end |
200 | 177 | |
201 | 178 | step 'I should see list of merge requests for "Internal" project' do |
202 | - project = Project.find_by(name: 'Internal') | |
179 | + page.should have_content internal_project.name | |
180 | + page.should have_content internal_merge_request.source_project.name | |
181 | + end | |
182 | + | |
183 | + def internal_project | |
184 | + @internal_project ||= Project.find_by!(name: 'Internal') | |
185 | + end | |
186 | + | |
187 | + def public_project | |
188 | + @public_project ||= Project.find_by!(name: 'Community') | |
189 | + end | |
190 | + | |
191 | + | |
192 | + def internal_merge_request | |
193 | + @internal_merge_request ||= MergeRequest.find_by!(title: 'Feature implemented') | |
194 | + end | |
203 | 195 | |
204 | - page.should have_content "Bug fix internal" | |
205 | - page.should have_content project.name | |
206 | - page.should have_content "Feature created for internal" | |
196 | + def public_merge_request | |
197 | + @public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project') | |
207 | 198 | end |
208 | 199 | end |
209 | 200 | ... | ... |