Commit 6845e153a95cb945031838287d548c785223c3be

Authored by Joenio Costa
1 parent 1a7d1285

Saving some time optimizing functional tests

test/functional/account_controller_test.rb
@@ -49,7 +49,7 @@ class AccountControllerTest < Test::Unit::TestCase @@ -49,7 +49,7 @@ class AccountControllerTest < Test::Unit::TestCase
49 end 49 end
50 50
51 should 'redirect to where was when login on other environment' do 51 should 'redirect to where was when login on other environment' do
52 - e = Environment.create!(:name => 'other_environment') 52 + e = fast_create(Environment, :name => 'other_environment')
53 e.domains << Domain.new(:name => 'other.environment') 53 e.domains << Domain.new(:name => 'other.environment')
54 e.save! 54 e.save!
55 u = create_user('test_user', :environment => e).person 55 u = create_user('test_user', :environment => e).person
@@ -338,7 +338,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -338,7 +338,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
338 person = create_user('mylogin').person 338 person = create_user('mylogin').person
339 login_as(person.identifier) 339 login_as(person.identifier)
340 340
341 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :cnpj => '0'*14, :enabled => true) 341 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => true)
  342 + ent.update_attribute(:cnpj, '0'*14)
342 task = mock 343 task = mock
343 task.expects(:enterprise).returns(ent).at_least_once 344 task.expects(:enterprise).returns(ent).at_least_once
344 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once 345 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once
@@ -352,7 +353,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -352,7 +353,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
352 person = create_user('mylogin').person 353 person = create_user('mylogin').person
353 login_as(person.identifier) 354 login_as(person.identifier)
354 355
355 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent') 356 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent')
356 357
357 task = mock 358 task = mock
358 task.expects(:enterprise).returns(ent).at_least_once 359 task.expects(:enterprise).returns(ent).at_least_once
@@ -367,7 +368,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -367,7 +368,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
367 person = create_user('mylogin').person 368 person = create_user('mylogin').person
368 login_as(person.identifier) 369 login_as(person.identifier)
369 370
370 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :enabled => false) 371 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
371 372
372 task = mock 373 task = mock
373 task.expects(:enterprise).returns(ent).at_least_once 374 task.expects(:enterprise).returns(ent).at_least_once
@@ -382,7 +383,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -382,7 +383,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
382 person = create_user('mylogin').person 383 person = create_user('mylogin').person
383 login_as(person.identifier) 384 login_as(person.identifier)
384 385
385 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 386 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  387 + ent.update_attribute(:foundation_year, 1998)
386 388
387 task = mock 389 task = mock
388 task.expects(:enterprise).returns(ent).at_least_once 390 task.expects(:enterprise).returns(ent).at_least_once
@@ -397,7 +399,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -397,7 +399,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
397 person = create_user('mylogin').person 399 person = create_user('mylogin').person
398 login_as(person.identifier) 400 login_as(person.identifier)
399 401
400 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :cnpj => '0'*14, :enabled => false) 402 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  403 + ent.update_attribute(:cnpj, '0'*14)
401 404
402 task = mock 405 task = mock
403 task.expects(:enterprise).returns(ent).at_least_once 406 task.expects(:enterprise).returns(ent).at_least_once
@@ -412,7 +415,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -412,7 +415,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
412 person = create_user('mylogin').person 415 person = create_user('mylogin').person
413 login_as(person.identifier) 416 login_as(person.identifier)
414 417
415 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => '1998', :enabled => false) 418 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  419 + ent.update_attribute(:foundation_year, 1998)
416 ent.block 420 ent.block
417 421
418 task = mock 422 task = mock
@@ -428,7 +432,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -428,7 +432,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
428 person = create_user('mylogin').person 432 person = create_user('mylogin').person
429 login_as(person.identifier) 433 login_as(person.identifier)
430 434
431 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 435 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  436 + ent.update_attribute(:foundation_year, 1998)
432 437
433 task = mock 438 task = mock
434 task.expects(:enterprise).returns(ent).at_least_once 439 task.expects(:enterprise).returns(ent).at_least_once
@@ -440,7 +445,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -440,7 +445,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
440 end 445 end
441 446
442 should 'require login for accept terms' do 447 should 'require login for accept terms' do
443 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 448 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  449 + ent.update_attribute(:foundation_year, 1998)
444 450
445 task = mock 451 task = mock
446 task.expects(:enterprise).returns(ent).never 452 task.expects(:enterprise).returns(ent).never
@@ -455,7 +461,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -455,7 +461,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
455 person = create_user('mylogin').person 461 person = create_user('mylogin').person
456 login_as(person.identifier) 462 login_as(person.identifier)
457 463
458 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 464 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  465 + ent.update_attribute(:foundation_year, 1998)
459 466
460 task = mock 467 task = mock
461 task.expects(:enterprise).returns(ent).at_least_once 468 task.expects(:enterprise).returns(ent).at_least_once
@@ -478,7 +485,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -478,7 +485,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
478 env.terms_of_enterprise_use = 'Some terms' 485 env.terms_of_enterprise_use = 'Some terms'
479 env.save! 486 env.save!
480 487
481 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 488 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  489 + ent.update_attribute(:foundation_year, 1998)
482 task = EnterpriseActivation.create!(:enterprise => ent) 490 task = EnterpriseActivation.create!(:enterprise => ent)
483 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once 491 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once
484 492
@@ -492,7 +500,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -492,7 +500,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
492 person = create_user('mylogin').person 500 person = create_user('mylogin').person
493 login_as(person.identifier) 501 login_as(person.identifier)
494 502
495 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 503 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  504 + ent.update_attribute(:foundation_year, 1998)
496 ent.block 505 ent.block
497 ent.save 506 ent.save
498 507
@@ -509,7 +518,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -509,7 +518,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
509 env = Environment.default 518 env = Environment.default
510 env.terms_of_use = 'some terms' 519 env.terms_of_use = 'some terms'
511 env.save! 520 env.save!
512 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 521 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  522 + ent.update_attribute(:foundation_year, 1998)
513 task = EnterpriseActivation.create!(:enterprise => ent) 523 task = EnterpriseActivation.create!(:enterprise => ent)
514 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).never 524 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).never
515 525
@@ -519,7 +529,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -519,7 +529,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
519 end 529 end
520 530
521 should 'not activate if user does not accept terms' do 531 should 'not activate if user does not accept terms' do
522 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 532 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  533 + ent.update_attribute(:foundation_year, 1998)
523 p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person 534 p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person
524 login_as(p.identifier) 535 login_as(p.identifier)
525 536
@@ -534,7 +545,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -534,7 +545,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
534 end 545 end
535 546
536 should 'activate enterprise and make logged user admin' do 547 should 'activate enterprise and make logged user admin' do
537 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 548 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  549 + ent.update_attribute(:foundation_year, 1998)
538 p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person 550 p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person
539 login_as(p.identifier) 551 login_as(p.identifier)
540 552
@@ -555,7 +567,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -555,7 +567,8 @@ class AccountControllerTest &lt; Test::Unit::TestCase
555 env = Environment.default 567 env = Environment.default
556 env.terms_of_use = 'some terms' 568 env.terms_of_use = 'some terms'
557 env.save! 569 env.save!
558 - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) 570 + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false)
  571 + ent.update_attribute(:foundation_year, 1998)
