Commit 6b1cada3b29039956e537dc7b2fcae486f41f5c6
1 parent
d9c1967c
Exists in
master
and in
1 other branch
fix spec about controller/errs
Showing
1 changed file
with
50 additions
and
50 deletions
Show diff stats
spec/controllers/errs_controller_spec.rb
@@ -7,17 +7,17 @@ describe ErrsController do | @@ -7,17 +7,17 @@ describe ErrsController do | ||
7 | }, | 7 | }, |
8 | :params => {:app_id => 'dummyid', :id => 'dummyid'} | 8 | :params => {:app_id => 'dummyid', :id => 'dummyid'} |
9 | 9 | ||
10 | - let(:app) { Factory(:app) } | ||
11 | - let(:err) { Factory(:err, :problem => Factory(:problem, :app => app, :environment => "production")) } | 10 | + let(:app) { Fabricate(:app) } |
11 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } | ||
12 | 12 | ||
13 | 13 | ||
14 | describe "GET /errs" do | 14 | describe "GET /errs" do |
15 | render_views | 15 | render_views |
16 | context 'when logged in as an admin' do | 16 | context 'when logged in as an admin' do |
17 | before(:each) do | 17 | before(:each) do |
18 | - @user = Factory(:admin) | 18 | + @user = Fabricate(:admin) |
19 | sign_in @user | 19 | sign_in @user |
20 | - @problem = Factory(:notice, :err => Factory(:err, :problem => Factory(:problem, :app => app, :environment => "production"))).problem | 20 | + @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production"))).problem |
21 | end | 21 | end |
22 | 22 | ||
23 | it "should successfully list errs" do | 23 | it "should successfully list errs" do |
@@ -34,7 +34,7 @@ describe ErrsController do | @@ -34,7 +34,7 @@ describe ErrsController do | ||
34 | 34 | ||
35 | context "pagination" do | 35 | context "pagination" do |
36 | before(:each) do | 36 | before(:each) do |
37 | - 35.times { Factory :err } | 37 | + 35.times { Fabricate :err } |
38 | end | 38 | end |
39 | 39 | ||
40 | it "should have default per_page value for user" do | 40 | it "should have default per_page value for user" do |
@@ -53,7 +53,7 @@ describe ErrsController do | @@ -53,7 +53,7 @@ describe ErrsController do | ||
53 | before(:each) do | 53 | before(:each) do |
54 | environments = ['production', 'test', 'development', 'staging'] | 54 | environments = ['production', 'test', 'development', 'staging'] |
55 | 20.times do |i| | 55 | 20.times do |i| |
56 | - Factory(:problem, :environment => environments[i % environments.length]) | 56 | + Fabricate(:problem, :environment => environments[i % environments.length]) |
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
@@ -96,10 +96,10 @@ describe ErrsController do | @@ -96,10 +96,10 @@ describe ErrsController do | ||
96 | 96 | ||
97 | context 'when logged in as a user' do | 97 | context 'when logged in as a user' do |
98 | it 'gets a paginated list of unresolved errs for the users apps' do | 98 | it 'gets a paginated list of unresolved errs for the users apps' do |
99 | - sign_in(user = Factory(:user)) | ||
100 | - unwatched_err = Factory(:err) | ||
101 | - watched_unresolved_err = Factory(:err, :problem => Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => false)) | ||
102 | - watched_resolved_err = Factory(:err, :problem => Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => true)) | 99 | + sign_in(user = Fabricate(:user)) |
100 | + unwatched_err = Fabricate(:err) | ||
101 | + watched_unresolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false)) | ||
102 | + watched_resolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true)) | ||
103 | get :index | 103 | get :index |
104 | assigns(:problems).should include(watched_unresolved_err.problem) | 104 | assigns(:problems).should include(watched_unresolved_err.problem) |
105 | assigns(:problems).should_not include(unwatched_err.problem, watched_resolved_err.problem) | 105 | assigns(:problems).should_not include(unwatched_err.problem, watched_resolved_err.problem) |
@@ -110,10 +110,10 @@ describe ErrsController do | @@ -110,10 +110,10 @@ describe ErrsController do | ||
110 | describe "GET /errs/all" do | 110 | describe "GET /errs/all" do |
111 | context 'when logged in as an admin' do | 111 | context 'when logged in as an admin' do |
112 | it "gets a paginated list of all errs" do | 112 | it "gets a paginated list of all errs" do |
113 | - sign_in Factory(:admin) | 113 | + sign_in Fabricate(:admin) |
114 | errs = Kaminari.paginate_array((1..30).to_a) | 114 | errs = Kaminari.paginate_array((1..30).to_a) |
115 | - 3.times { errs << Factory(:err).problem } | ||
116 | - 3.times { errs << Factory(:err, :problem => Factory(:problem, :resolved => true)).problem } | 115 | + 3.times { errs << Fabricate(:err).problem } |
116 | + 3.times { errs << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } | ||
117 | Problem.should_receive(:ordered).and_return( | 117 | Problem.should_receive(:ordered).and_return( |
118 | mock('proxy', :page => mock('other_proxy', :per => errs)) | 118 | mock('proxy', :page => mock('other_proxy', :per => errs)) |
119 | ) | 119 | ) |
@@ -124,10 +124,10 @@ describe ErrsController do | @@ -124,10 +124,10 @@ describe ErrsController do | ||
124 | 124 | ||
125 | context 'when logged in as a user' do | 125 | context 'when logged in as a user' do |
126 | it 'gets a paginated list of all errs for the users apps' do | 126 | it 'gets a paginated list of all errs for the users apps' do |
127 | - sign_in(user = Factory(:user)) | ||
128 | - unwatched_err = Factory(:problem) | ||
129 | - watched_unresolved_err = Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => false) | ||
130 | - watched_resolved_err = Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => true) | 127 | + sign_in(user = Fabricate(:user)) |
128 | + unwatched_err = Fabricate(:problem) | ||
129 | + watched_unresolved_err = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false) | ||
130 | + watched_resolved_err = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true) | ||
131 | get :all | 131 | get :all |
132 | assigns(:problems).should include(watched_resolved_err, watched_unresolved_err) | 132 | assigns(:problems).should include(watched_resolved_err, watched_unresolved_err) |
133 | assigns(:problems).should_not include(unwatched_err) | 133 | assigns(:problems).should_not include(unwatched_err) |
@@ -139,12 +139,12 @@ describe ErrsController do | @@ -139,12 +139,12 @@ describe ErrsController do | ||
139 | render_views | 139 | render_views |
140 | 140 | ||
141 | before do | 141 | before do |
142 | - 3.times { Factory(:notice, :err => err)} | 142 | + 3.times { Fabricate(:notice, :err => err)} |
143 | end | 143 | end |
144 | 144 | ||
145 | context 'when logged in as an admin' do | 145 | context 'when logged in as an admin' do |
146 | before do | 146 | before do |
147 | - sign_in Factory(:admin) | 147 | + sign_in Fabricate(:admin) |
148 | end | 148 | end |
149 | 149 | ||
150 | it "finds the app" do | 150 | it "finds the app" do |
@@ -166,23 +166,23 @@ describe ErrsController do | @@ -166,23 +166,23 @@ describe ErrsController do | ||
166 | let(:button_matcher) { match(/create issue/) } | 166 | let(:button_matcher) { match(/create issue/) } |
167 | 167 | ||
168 | it "should not exist for err's app without issue tracker" do | 168 | it "should not exist for err's app without issue tracker" do |
169 | - err = Factory :err | 169 | + err = Fabricate :err |
170 | get :show, :app_id => err.app.id, :id => err.problem.id | 170 | get :show, :app_id => err.app.id, :id => err.problem.id |
171 | 171 | ||
172 | response.body.should_not button_matcher | 172 | response.body.should_not button_matcher |
173 | end | 173 | end |
174 | 174 | ||
175 | it "should exist for err's app with issue tracker" do | 175 | it "should exist for err's app with issue tracker" do |
176 | - tracker = Factory(:lighthouse_tracker) | ||
177 | - err = Factory(:err, :problem => Factory(:problem, :app => tracker.app)) | 176 | + tracker = Fabricate(:lighthouse_tracker) |
177 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) | ||
178 | get :show, :app_id => err.app.id, :id => err.problem.id | 178 | get :show, :app_id => err.app.id, :id => err.problem.id |
179 | 179 | ||
180 | response.body.should button_matcher | 180 | response.body.should button_matcher |
181 | end | 181 | end |
182 | 182 | ||
183 | it "should not exist for err with issue_link" do | 183 | it "should not exist for err with issue_link" do |
184 | - tracker = Factory(:lighthouse_tracker) | ||
185 | - err = Factory(:err, :problem => Factory(:problem, :app => tracker.app, :issue_link => "http://some.host")) | 184 | + tracker = Fabricate(:lighthouse_tracker) |
185 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app, :issue_link => "http://some.host")) | ||
186 | get :show, :app_id => err.app.id, :id => err.problem.id | 186 | get :show, :app_id => err.app.id, :id => err.problem.id |
187 | 187 | ||
188 | response.body.should_not button_matcher | 188 | response.body.should_not button_matcher |
@@ -192,11 +192,11 @@ describe ErrsController do | @@ -192,11 +192,11 @@ describe ErrsController do | ||
192 | 192 | ||
193 | context 'when logged in as a user' do | 193 | context 'when logged in as a user' do |
194 | before do | 194 | before do |
195 | - sign_in(@user = Factory(:user)) | ||
196 | - @unwatched_err = Factory(:err) | ||
197 | - @watched_app = Factory(:app) | ||
198 | - @watcher = Factory(:user_watcher, :user => @user, :app => @watched_app) | ||
199 | - @watched_err = Factory(:err, :problem => Factory(:problem, :app => @watched_app)) | 195 | + sign_in(@user = Fabricate(:user)) |
196 | + @unwatched_err = Fabricate(:err) | ||
197 | + @watched_app = Fabricate(:app) | ||
198 | + @watcher = Fabricate(:user_watcher, :user => @user, :app => @watched_app) | ||
199 | + @watched_err = Fabricate(:err, :problem => Fabricate(:problem, :app => @watched_app)) | ||
200 | end | 200 | end |
201 | 201 | ||
202 | it 'finds the err if the user is watching the app' do | 202 | it 'finds the err if the user is watching the app' do |
@@ -214,9 +214,9 @@ describe ErrsController do | @@ -214,9 +214,9 @@ describe ErrsController do | ||
214 | 214 | ||
215 | describe "PUT /apps/:app_id/errs/:id/resolve" do | 215 | describe "PUT /apps/:app_id/errs/:id/resolve" do |
216 | before do | 216 | before do |
217 | - sign_in Factory(:admin) | 217 | + sign_in Fabricate(:admin) |
218 | 218 | ||
219 | - @problem = Factory(:err) | 219 | + @problem = Fabricate(:err) |
220 | App.stub(:find).with(@problem.app.id).and_return(@problem.app) | 220 | App.stub(:find).with(@problem.app.id).and_return(@problem.app) |
221 | @problem.app.problems.stub(:find).and_return(@problem.problem) | 221 | @problem.app.problems.stub(:find).and_return(@problem.problem) |
222 | @problem.problem.stub(:resolve!) | 222 | @problem.problem.stub(:resolve!) |
@@ -256,13 +256,13 @@ describe ErrsController do | @@ -256,13 +256,13 @@ describe ErrsController do | ||
256 | render_views | 256 | render_views |
257 | 257 | ||
258 | before(:each) do | 258 | before(:each) do |
259 | - sign_in Factory(:admin) | 259 | + sign_in Fabricate(:admin) |
260 | end | 260 | end |
261 | 261 | ||
262 | context "successful issue creation" do | 262 | context "successful issue creation" do |
263 | context "lighthouseapp tracker" do | 263 | context "lighthouseapp tracker" do |
264 | - let(:notice) { Factory :notice } | ||
265 | - let(:tracker) { Factory :lighthouse_tracker, :app => notice.app } | 264 | + let(:notice) { Fabricate :notice } |
265 | + let(:tracker) { Fabricate :lighthouse_tracker, :app => notice.app } | ||
266 | let(:problem) { notice.problem } | 266 | let(:problem) { notice.problem } |
267 | 267 | ||
268 | before(:each) do | 268 | before(:each) do |
@@ -283,7 +283,7 @@ describe ErrsController do | @@ -283,7 +283,7 @@ describe ErrsController do | ||
283 | end | 283 | end |
284 | 284 | ||
285 | context "absent issue tracker" do | 285 | context "absent issue tracker" do |
286 | - let(:problem) { Factory :problem } | 286 | + let(:problem) { Fabricate :problem } |
287 | 287 | ||
288 | before(:each) do | 288 | before(:each) do |
289 | post :create_issue, :app_id => problem.app.id, :id => problem.id | 289 | post :create_issue, :app_id => problem.app.id, :id => problem.id |
@@ -300,8 +300,8 @@ describe ErrsController do | @@ -300,8 +300,8 @@ describe ErrsController do | ||
300 | 300 | ||
301 | context "error during request to a tracker" do | 301 | context "error during request to a tracker" do |
302 | context "lighthouseapp tracker" do | 302 | context "lighthouseapp tracker" do |
303 | - let(:tracker) { Factory :lighthouse_tracker } | ||
304 | - let(:err) { Factory(:err, :problem => Factory(:problem, :app => tracker.app)) } | 303 | + let(:tracker) { Fabricate :lighthouse_tracker } |
304 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) } | ||
305 | 305 | ||
306 | before(:each) do | 306 | before(:each) do |
307 | stub_request(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml").to_return(:status => 500) | 307 | stub_request(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml").to_return(:status => 500) |
@@ -322,11 +322,11 @@ describe ErrsController do | @@ -322,11 +322,11 @@ describe ErrsController do | ||
322 | 322 | ||
323 | describe "DELETE /apps/:app_id/errs/:id/unlink_issue" do | 323 | describe "DELETE /apps/:app_id/errs/:id/unlink_issue" do |
324 | before(:each) do | 324 | before(:each) do |
325 | - sign_in Factory(:admin) | 325 | + sign_in Fabricate(:admin) |
326 | end | 326 | end |
327 | 327 | ||
328 | context "err with issue" do | 328 | context "err with issue" do |
329 | - let(:err) { Factory(:err, :problem => Factory(:problem, :issue_link => "http://some.host")) } | 329 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :issue_link => "http://some.host")) } |
330 | 330 | ||
331 | before(:each) do | 331 | before(:each) do |
332 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 332 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id |
@@ -343,7 +343,7 @@ describe ErrsController do | @@ -343,7 +343,7 @@ describe ErrsController do | ||
343 | end | 343 | end |
344 | 344 | ||
345 | context "err without issue" do | 345 | context "err without issue" do |
346 | - let(:err) { Factory :err } | 346 | + let(:err) { Fabricate :err } |
347 | 347 | ||
348 | before(:each) do | 348 | before(:each) do |
349 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 349 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id |
@@ -361,12 +361,12 @@ describe ErrsController do | @@ -361,12 +361,12 @@ describe ErrsController do | ||
361 | render_views | 361 | render_views |
362 | 362 | ||
363 | before(:each) do | 363 | before(:each) do |
364 | - sign_in Factory(:admin) | 364 | + sign_in Fabricate(:admin) |
365 | end | 365 | end |
366 | 366 | ||
367 | context "successful comment creation" do | 367 | context "successful comment creation" do |
368 | - let(:problem) { Factory(:problem) } | ||
369 | - let(:user) { Factory(:user) } | 368 | + let(:problem) { Fabricate(:problem) } |
369 | + let(:user) { Fabricate(:user) } | ||
370 | 370 | ||
371 | before(:each) do | 371 | before(:each) do |
372 | post :create_comment, :app_id => problem.app.id, :id => problem.id, | 372 | post :create_comment, :app_id => problem.app.id, :id => problem.id, |
@@ -388,15 +388,15 @@ describe ErrsController do | @@ -388,15 +388,15 @@ describe ErrsController do | ||
388 | render_views | 388 | render_views |
389 | 389 | ||
390 | before(:each) do | 390 | before(:each) do |
391 | - sign_in Factory(:admin) | 391 | + sign_in Fabricate(:admin) |
392 | end | 392 | end |
393 | 393 | ||
394 | context "successful comment deletion" do | 394 | context "successful comment deletion" do |
395 | - let(:problem) { Factory(:problem_with_comments) } | ||
396 | - let(:comment) { problem.comments.first } | 395 | + let(:problem) { Fabricate(:problem_with_comments) } |
396 | + let(:comment) { problem.reload.comments.first } | ||
397 | 397 | ||
398 | before(:each) do | 398 | before(:each) do |
399 | - delete :destroy_comment, :app_id => problem.app.id, :id => problem.id, :comment_id => comment.id | 399 | + delete :destroy_comment, :app_id => problem.app.id, :id => problem.id, :comment_id => comment.id.to_s |
400 | problem.reload | 400 | problem.reload |
401 | end | 401 | end |
402 | 402 | ||
@@ -412,9 +412,9 @@ describe ErrsController do | @@ -412,9 +412,9 @@ describe ErrsController do | ||
412 | 412 | ||
413 | describe "Bulk Actions" do | 413 | describe "Bulk Actions" do |
414 | before(:each) do | 414 | before(:each) do |
415 | - sign_in Factory(:admin) | ||
416 | - @problem1 = Factory(:err, :problem => Factory(:problem, :resolved => true)).problem | ||
417 | - @problem2 = Factory(:err, :problem => Factory(:problem, :resolved => false)).problem | 415 | + sign_in Fabricate(:admin) |
416 | + @problem1 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem | ||
417 | + @problem2 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => false)).problem | ||
418 | end | 418 | end |
419 | 419 | ||
420 | it "should apply to multiple problems" do | 420 | it "should apply to multiple problems" do |