Commit 53d3294d1de6a3ded84532c1874ca48910fd69b0

Authored by Robert Speicher
1 parent 046773d6

Speed up features/notes_on_merge_requests_spec

This spec featured the slowest tests in the entire suite. After some
debugging, the cause was found to be the large commit diff generated by
comparing the stable and master branches.

To fix this, the seed repository was modified to create a simple branch
off of master that consists of three simple commits and minor changes.
The spec was then updated to compare master to this branch instead of
stable. The result is a spec group that runs in under 30 seconds, down
from about 90.
spec/factories.rb
... ... @@ -146,6 +146,11 @@ FactoryGirl.define do
146 146 state :reopened
147 147 end
148 148  
  149 + trait :simple do
  150 + source_branch "simple_merge_request"
  151 + target_branch "master"
  152 + end
  153 +
149 154 factory :closed_merge_request, traits: [:closed]
150 155 factory :reopened_merge_request, traits: [:reopened]
151 156 factory :merge_request_with_diffs, traits: [:with_diffs]
... ... @@ -161,7 +166,6 @@ FactoryGirl.define do
161 166 factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
162 167 factory :note_on_merge_request, traits: [:on_merge_request]
163 168 factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
164   - factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment]
165 169  
166 170 trait :on_commit do
167 171 project factory: :project
... ...
spec/features/notes_on_merge_requests_spec.rb
1 1 require 'spec_helper'
2 2  
3 3 describe "On a merge request", js: true do
4   - let!(:project) { create(:project) }
5   - let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
6   - let!(:note) { create(:note_on_merge_request_with_attachment, project: project) }
  4 + let!(:merge_request) { create(:merge_request, :simple) }
  5 + let!(:project) { merge_request.source_project }
  6 + let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) }
7 7  
8 8 before do
9   - login_as :user
10   - project.team << [@user, :master]
11   -
  9 + login_as :admin
12 10 visit project_merge_request_path(project, merge_request)
13 11 end
14 12  
... ... @@ -134,22 +132,20 @@ describe &quot;On a merge request&quot;, js: true do
134 132 end
135 133 end
136 134  
137   -describe "On a merge request diff", js: true, focus: true do
138   - let!(:project) { create(:project) }
139   - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
  135 +describe "On a merge request diff", js: true do
  136 + let(:merge_request) { create(:merge_request, :with_diffs, :simple) }
  137 + let(:project) { merge_request.source_project }
140 138  
141 139 before do
142   - login_as :user
143   - project.team << [@user, :master]
  140 + login_as :admin
144 141 visit diffs_project_merge_request_path(project, merge_request)
145 142 end
146 143  
147   -
148 144 subject { page }
149 145  
150 146 describe "when adding a note" do
151 147 before do
152   - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
  148 + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click
153 149 end
154 150  
155 151 describe "the notes holder" do
... ... @@ -160,13 +156,13 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
160 156  
161 157 describe "the note form" do
162 158 it "shouldn't add a second form for same row" do
163   - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
  159 + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click
164 160  
165   - should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder form", count: 1)
  161 + should have_css("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder form", count: 1)
166 162 end
167 163  
168 164 it "should be removed when canceled" do
169   - within(".diff-file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185']") do
  165 + within(".diff-file form[rel$='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7']") do
170 166 find(".js-close-discussion-note-form").trigger("click")
171 167 end
172 168  
... ... @@ -176,12 +172,9 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
176 172 end
177 173  
178 174 describe "with muliple note forms" do
179   - let!(:project) { create(:project) }
180   - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
181   -
182 175 before do
183   - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
184   - find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click
  176 + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click
  177 + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10"]').click
185 178 end
186 179  
187 180 it { should have_css(".js-temp-notes-holder", count: 2) }
... ... @@ -189,12 +182,12 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
189 182 describe "previewing them separately" do
190 183 before do
191 184 # add two separate texts and trigger previews on both
192   - within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder") do
193   - fill_in "note[note]", with: "One comment on line 185"
  185 + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder") do
  186 + fill_in "note[note]", with: "One comment on line 7"
194 187 find(".js-note-preview-button").trigger("click")
195 188 end
196   - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
197   - fill_in "note[note]", with: "Another comment on line 17"
  189 + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do
  190 + fill_in "note[note]", with: "Another comment on line 10"
198 191 find(".js-note-preview-button").trigger("click")
199 192 end
200 193 end
... ... @@ -202,14 +195,14 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
202 195  
203 196 describe "posting a note" do
204 197 before do
205   - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do
206   - fill_in "note[note]", with: "Another comment on line 17"
  198 + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do
  199 + fill_in "note[note]", with: "Another comment on line 10"
207 200 click_button("Add Comment")
208 201 end
209 202 end
210 203  
211 204 it 'should be added as discussion' do
212   - should have_content("Another comment on line 17")
  205 + should have_content("Another comment on line 10")
213 206 should have_css(".notes_holder")
214 207 should have_css(".notes_holder .note", count: 1)
215 208 should have_link("Reply")
... ...
spec/seed_project.tar.gz
No preview for this file type