559 task = EnterpriseActivation.create!(:enterprise => ent) 572 task = EnterpriseActivation.create!(:enterprise => ent)
560 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once 573 EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once
561 574
@@ -583,7 +596,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -583,7 +596,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
583 template.boxes << Box.new 596 template.boxes << Box.new
584 template.boxes[0].blocks << Block.new 597 template.boxes[0].blocks << Block.new
585 template.save! 598 template.save!
586 - env = Environment.create!(:name => 'test_env') 599 + env = fast_create(Environment, :name => 'test_env')
587 env.settings[:person_template_id] = template.id 600 env.settings[:person_template_id] = template.id
588 env.save! 601 env.save!
589 602
@@ -658,7 +671,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -658,7 +671,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
658 end 671 end
659 672
660 should 'check_url is available on environment' do 673 should 'check_url is available on environment' do
661 - env = Environment.create(:name => 'Environment test') 674 + env = fast_create(Environment, :name => 'Environment test')
662 @controller.expects(:environment).returns(env).at_least_once 675 @controller.expects(:environment).returns(env).at_least_once
663 profile = create_user('mylogin').person 676 profile = create_user('mylogin').person
664 get :check_url, :identifier => 'mylogin' 677 get :check_url, :identifier => 'mylogin'
test/functional/admin_panel_controller_test.rb
@@ -24,7 +24,7 @@ class AdminPanelControllerTest &lt; Test::Unit::TestCase @@ -24,7 +24,7 @@ class AdminPanelControllerTest &lt; Test::Unit::TestCase
24 end 24 end
25 25
26 should 'manage the correct environment' do 26 should 'manage the correct environment' do
27 - current = Environment.create!(:name => 'test environment', :is_default => false) 27 + current = fast_create(Environment, :name => 'test environment', :is_default => false)
28 current.domains.create!(:name => 'example.com') 28 current.domains.create!(:name => 'example.com')
29 29
30 @request.expects(:host).returns('example.com').at_least_once 30 @request.expects(:host).returns('example.com').at_least_once
@@ -241,7 +241,7 @@ class AdminPanelControllerTest &lt; Test::Unit::TestCase @@ -241,7 +241,7 @@ class AdminPanelControllerTest &lt; Test::Unit::TestCase
241 should 'not have a portal community from other environment' do 241 should 'not have a portal community from other environment' do
242 e = Environment.default 242 e = Environment.default
243 @controller.stubs(:environment).returns(e) 243 @controller.stubs(:environment).returns(e)
244 - other_e = Environment.create!(:name => 'other environment') 244 + other_e = fast_create(Environment, :name => 'other environment')
245 c = Community.create!(:name => 'portal community', :environment => other_e) 245 c = Community.create!(:name => 'portal community', :environment => other_e)
246 246
247 post :set_portal_community, :portal_community_identifier => c.identifier 247 post :set_portal_community, :portal_community_identifier => c.identifier
test/functional/application_controller_test.rb
@@ -49,7 +49,7 @@ class ApplicationControllerTest &lt; Test::Unit::TestCase @@ -49,7 +49,7 @@ class ApplicationControllerTest &lt; Test::Unit::TestCase
49 Environment.stubs(:default).returns(default) 49 Environment.stubs(:default).returns(default)
50 default.stubs(:top_url).returns('http://default.com/') 50 default.stubs(:top_url).returns('http://default.com/')
51 51
52 - current = Environment.create!(:name => 'test environment') 52 + current = fast_create(Environment, :name => 'test environment')
53 current.domains.create!(:name => 'example.com') 53 current.domains.create!(:name => 'example.com')
54 54
55 @request.expects(:host).returns('example.com').at_least_once 55 @request.expects(:host).returns('example.com').at_least_once
@@ -387,7 +387,7 @@ class ApplicationControllerTest &lt; Test::Unit::TestCase @@ -387,7 +387,7 @@ class ApplicationControllerTest &lt; Test::Unit::TestCase
387 387
388 should 'display menu links for my environment when logged in other environment' do 388 should 'display menu links for my environment when logged in other environment' do
389 @controller.stubs(:get_layout).returns('application') 389 @controller.stubs(:get_layout).returns('application')
390 - e = Environment.create!(:name => 'other_environment') 390 + e = fast_create(Environment, :name => 'other_environment')
391 e.domains << Domain.new(:name => 'other.environment') 391 e.domains << Domain.new(:name => 'other.environment')
392 e.save! 392 e.save!
393 393
test/functional/catalog_controller_test.rb
@@ -10,12 +10,12 @@ class CatalogControllerTest &lt; Test::Unit::TestCase @@ -10,12 +10,12 @@ class CatalogControllerTest &lt; Test::Unit::TestCase
10 @request = ActionController::TestRequest.new 10 @request = ActionController::TestRequest.new
11 @response = ActionController::TestResponse.new 11 @response = ActionController::TestResponse.new
12 12
13 - @enterprise = Enterprise.create!(:name => 'My enterprise', :identifier => 'testent') 13 + @enterprise = fast_create(Enterprise, :name => 'My enterprise', :identifier => 'testent')
14 end 14 end
15 attr_accessor :enterprise 15 attr_accessor :enterprise
16 16
17 def test_local_files_reference 17 def test_local_files_reference
18 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 18 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
19 assert_local_files_reference :get, :index, :profile => ent.identifier 19 assert_local_files_reference :get, :index, :profile => ent.identifier
20 end 20 end
21 21
@@ -35,13 +35,13 @@ class CatalogControllerTest &lt; Test::Unit::TestCase @@ -35,13 +35,13 @@ class CatalogControllerTest &lt; Test::Unit::TestCase
35 end 35 end
36 36
37 should 'list products of enterprise' do 37 should 'list products of enterprise' do
38 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 38 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
39 get :index, :profile => ent.identifier 39 get :index, :profile => ent.identifier
40 assert_kind_of Array, assigns(:products) 40 assert_kind_of Array, assigns(:products)
41 end 41 end
42 42
43 should 'show product of enterprise' do 43 should 'show product of enterprise' do
44 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 44 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
45 prod = ent.products.create!(:name => 'Product test') 45 prod = ent.products.create!(:name => 'Product test')
46 get :show, :id => prod.id, :profile => ent.identifier 46 get :show, :id => prod.id, :profile => ent.identifier
47 assert_tag :tag => 'h1', :content => /#{prod.name}/ 47 assert_tag :tag => 'h1', :content => /#{prod.name}/
@@ -70,28 +70,28 @@ class CatalogControllerTest &lt; Test::Unit::TestCase @@ -70,28 +70,28 @@ class CatalogControllerTest &lt; Test::Unit::TestCase
70 env = Environment.default 70 env = Environment.default
71 env.enable('disable_products_for_enterprises') 71 env.enable('disable_products_for_enterprises')
72 env.save! 72 env.save!
73 - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) 73 + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id)
74 get :index, :profile => ent.identifier 74 get :index, :profile => ent.identifier
75 75
76 assert_redirected_to :controller => 'profile', :action => 'index', :profile => ent.identifier 76 assert_redirected_to :controller => 'profile', :action => 'index', :profile => ent.identifier
77 end 77 end
78 78
79 should 'not show product price when listing products if not informed' do 79 should 'not show product price when listing products if not informed' do
80 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 80 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
81 prod = ent.products.create!(:name => 'Product test') 81 prod = ent.products.create!(:name => 'Product test')
82 get :index, :profile => ent.identifier 82 get :index, :profile => ent.identifier
83 assert_no_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ 83 assert_no_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/
84 end 84 end
85 85
86 should 'show product price when listing products if informed' do 86 should 'show product price when listing products if informed' do
87 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 87 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
88 prod = ent.products.create!(:name => 'Product test', :price => 50.00) 88 prod = ent.products.create!(:name => 'Product test', :price => 50.00)
89 get :index, :profile => ent.identifier 89 get :index, :profile => ent.identifier
90 assert_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ 90 assert_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/
91 end 91 end
92 92
93 should 'not show product price when showing product if not informed' do 93 should 'not show product price when showing product if not informed' do
94 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 94 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
95 prod = ent.products.create!(:name => 'Product test') 95 prod = ent.products.create!(:name => 'Product test')
96 get :show, :id => prod.id, :profile => ent.identifier 96 get :show, :id => prod.id, :profile => ent.identifier
97 97
@@ -99,7 +99,7 @@ class CatalogControllerTest &lt; Test::Unit::TestCase @@ -99,7 +99,7 @@ class CatalogControllerTest &lt; Test::Unit::TestCase
99 end 99 end
100 100
101 should 'show product price when showing product if informed' do 101 should 'show product price when showing product if informed' do
102 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 102 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
103 prod = ent.products.create!(:name => 'Product test', :price => 50.00) 103 prod = ent.products.create!(:name => 'Product test', :price => 50.00)
104 get :show, :id => prod.id, :profile => ent.identifier 104 get :show, :id => prod.id, :profile => ent.identifier
105 105
@@ -107,7 +107,7 @@ class CatalogControllerTest &lt; Test::Unit::TestCase @@ -107,7 +107,7 @@ class CatalogControllerTest &lt; Test::Unit::TestCase
107 end 107 end
108 108
109 should 'not crash on index when product has no product_category and enterprise not enabled' do 109 should 'not crash on index when product has no product_category and enterprise not enabled' do
110 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1', :enabled => false) 110 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1', :enabled => false)
111 prod = ent.products.create!(:name => 'Product test', :price => 50.00, :product_category => nil) 111 prod = ent.products.create!(:name => 'Product test', :price => 50.00, :product_category => nil)
112 assert_nothing_raised do 112 assert_nothing_raised do
113 get :index, :profile => ent.identifier 113 get :index, :profile => ent.identifier
test/functional/categories_controller_test.rb
@@ -12,7 +12,7 @@ class CategoriesControllerTest &lt; Test::Unit::TestCase @@ -12,7 +12,7 @@ class CategoriesControllerTest &lt; Test::Unit::TestCase
12 @request.stubs(:ssl?).returns(true) 12 @request.stubs(:ssl?).returns(true)
13 @response = ActionController::TestResponse.new 13 @response = ActionController::TestResponse.new
14 14
15 - @env = Environment.create!(:name => "My test environment") 15 + @env = fast_create(Environment, :name => "My test environment")
16 Environment.stubs(:default).returns(env) 16 Environment.stubs(:default).returns(env)
17 assert (@cat1 = env.categories.create(:name => 'a test category')) 17 assert (@cat1 = env.categories.create(:name => 'a test category'))
18 assert (@cat1 = env.categories.create(:name => 'another category')) 18 assert (@cat1 = env.categories.create(:name => 'another category'))
test/functional/cms_controller_test.rb
@@ -583,7 +583,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -583,7 +583,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
583 end 583 end
584 584
585 should 'make enterprise homepage available to enterprises' do 585 should 'make enterprise homepage available to enterprises' do
586 - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) 586 + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent'))
587 assert_includes @controller.available_article_types, EnterpriseHomepage 587 assert_includes @controller.available_article_types, EnterpriseHomepage
588 end 588 end
589 589
@@ -786,7 +786,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -786,7 +786,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
786 end 786 end
787 787
788 should 'not offer folder to blog articles' do 788 should 'not offer folder to blog articles' do
789 - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) 789 + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent'))
790 blog = Blog.create!(:name => 'Blog for test', :profile => profile) 790 blog = Blog.create!(:name => 'Blog for test', :profile => profile)
791 @controller.stubs(:params).returns({ :parent_id => blog.id }) 791 @controller.stubs(:params).returns({ :parent_id => blog.id })
792 792
@@ -794,7 +794,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -794,7 +794,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
794 end 794 end
795 795
796 should 'not offer rssfeed to blog articles' do 796 should 'not offer rssfeed to blog articles' do
797 - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) 797 + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent'))
798 blog = Blog.create!(:name => 'Blog for test', :profile => profile) 798 blog = Blog.create!(:name => 'Blog for test', :profile => profile)
799 @controller.stubs(:params).returns({ :parent_id => blog.id }) 799 @controller.stubs(:params).returns({ :parent_id => blog.id })
800 800
test/functional/contact_controller_test.rb
@@ -14,7 +14,7 @@ class ContactControllerTest &lt; Test::Unit::TestCase @@ -14,7 +14,7 @@ class ContactControllerTest &lt; Test::Unit::TestCase
14 @response = ActionController::TestResponse.new 14 @response = ActionController::TestResponse.new
15 15
16 @profile = create_user('contact_test_user').person 16 @profile = create_user('contact_test_user').person
17 - @enterprise = Enterprise.create!(:identifier => 'contact_test_enterprise', :name => 'Test contact enteprise') 17 + @enterprise = fast_create(Enterprise, :identifier => 'contact_test_enterprise', :name => 'Test contact enteprise')
18 18
19 login_as('contact_test_user') 19 login_as('contact_test_user')
20 end 20 end
test/functional/content_viewer_controller_test.rb
@@ -360,7 +360,7 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase @@ -360,7 +360,7 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
360 360
361 should 'not show message for disabled enterprise if there is a block for it' do 361 should 'not show message for disabled enterprise if there is a block for it' do
362 login_as(@profile.identifier) 362 login_as(@profile.identifier)
363 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) 363 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
364 ent.boxes << Box.new 364 ent.boxes << Box.new
365 ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new 365 ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new
366 ent.save 366 ent.save
@@ -595,7 +595,7 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase @@ -595,7 +595,7 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
595 should 'not show a profile in an environment that is not its home environment' do 595 should 'not show a profile in an environment that is not its home environment' do
596 p = Profile.create!(:identifier => 'mytestprofile', :name => 'My test profile', :environment => Environment.default) 596 p = Profile.create!(:identifier => 'mytestprofile', :name => 'My test profile', :environment => Environment.default)
597 597
598 - current = Environment.create!(:name => 'test environment') 598 + current = fast_create(Environment, :name => 'test environment')
599 current.domains.create!(:name => 'example.com') 599 current.domains.create!(:name => 'example.com')
600 uses_host 'www.example.com' 600 uses_host 'www.example.com'
601 601
test/functional/favorite_enterprises_controller_test.rb
@@ -14,7 +14,7 @@ class FavoriteEnterprisesControllerTest &lt; Test::Unit::TestCase @@ -14,7 +14,7 @@ class FavoriteEnterprisesControllerTest &lt; Test::Unit::TestCase
14 @response = ActionController::TestResponse.new 14 @response = ActionController::TestResponse.new
15 15
16 self.profile = create_user('testuser').person 16 self.profile = create_user('testuser').person
17 - self.favorite_enterprise = Enterprise.create!(:name => 'the_enterprise', :identifier => 'the_enterprise') 17 + self.favorite_enterprise = fast_create(Enterprise, :name => 'the_enterprise', :identifier => 'the_enterprise')
18 login_as ('testuser') 18 login_as ('testuser')
19 end 19 end
20 attr_accessor :profile, :favorite_enterprise 20 attr_accessor :profile, :favorite_enterprise
test/functional/manage_products_controller_test.rb
@@ -11,7 +11,7 @@ class ManageProductsControllerTest &lt; Test::Unit::TestCase @@ -11,7 +11,7 @@ class ManageProductsControllerTest &lt; Test::Unit::TestCase
11 @request = ActionController::TestRequest.new 11 @request = ActionController::TestRequest.new
12 @request.stubs(:ssl?).returns(true) 12 @request.stubs(:ssl?).returns(true)
13 @response = ActionController::TestResponse.new 13 @response = ActionController::TestResponse.new
14 - @enterprise = Enterprise.create(:name => 'teste', :identifier => 'test_ent') 14 + @enterprise = fast_create(Enterprise, :name => 'teste', :identifier => 'test_ent')
15 @user = create_user_with_permission('test_user', 'manage_products', @enterprise) 15 @user = create_user_with_permission('test_user', 'manage_products', @enterprise)
16 login_as :test_user 16 login_as :test_user
17 end 17 end
test/functional/memberships_controller_test.rb
@@ -99,7 +99,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase @@ -99,7 +99,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase
99 end 99 end
100 100
101 should 'not show description to enterprises on list' do 101 should 'not show description to enterprises on list' do
102 - enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise') 102 + enterprise = fast_create(Enterprise, :identifier => 'enterprise-test', :name => 'my test enterprise')
103 enterprise.add_member(profile) 103 enterprise.add_member(profile)
104 get :index, :profile => profile.identifier 104 get :index, :profile => profile.identifier
105 assert_no_tag :tag => 'li', :content => /Description:/ 105 assert_no_tag :tag => 'li', :content => /Description:/
@@ -130,7 +130,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase @@ -130,7 +130,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase
130 130
131 should 'display destroy link only to communities' do 131 should 'display destroy link only to communities' do
132 community = Community.create!(:name => 'A community to destroy') 132 community = Community.create!(:name => 'A community to destroy')
133 - enterprise = Enterprise.create!(:name => 'A enterprise test', :identifier => 'enterprise-test') 133 + enterprise = fast_create(Enterprise, :name => 'A enterprise test', :identifier => 'enterprise-test')
134 134
135 person = Person['testuser'] 135 person = Person['testuser']
136 community.add_admin(person) 136 community.add_admin(person)
@@ -173,7 +173,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase @@ -173,7 +173,7 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase
173 template.boxes[0].blocks << Block.new 173 template.boxes[0].blocks << Block.new
174 template.save! 174 template.save!
175 175
176 - env = Environment.create!(:name => 'test_env') 176 + env = fast_create(Environment, :name => 'test_env')
177 env.settings[:community_template_id] = template.id 177 env.settings[:community_template_id] = template.id
178 env.save! 178 env.save!
179 179
test/functional/profile_controller_test.rb
@@ -122,7 +122,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -122,7 +122,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
122 end 122 end
123 123
124 should 'not show enterprises link to enterprise' do 124 should 'not show enterprises link to enterprise' do
125 - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') 125 + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1')
126 get :index, :profile => ent.identifier 126 get :index, :profile => ent.identifier
127 assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ } 127 assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ }
128 end 128 end
@@ -257,7 +257,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -257,7 +257,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
257 257
258 should 'show message for disabled enterprise' do 258 should 'show message for disabled enterprise' do
259 login_as(@profile.identifier) 259 login_as(@profile.identifier)
260 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) 260 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
261 get :index, :profile => ent.identifier 261 get :index, :profile => ent.identifier
262 assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise 262 assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise
263 end 263 end
@@ -271,7 +271,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -271,7 +271,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
271 271
272 should 'not show message for disabled enterprise if there is a block for it' do 272 should 'not show message for disabled enterprise if there is a block for it' do
273 login_as(@profile.identifier) 273 login_as(@profile.identifier)
274 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) 274 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
275 ent.boxes << Box.new 275 ent.boxes << Box.new
276 ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new 276 ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new
277 ent.save 277 ent.save
@@ -280,7 +280,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -280,7 +280,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
280 end 280 end
281 281
282 should 'display "Products" link for enterprise' do 282 should 'display "Products" link for enterprise' do
283 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) 283 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
284 284
285 get :index, :profile => 'my-test-enterprise' 285 get :index, :profile => 'my-test-enterprise'
286 assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ 286 assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/
@@ -290,7 +290,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -290,7 +290,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
290 env = Environment.default 290 env = Environment.default
291 env.enable('disable_products_for_enterprises') 291 env.enable('disable_products_for_enterprises')
292 env.save! 292 env.save!
293 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false, :environment => env) 293 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false, :environment_id => env.id)
294 294
295 get :index, :profile => 'my-test-enterprise' 295 get :index, :profile => 'my-test-enterprise'
296 assert_no_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ 296 assert_no_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/
@@ -346,7 +346,8 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -346,7 +346,8 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
346 end 346 end
347 347
348 should 'display contact us only if enabled' do 348 should 'display contact us only if enabled' do
349 - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enable_contact_us => false) 349 + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise')
  350 + ent.update_attribute(:enable_contact_us, false)
