Commit b483a6af718d06009d47dc88e7226d6520420a1e
1 parent
7f0137d2
Exists in
master
and in
1 other branch
Now that's what I call a refactor, Vol 2. Glad I'm not getting paid per LOC. Wai…
…t, I'm not getting paid at all!
Showing
1 changed file
with
18 additions
and
147 deletions
Show diff stats
spec/controllers/apps_controller_spec.rb
... | ... | @@ -273,163 +273,34 @@ describe AppsController do |
273 | 273 | end |
274 | 274 | end |
275 | 275 | |
276 | - context "lighthouseapp" do | |
277 | - it "should save tracker params" do | |
278 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
279 | - :type => 'LighthouseTracker', :project_id => '1234', :api_token => '123123', :account => 'myapp' | |
280 | - } } | |
281 | - @app.reload | |
282 | - | |
283 | - tracker = @app.issue_tracker | |
284 | - tracker.should be_a(LighthouseTracker) | |
285 | - tracker.project_id.should == '1234' | |
286 | - tracker.api_token.should == '123123' | |
287 | - tracker.account.should == 'myapp' | |
288 | - end | |
289 | - | |
290 | - it "should show validation notice when sufficient params are not present" do | |
291 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
292 | - :type => 'LighthouseTracker', :project_id => '1234', :api_token => '123123' | |
293 | - } } | |
294 | - @app.reload | |
295 | - | |
296 | - @app.issue_tracker_configured?.should == false | |
297 | - response.body.should match(/You must specify your Lighthouseapp account, API token and Project ID/) | |
298 | - end | |
299 | - end | |
300 | - | |
301 | - context "redmine" do | |
302 | - it "should save tracker params" do | |
303 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
304 | - :type => 'RedmineTracker', :project_id => '1234', :api_token => '123123', :account => 'http://myapp.com' | |
305 | - } } | |
306 | - @app.reload | |
307 | - | |
308 | - tracker = @app.issue_tracker | |
309 | - tracker.should be_a(RedmineTracker) | |
310 | - tracker.project_id.should == '1234' | |
311 | - tracker.api_token.should == '123123' | |
312 | - tracker.account.should == 'http://myapp.com' | |
313 | - end | |
314 | - | |
315 | - it "should show validation notice when sufficient params are not present" do | |
316 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
317 | - :type => 'RedmineTracker', :project_id => '1234', :api_token => '123123' | |
318 | - } } | |
319 | - @app.reload | |
320 | - | |
321 | - @app.issue_tracker_configured?.should == false | |
322 | - response.body.should match(/You must specify your Redmine URL, API token and Project ID/) | |
323 | - end | |
324 | - end | |
325 | - | |
326 | - context "pivotal" do | |
327 | - it "should save tracker params" do | |
328 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
329 | - :type => 'PivotalLabsTracker', :project_id => '1234', :api_token => '123123' } } | |
330 | - @app.reload | |
331 | - | |
332 | - tracker = @app.issue_tracker | |
333 | - tracker.should be_a(PivotalLabsTracker) | |
334 | - tracker.project_id.should == '1234' | |
335 | - tracker.api_token.should == '123123' | |
336 | - end | |
337 | - | |
338 | - it "should show validation notice when sufficient params are not present" do | |
339 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
340 | - :type => 'PivotalLabsTracker', :project_id => '1234' } } | |
341 | - @app.reload | |
342 | - | |
343 | - @app.issue_tracker_configured?.should == false | |
344 | - response.body.should match(/You must specify your Pivotal Tracker API token and Project ID/) | |
345 | - end | |
346 | - end | |
276 | + IssueTracker.subclasses.each do |tracker_klass| | |
277 | + context tracker_klass do | |
278 | + it "should save tracker params" do | |
279 | + params = tracker_klass::RequiredFields.inject({}){|hash,f| hash[f] = "test_value"; hash } | |
280 | + params['ticket_properties'] = "card_type = defect" if tracker_klass == MingleTracker | |
281 | + params['type'] = tracker_klass.to_s | |
282 | + put :update, :id => @app.id, :app => {:issue_tracker_attributes => params} | |
347 | 283 | |
348 | - context "fogbugz" do | |
349 | - context 'with correct params' do | |
350 | - before do | |
351 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
352 | - :type => 'FogbugzTracker', :account => 'abc', :project_id => 'Service - Peon', :username => '1234', :password => '123123' } } | |
353 | 284 | @app.reload |
285 | + tracker = @app.issue_tracker | |
286 | + tracker.should be_a(tracker_klass) | |
287 | + tracker_klass::RequiredFields.each do |required| | |
288 | + tracker.send(required.to_sym).should == 'test_value' | |
289 | + end | |
354 | 290 | end |
355 | 291 | |
356 | - subject {@app.issue_tracker} | |
357 | - its(:type) {should == "FogbugzTracker"} | |
358 | - its(:account) {should == 'abc'} | |
359 | - its(:project_id) {should == 'Service - Peon'} | |
360 | - its(:username) {should == '1234'} | |
361 | - its(:password) {should == '123123'} | |
362 | - end | |
292 | + it "should show validation notice when sufficient params are not present" do | |
293 | + # Leave out one required param | |
294 | + params = tracker_klass::RequiredFields[1..-1].inject({}){|hash,f| hash[f] = "test_value"; hash } | |
295 | + params['type'] = tracker_klass.to_s | |
296 | + put :update, :id => @app.id, :app => {:issue_tracker_attributes => params} | |
363 | 297 | |
364 | - context 'insufficient params' do | |
365 | - it 'shows validation notice' do | |
366 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
367 | - :type => 'FogbugzTracker', :project_id => '1234' } } | |
368 | 298 | @app.reload |
369 | - | |
370 | 299 | @app.issue_tracker_configured?.should == false |
371 | - response.body.should match(/You must specify your FogBugz Area Name, FogBugz URL, Username, and Password/) | |
372 | - end | |
373 | - end | |
374 | - end | |
375 | - | |
376 | - context "mingle" do | |
377 | - context 'with correct params' do | |
378 | - before do | |
379 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
380 | - :type => 'MingleTracker', :project_id => 'test', :account => 'http://mingle.example.com', | |
381 | - :username => '1234', :password => '123123', :ticket_properties => "card_type = Defect" | |
382 | - } } | |
383 | - @app.reload | |
384 | - end | |
385 | - | |
386 | - subject {@app.issue_tracker} | |
387 | - its(:type) {should == "MingleTracker"} | |
388 | - its(:project_id) {should == 'test'} | |
389 | - its(:username) {should == '1234'} | |
390 | - its(:password) {should == '123123'} | |
391 | - end | |
392 | - | |
393 | - it "should show validation notice when sufficient params are not present" do | |
394 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
395 | - :type => 'MingleTracker', :project_id => 'test', :account => 'http://mingle.example.com', | |
396 | - :username => '1234', :password => '1234', :ticket_properties => "cards_type = Defect" | |
397 | - } } | |
398 | - @app.reload | |
399 | - | |
400 | - @app.issue_tracker_configured?.should == false | |
401 | - response.body.should match(/You must specify your Mingle URL, Project ID, Card Type \(in default card properties\), Sign-in name, and Password/) | |
402 | - end | |
403 | - end | |
404 | - | |
405 | - context "github issues" do | |
406 | - context 'with correct params' do | |
407 | - before do | |
408 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
409 | - :type => 'GithubTracker', :project_id => 'test', :username => 'user', | |
410 | - :api_token => '123123' | |
411 | - } } | |
412 | - @app.reload | |
300 | + response.body.should match(/You must specify your/) | |
413 | 301 | end |
414 | - | |
415 | - subject {@app.issue_tracker} | |
416 | - its(:type) {should == "GithubTracker"} | |
417 | - its(:project_id) {should == 'test'} | |
418 | - its(:username) {should == 'user'} | |
419 | - its(:api_token) {should == '123123'} | |
420 | - end | |
421 | - | |
422 | - it "should show validation notice when sufficient params are not present" do | |
423 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | |
424 | - :type => 'GithubTracker', :project_id => 'test', :username => 'user' | |
425 | - } } | |
426 | - @app.reload | |
427 | - | |
428 | - @app.issue_tracker_configured?.should == false | |
429 | - response.body.should match(/You must specify your Github repository, username and API token/) | |
430 | 302 | end |
431 | 303 | end |
432 | - | |
433 | 304 | end |
434 | 305 | end |
435 | 306 | ... | ... |