Commit 70fb26a6b7091aee9875970f070a6801e35de764

Authored by Marin Jankovski
1 parent 75cecf36

Extract projects and mr into methods in features.

features/public/public_projects.feature
@@ -84,15 +84,18 @@ Feature: Public Projects Feature @@ -84,15 +84,18 @@ Feature: Public Projects Feature
84 Given I sign in as a user 84 Given I sign in as a user
85 Given I visit project "Community" page 85 Given I visit project "Community" page
86 And I visit "Community" merge requests page 86 And I visit "Community" merge requests page
  87 + And project "Community" has "Bug fix" open merge request
87 Then I should see list of merge requests for "Community" project 88 Then I should see list of merge requests for "Community" project
88 89
89 Scenario: I visit public project merge requests page as a non authorized user 90 Scenario: I visit public project merge requests page as a non authorized user
90 Given I visit project "Community" page 91 Given I visit project "Community" page
91 And I visit "Community" merge requests page 92 And I visit "Community" merge requests page
  93 + And project "Community" has "Bug fix" open merge request
92 Then I should see list of merge requests for "Community" project 94 Then I should see list of merge requests for "Community" project
93 95
94 Scenario: I visit internal project merge requests page as an authorized user 96 Scenario: I visit internal project merge requests page as an authorized user
95 Given I sign in as a user 97 Given I sign in as a user
96 Given I visit project "Internal" page 98 Given I visit project "Internal" page
97 And I visit "Internal" merge requests page 99 And I visit "Internal" merge requests page
  100 + And project "Internal" has "Feature implemented" open merge request
98 Then I should see list of merge requests for "Internal" project 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,101 +109,92 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
109 end 109 end
110 110
111 step 'I visit "Community" issues page' do 111 step 'I visit "Community" issues page' do
112 - project = Project.find_by(name: 'Community')  
113 create(:issue, 112 create(:issue,
114 title: "Bug", 113 title: "Bug",
115 - project: project 114 + project: public_project
116 ) 115 )
117 create(:issue, 116 create(:issue,
118 title: "New feature", 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 end 121 end
123 122
124 123
125 step 'I should see list of issues for "Community" project' do 124 step 'I should see list of issues for "Community" project' do
126 - project = Project.find_by(name: 'Community')  
127 -  
128 page.should have_content "Bug" 125 page.should have_content "Bug"
129 - page.should have_content project.name 126 + page.should have_content public_project.name
130 page.should have_content "New feature" 127 page.should have_content "New feature"
131 end 128 end
132 129
133 step 'I visit "Internal" issues page' do 130 step 'I visit "Internal" issues page' do
134 - project = Project.find_by(name: 'Internal')  
135 create(:issue, 131 create(:issue,
136 title: "Internal Bug", 132 title: "Internal Bug",
137 - project: project 133 + project: internal_project
138 ) 134 )
139 create(:issue, 135 create(:issue,
140 title: "New internal feature", 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 end 140 end
145 141
146 142
147 step 'I should see list of issues for "Internal" project' do 143 step 'I should see list of issues for "Internal" project' do
148 - project = Project.find_by(name: 'Internal')  
149 -  
150 page.should have_content "Internal Bug" 144 page.should have_content "Internal Bug"
151 - page.should have_content project.name 145 + page.should have_content internal_project.name
152 page.should have_content "New internal feature" 146 page.should have_content "New internal feature"
153 end 147 end
154 148
155 step 'I visit "Community" merge requests page' do 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 create(:merge_request, 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 end 159 end
173 160
174 step 'I should see list of merge requests for "Community" project' do 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 end 164 end
181 165
182 step 'I visit "Internal" merge requests page' do 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 create(:merge_request, 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 end 176 end
200 177
201 step 'I should see list of merge requests for "Internal" project' do 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 end 198 end
208 end 199 end
209 200