350 get :index, :profile => 'my-test-enterprise' 351 get :index, :profile => 'my-test-enterprise'
351 assert_no_tag :tag => 'a', :attributes => { :href => "/contact/my-test-enterprise/new" }, :content => 'Contact us' 352 assert_no_tag :tag => 'a', :attributes => { :href => "/contact/my-test-enterprise/new" }, :content => 'Contact us'
352 end 353 end
test/functional/profile_design_controller_test.rb
@@ -208,7 +208,8 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase @@ -208,7 +208,8 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
208 should 'be able to edit ProductsBlock' do 208 should 'be able to edit ProductsBlock' do
209 block = ProductsBlock.new 209 block = ProductsBlock.new
210 210
211 - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') 211 + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise')
  212 + enterprise.boxes << Box.new
212 p1 = enterprise.products.create!(:name => 'product one') 213 p1 = enterprise.products.create!(:name => 'product one')
213 p2 = enterprise.products.create!(:name => 'product two') 214 p2 = enterprise.products.create!(:name => 'product two')
214 enterprise.boxes.first.blocks << block 215 enterprise.boxes.first.blocks << block
@@ -228,7 +229,8 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase @@ -228,7 +229,8 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
228 should 'be able to save ProductsBlock' do 229 should 'be able to save ProductsBlock' do
229 block = ProductsBlock.new 230 block = ProductsBlock.new
230 231
231 - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') 232 + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise')
  233 + enterprise.boxes << Box.new
232 p1 = enterprise.products.create!(:name => 'product one') 234 p1 = enterprise.products.create!(:name => 'product one')
233 p2 = enterprise.products.create!(:name => 'product two') 235 p2 = enterprise.products.create!(:name => 'product two')
234 enterprise.boxes.first.blocks << block 236 enterprise.boxes.first.blocks << block
@@ -256,7 +258,7 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase @@ -256,7 +258,7 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
256 env = Environment.default 258 env = Environment.default
257 env.enable('disable_products_for_enterprises') 259 env.enable('disable_products_for_enterprises')
258 env.save! 260 env.save!
259 - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) 261 + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id)
260 person = create_user_with_permission('test_user', 'edit_profile_design', ent) 262 person = create_user_with_permission('test_user', 'edit_profile_design', ent)
261 login_as(person.user.login) 263 login_as(person.user.login)
262 264
test/functional/profile_members_controller_test.rb
@@ -23,7 +23,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -23,7 +23,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
23 23
24 should 'not access index if dont have permission' do 24 should 'not access index if dont have permission' do
25 user = create_user('test_user') 25 user = create_user('test_user')
26 - Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 26 + fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
27 login_as :test_user 27 login_as :test_user
28 28
29 get 'index', :profile => 'test_enterprise' 29 get 'index', :profile => 'test_enterprise'
@@ -33,7 +33,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -33,7 +33,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
33 end 33 end
34 34
35 should 'access index' do 35 should 'access index' do
36 - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 36 + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
37 user = create_user_with_permission('test_user', 'manage_memberships', ent) 37 user = create_user_with_permission('test_user', 'manage_memberships', ent)
38 login_as :test_user 38 login_as :test_user
39 39
@@ -44,7 +44,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -44,7 +44,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
44 end 44 end
45 45
46 should 'show form to change role' do 46 should 'show form to change role' do
47 - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 47 + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
48 role = Profile::Roles.member(Environment.default) 48 role = Profile::Roles.member(Environment.default)
49 49
50 member = create_user('test_member').person 50 member = create_user('test_member').person
@@ -63,7 +63,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -63,7 +63,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
63 end 63 end
64 64
65 should 'not show form to change role if person is not member' do 65 should 'not show form to change role if person is not member' do
66 - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 66 + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
67 not_member = create_user('test_member').person 67 not_member = create_user('test_member').person
68 user = create_user_with_permission('test_user', 'manage_memberships', ent) 68 user = create_user_with_permission('test_user', 'manage_memberships', ent)
69 login_as :test_user 69 login_as :test_user
@@ -76,7 +76,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -76,7 +76,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
76 end 76 end
77 77
78 should 'update roles' do 78 should 'update roles' do
79 - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 79 + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
80 role1 = Role.create!(:name => 'member_role', :permissions => ['edit_profile'], :environment => ent.environment) 80 role1 = Role.create!(:name => 'member_role', :permissions => ['edit_profile'], :environment => ent.environment)
81 role2 = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) 81 role2 = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment)
82 82
@@ -95,7 +95,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -95,7 +95,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
95 end 95 end
96 96
97 should 'not update roles if user is not profile member' do 97 should 'not update roles if user is not profile member' do
98 - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') 98 + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise')
99 role = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) 99 role = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment)
100 100
101 not_member = create_user('test_member').person 101 not_member = create_user('test_member').person
@@ -129,7 +129,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -129,7 +129,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
129 end 129 end
130 130
131 should 'not list roles from other environments' do 131 should 'not list roles from other environments' do
132 - env2 = Environment.create!(:name => 'new env') 132 + env2 = fast_create(Environment, :name => 'new env')
133 role = Role.create!(:name => 'some role', :environment => env2, :permissions => ['manage_memberships']) 133 role = Role.create!(:name => 'some role', :environment => env2, :permissions => ['manage_memberships'])
134 134
135 com = Community.create!(:name => 'test community') 135 com = Community.create!(:name => 'test community')
@@ -145,7 +145,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -145,7 +145,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
145 end 145 end
146 146
147 should 'enterprises have a add members button' do 147 should 'enterprises have a add members button' do
148 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 148 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
149 u = create_user_with_permission('test_user', 'manage_memberships', ent) 149 u = create_user_with_permission('test_user', 'manage_memberships', ent)
150 login_as :test_user 150 login_as :test_user
151 151
@@ -177,7 +177,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -177,7 +177,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
177 end 177 end
178 178
179 should 'have a add_members page' do 179 should 'have a add_members page' do
180 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 180 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
181 u = create_user_with_permission('test_user', 'manage_memberships', ent) 181 u = create_user_with_permission('test_user', 'manage_memberships', ent)
182 login_as :test_user 182 login_as :test_user
183 183
@@ -188,7 +188,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -188,7 +188,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
188 end 188 end
189 189
190 should 'list current members when adding new members' do 190 should 'list current members when adding new members' do
191 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 191 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
192 p = create_user_with_permission('test_user', 'manage_memberships', ent) 192 p = create_user_with_permission('test_user', 'manage_memberships', ent)
193 login_as :test_user 193 login_as :test_user
194 194
@@ -198,7 +198,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -198,7 +198,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
198 end 198 end
199 199
200 should 'add member to profile' do 200 should 'add member to profile' do
201 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 201 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
202 p = create_user_with_permission('test_user', 'manage_memberships', ent) 202 p = create_user_with_permission('test_user', 'manage_memberships', ent)
203 login_as :test_user 203 login_as :test_user
204 204
@@ -211,7 +211,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -211,7 +211,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
211 end 211 end
212 212
213 should 'add member with all roles' do 213 should 'add member with all roles' do
214 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 214 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
215 p = create_user_with_permission('test_user', 'manage_memberships', ent) 215 p = create_user_with_permission('test_user', 'manage_memberships', ent)
216 login_as :test_user 216 login_as :test_user
217 217
@@ -234,7 +234,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -234,7 +234,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
234 end 234 end
235 235
236 should 'find users' do 236 should 'find users' do
237 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 237 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
238 user = create_user_full('test_user').person 238 user = create_user_full('test_user').person
239 u = create_user_with_permission('ent_user', 'manage_memberships', ent) 239 u = create_user_with_permission('ent_user', 'manage_memberships', ent)
240 login_as :ent_user 240 login_as :ent_user
@@ -245,7 +245,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -245,7 +245,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
245 end 245 end
246 246
247 should 'not appear add button for member in add members page' do 247 should 'not appear add button for member in add members page' do
248 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 248 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
249 p = create_user_with_permission('test_user', 'manage_memberships', ent) 249 p = create_user_with_permission('test_user', 'manage_memberships', ent)
250 login_as :test_user 250 login_as :test_user
251 251
@@ -258,7 +258,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -258,7 +258,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
258 daniel = create_user_full('daniel').person 258 daniel = create_user_full('daniel').person
259 daniela = create_user_full('daniela').person 259 daniela = create_user_full('daniela').person
260 260
261 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 261 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
262 p = create_user_with_permission('test_user', 'manage_memberships', ent) 262 p = create_user_with_permission('test_user', 'manage_memberships', ent)
263 login_as :test_user 263 login_as :test_user
264 264
@@ -269,7 +269,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase @@ -269,7 +269,7 @@ class ProfileMembersControllerTest &lt; Test::Unit::TestCase
269 end 269 end
270 270
271 should 'ignore roles with id zero' do 271 should 'ignore roles with id zero' do
272 - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') 272 + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent')
273 p = create_user_with_permission('test_user', 'manage_memberships', ent) 273 p = create_user_with_permission('test_user', 'manage_memberships', ent)
274 login_as :test_user 274 login_as :test_user
275 r = ent.environment.roles.create!(:name => 'test_role', :permissions => ['some_perm']) 275 r = ent.environment.roles.create!(:name => 'test_role', :permissions => ['some_perm'])
test/functional/region_validators_controller_test.rb
@@ -31,7 +31,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase @@ -31,7 +31,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase
31 end 31 end
32 32
33 should 'view validators for a specific region' do 33 should 'view validators for a specific region' do
34 - environment = Environment.create!(:name => "my environment") 34 + environment = fast_create(Environment, :name => "my environment")
35 give_permission('ze', 'manage_environment_validators', environment) 35 give_permission('ze', 'manage_environment_validators', environment)
36 region = Region.new(:name => 'my region') 36 region = Region.new(:name => 'my region')
37 environment.regions << region 37 environment.regions << region
@@ -47,7 +47,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase @@ -47,7 +47,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase
47 end 47 end
48 48
49 should 'search possible validators by name' do 49 should 'search possible validators by name' do
50 - environment = Environment.create!(:name => "my environment") 50 + environment = fast_create(Environment, :name => "my environment")
51 give_permission('ze', 'manage_environment_validators', environment) 51 give_permission('ze', 'manage_environment_validators', environment)
52 region = Region.new(:name => 'my region') 52 region = Region.new(:name => 'my region')
53 environment.regions << region 53 environment.regions << region
@@ -63,7 +63,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase @@ -63,7 +63,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase
63 end 63 end
64 64
65 should 'be able to add validators to the current region' do 65 should 'be able to add validators to the current region' do
66 - environment = Environment.create!(:name => "my environment") 66 + environment = fast_create(Environment, :name => "my environment")
67 give_permission('ze', 'manage_environment_validators', environment) 67 give_permission('ze', 'manage_environment_validators', environment)
68 region = Region.new(:name => 'my region') 68 region = Region.new(:name => 'my region')
69 environment.regions << region 69 environment.regions << region
@@ -80,7 +80,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase @@ -80,7 +80,7 @@ class RegionValidatorsControllerTest &lt; Test::Unit::TestCase
80 end 80 end
81 81
82 should 'be able to remove validators from the current region' do 82 should 'be able to remove validators from the current region' do
83 - environment = Environment.create!(:name => "my environment") 83 + environment = fast_create(Environment, :name => "my environment")
84 give_permission('ze', 'manage_environment_validators', environment) 84 give_permission('ze', 'manage_environment_validators', environment)
85 region = Region.new(:name => 'my region') 85 region = Region.new(:name => 'my region')
86 environment.regions << region 86 environment.regions << region