Commit 30c66afb0bda26c71b37c8c4fa3731c64986aa84
Exists in
master
and in
28 other branches
Merge branch 'stable'
Conflicts: test/functional/catalog_controller_test.rb test/functional/profile_design_controller_test.rb
Showing
17 changed files
with
84 additions
and
68 deletions
Show diff stats
app/controllers/my_profile/profile_members_controller.rb
| ... | ... | @@ -69,7 +69,7 @@ class ProfileMembersController < MyProfileController |
| 69 | 69 | |
| 70 | 70 | def add_member |
| 71 | 71 | if profile.enterprise? |
| 72 | - member = Person.find_by_identifier(params[:id]) | |
| 72 | + member = Person.find(params[:id]) | |
| 73 | 73 | member.define_roles(Profile::Roles.all_roles(environment), profile) |
| 74 | 74 | end |
| 75 | 75 | render :layout => false | ... | ... |
app/views/profile_members/find_users.rhtml
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <%= button_to_remote_without_text(:add, _('Add member'), |
| 18 | 18 | { :loading => '$("members-list").addClassName("loading")', |
| 19 | 19 | :update => 'members-list', |
| 20 | - :url => {:action => 'add_member', :profile => profile.identifier, :id => user.identifier}, | |
| 20 | + :url => {:action => 'add_member', :profile => profile.identifier, :id => user.id}, | |
| 21 | 21 | :success => "$('tr-#{user.identifier}').hide()", |
| 22 | 22 | :complete => '$("members-list").removeClassName("loading")'}) %> |
| 23 | 23 | ... | ... |
test/functional/account_controller_test.rb
| ... | ... | @@ -49,7 +49,7 @@ class AccountControllerTest < Test::Unit::TestCase |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 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 | 53 | e.domains << Domain.new(:name => 'other.environment') |
| 54 | 54 | e.save! |
| 55 | 55 | u = create_user('test_user', :environment => e).person |
| ... | ... | @@ -338,7 +338,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 338 | 338 | person = create_user('mylogin').person |
| 339 | 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 | 343 | task = mock |
| 343 | 344 | task.expects(:enterprise).returns(ent).at_least_once |
| 344 | 345 | EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once |
| ... | ... | @@ -352,7 +353,7 @@ class AccountControllerTest < Test::Unit::TestCase |
| 352 | 353 | person = create_user('mylogin').person |
| 353 | 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 | 358 | task = mock |
| 358 | 359 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -367,7 +368,7 @@ class AccountControllerTest < Test::Unit::TestCase |
| 367 | 368 | person = create_user('mylogin').person |
| 368 | 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 | 373 | task = mock |
| 373 | 374 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -382,7 +383,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 382 | 383 | person = create_user('mylogin').person |
| 383 | 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 | 389 | task = mock |
| 388 | 390 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -397,7 +399,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 397 | 399 | person = create_user('mylogin').person |
| 398 | 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 | 405 | task = mock |
| 403 | 406 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -412,7 +415,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 412 | 415 | person = create_user('mylogin').person |
| 413 | 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 | 420 | ent.block |
| 417 | 421 | |
| 418 | 422 | task = mock |
| ... | ... | @@ -428,7 +432,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 428 | 432 | person = create_user('mylogin').person |
| 429 | 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 | 438 | task = mock |
| 434 | 439 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -440,7 +445,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 440 | 445 | end |
| 441 | 446 | |
| 442 | 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 | 451 | task = mock |
| 446 | 452 | task.expects(:enterprise).returns(ent).never |
| ... | ... | @@ -455,7 +461,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 455 | 461 | person = create_user('mylogin').person |
| 456 | 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 | 467 | task = mock |
| 461 | 468 | task.expects(:enterprise).returns(ent).at_least_once |
| ... | ... | @@ -478,7 +485,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 478 | 485 | env.terms_of_enterprise_use = 'Some terms' |
| 479 | 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 | 490 | task = EnterpriseActivation.create!(:enterprise => ent) |
| 483 | 491 | EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once |
| 484 | 492 | |
| ... | ... | @@ -492,7 +500,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 492 | 500 | person = create_user('mylogin').person |
| 493 | 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 | 505 | ent.block |
| 497 | 506 | ent.save |
| 498 | 507 | |
| ... | ... | @@ -509,7 +518,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 509 | 518 | env = Environment.default |
| 510 | 519 | env.terms_of_use = 'some terms' |
| 511 | 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 | 523 | task = EnterpriseActivation.create!(:enterprise => ent) |
| 514 | 524 | EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).never |
| 515 | 525 | |
| ... | ... | @@ -519,7 +529,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 519 | 529 | end |
| 520 | 530 | |
| 521 | 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 | 534 | p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person |
| 524 | 535 | login_as(p.identifier) |
| 525 | 536 | |
| ... | ... | @@ -534,7 +545,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 534 | 545 | end |
| 535 | 546 | |
| 536 | 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 | 550 | p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person |
| 539 | 551 | login_as(p.identifier) |
| 540 | 552 | |
| ... | ... | @@ -555,7 +567,8 @@ class AccountControllerTest < Test::Unit::TestCase |
| 555 | 567 | env = Environment.default |
| 556 | 568 | env.terms_of_use = 'some terms' |
| 557 | 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 | 572 | task = EnterpriseActivation.create!(:enterprise => ent) |
| 560 | 573 | EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once |
| 561 | 574 | |
| ... | ... | @@ -583,7 +596,7 @@ class AccountControllerTest < Test::Unit::TestCase |
| 583 | 596 | template.boxes << Box.new |
| 584 | 597 | template.boxes[0].blocks << Block.new |
| 585 | 598 | template.save! |
| 586 | - env = Environment.create!(:name => 'test_env') | |
| 599 | + env = fast_create(Environment, :name => 'test_env') | |
| 587 | 600 | env.settings[:person_template_id] = template.id |
| 588 | 601 | env.save! |
| 589 | 602 | |
| ... | ... | @@ -658,7 +671,7 @@ class AccountControllerTest < Test::Unit::TestCase |
| 658 | 671 | end |
| 659 | 672 | |
| 660 | 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 | 675 | @controller.expects(:environment).returns(env).at_least_once |
| 663 | 676 | profile = create_user('mylogin').person |
| 664 | 677 | get :check_url, :identifier => 'mylogin' | ... | ... |
test/functional/admin_panel_controller_test.rb
| ... | ... | @@ -24,7 +24,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | 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 | 28 | current.domains.create!(:name => 'example.com') |
| 29 | 29 | |
| 30 | 30 | @request.expects(:host).returns('example.com').at_least_once |
| ... | ... | @@ -241,7 +241,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase |
| 241 | 241 | should 'not have a portal community from other environment' do |
| 242 | 242 | e = Environment.default |
| 243 | 243 | @controller.stubs(:environment).returns(e) |
| 244 | - other_e = Environment.create!(:name => 'other environment') | |
| 244 | + other_e = fast_create(Environment, :name => 'other environment') | |
| 245 | 245 | c = Community.create!(:name => 'portal community', :environment => other_e) |
| 246 | 246 | |
| 247 | 247 | post :set_portal_community, :portal_community_identifier => c.identifier | ... | ... |
test/functional/application_controller_test.rb
| ... | ... | @@ -49,7 +49,7 @@ class ApplicationControllerTest < Test::Unit::TestCase |
| 49 | 49 | Environment.stubs(:default).returns(default) |
| 50 | 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 | 53 | current.domains.create!(:name => 'example.com') |
| 54 | 54 | |
| 55 | 55 | @request.expects(:host).returns('example.com').at_least_once |
| ... | ... | @@ -387,7 +387,7 @@ class ApplicationControllerTest < Test::Unit::TestCase |
| 387 | 387 | |
| 388 | 388 | should 'display menu links for my environment when logged in other environment' do |
| 389 | 389 | @controller.stubs(:get_layout).returns('application') |
| 390 | - e = Environment.create!(:name => 'other_environment') | |
| 390 | + e = fast_create(Environment, :name => 'other_environment') | |
| 391 | 391 | e.domains << Domain.new(:name => 'other.environment') |
| 392 | 392 | e.save! |
| 393 | 393 | ... | ... |
test/functional/catalog_controller_test.rb
| ... | ... | @@ -68,7 +68,7 @@ class CatalogControllerTest < Test::Unit::TestCase |
| 68 | 68 | env = Environment.default |
| 69 | 69 | env.enable('disable_products_for_enterprises') |
| 70 | 70 | env.save! |
| 71 | - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) | |
| 71 | + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) | |
| 72 | 72 | get :index, :profile => ent.identifier |
| 73 | 73 | |
| 74 | 74 | assert_redirected_to :controller => 'profile', :action => 'index', :profile => ent.identifier | ... | ... |
test/functional/categories_controller_test.rb
| ... | ... | @@ -12,7 +12,7 @@ class CategoriesControllerTest < Test::Unit::TestCase |
| 12 | 12 | @request.stubs(:ssl?).returns(true) |
| 13 | 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 | 16 | Environment.stubs(:default).returns(env) |
| 17 | 17 | assert (@cat1 = env.categories.create(:name => 'a test category')) |
| 18 | 18 | assert (@cat1 = env.categories.create(:name => 'another category')) | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -583,7 +583,7 @@ class CmsControllerTest < Test::Unit::TestCase |
| 583 | 583 | end |
| 584 | 584 | |
| 585 | 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 | 587 | assert_includes @controller.available_article_types, EnterpriseHomepage |
| 588 | 588 | end |
| 589 | 589 | |
| ... | ... | @@ -786,7 +786,7 @@ class CmsControllerTest < Test::Unit::TestCase |
| 786 | 786 | end |
| 787 | 787 | |
| 788 | 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 | 790 | blog = Blog.create!(:name => 'Blog for test', :profile => profile) |
| 791 | 791 | @controller.stubs(:params).returns({ :parent_id => blog.id }) |
| 792 | 792 | |
| ... | ... | @@ -794,7 +794,7 @@ class CmsControllerTest < Test::Unit::TestCase |
| 794 | 794 | end |
| 795 | 795 | |
| 796 | 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 | 798 | blog = Blog.create!(:name => 'Blog for test', :profile => profile) |
| 799 | 799 | @controller.stubs(:params).returns({ :parent_id => blog.id }) |
| 800 | 800 | ... | ... |
test/functional/contact_controller_test.rb
| ... | ... | @@ -14,7 +14,7 @@ class ContactControllerTest < Test::Unit::TestCase |
| 14 | 14 | @response = ActionController::TestResponse.new |
| 15 | 15 | |
| 16 | 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 | 19 | login_as('contact_test_user') |
| 20 | 20 | end | ... | ... |
test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -360,7 +360,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase |
| 360 | 360 | |
| 361 | 361 | should 'not show message for disabled enterprise if there is a block for it' do |
| 362 | 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 | 364 | ent.boxes << Box.new |
| 365 | 365 | ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new |
| 366 | 366 | ent.save |
| ... | ... | @@ -595,7 +595,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase |
| 595 | 595 | should 'not show a profile in an environment that is not its home environment' do |
| 596 | 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 | 599 | current.domains.create!(:name => 'example.com') |
| 600 | 600 | uses_host 'www.example.com' |
| 601 | 601 | ... | ... |
test/functional/favorite_enterprises_controller_test.rb
| ... | ... | @@ -14,7 +14,7 @@ class FavoriteEnterprisesControllerTest < Test::Unit::TestCase |
| 14 | 14 | @response = ActionController::TestResponse.new |
| 15 | 15 | |
| 16 | 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 | 18 | login_as ('testuser') |
| 19 | 19 | end |
| 20 | 20 | attr_accessor :profile, :favorite_enterprise | ... | ... |
test/functional/manage_products_controller_test.rb
| ... | ... | @@ -11,7 +11,7 @@ class ManageProductsControllerTest < Test::Unit::TestCase |
| 11 | 11 | @request = ActionController::TestRequest.new |
| 12 | 12 | @request.stubs(:ssl?).returns(true) |
| 13 | 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 | 15 | @user = create_user_with_permission('test_user', 'manage_products', @enterprise) |
| 16 | 16 | @environment = @enterprise.environment |
| 17 | 17 | @product_category = fast_create(ProductCategory) | ... | ... |
test/functional/memberships_controller_test.rb
| ... | ... | @@ -99,7 +99,7 @@ class MembershipsControllerTest < Test::Unit::TestCase |
| 99 | 99 | end |
| 100 | 100 | |
| 101 | 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 | 103 | enterprise.add_member(profile) |
| 104 | 104 | get :index, :profile => profile.identifier |
| 105 | 105 | assert_no_tag :tag => 'li', :content => /Description:/ |
| ... | ... | @@ -130,7 +130,7 @@ class MembershipsControllerTest < Test::Unit::TestCase |
| 130 | 130 | |
| 131 | 131 | should 'display destroy link only to communities' do |
| 132 | 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 | 135 | person = Person['testuser'] |
| 136 | 136 | community.add_admin(person) |
| ... | ... | @@ -173,7 +173,7 @@ class MembershipsControllerTest < Test::Unit::TestCase |
| 173 | 173 | template.boxes[0].blocks << Block.new |
| 174 | 174 | template.save! |
| 175 | 175 | |
| 176 | - env = Environment.create!(:name => 'test_env') | |
| 176 | + env = fast_create(Environment, :name => 'test_env') | |
| 177 | 177 | env.settings[:community_template_id] = template.id |
| 178 | 178 | env.save! |
| 179 | 179 | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -122,7 +122,7 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 122 | 122 | end |
| 123 | 123 | |
| 124 | 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 | 126 | get :index, :profile => ent.identifier |
| 127 | 127 | assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ } |
| 128 | 128 | end |
| ... | ... | @@ -257,7 +257,7 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 257 | 257 | |
| 258 | 258 | should 'show message for disabled enterprise' do |
| 259 | 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 | 261 | get :index, :profile => ent.identifier |
| 262 | 262 | assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise |
| 263 | 263 | end |
| ... | ... | @@ -271,7 +271,7 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 271 | 271 | |
| 272 | 272 | should 'not show message for disabled enterprise if there is a block for it' do |
| 273 | 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 | 275 | ent.boxes << Box.new |
| 276 | 276 | ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new |
| 277 | 277 | ent.save |
| ... | ... | @@ -280,7 +280,7 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 280 | 280 | end |
| 281 | 281 | |
| 282 | 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 | 285 | get :index, :profile => 'my-test-enterprise' |
| 286 | 286 | assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ |
| ... | ... | @@ -290,7 +290,7 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 290 | 290 | env = Environment.default |
| 291 | 291 | env.enable('disable_products_for_enterprises') |
| 292 | 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 | 295 | get :index, :profile => 'my-test-enterprise' |
| 296 | 296 | assert_no_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ |
| ... | ... | @@ -346,7 +346,8 @@ class ProfileControllerTest < Test::Unit::TestCase |
| 346 | 346 | end |
| 347 | 347 | |
| 348 | 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 | 351 | get :index, :profile => 'my-test-enterprise' |
| 351 | 352 | assert_no_tag :tag => 'a', :attributes => { :href => "/contact/my-test-enterprise/new" }, :content => 'Contact us' |
| 352 | 353 | end | ... | ... |
test/functional/profile_design_controller_test.rb
| ... | ... | @@ -218,7 +218,8 @@ class ProfileDesignControllerTest < Test::Unit::TestCase |
| 218 | 218 | should 'be able to edit ProductsBlock' do |
| 219 | 219 | block = ProductsBlock.new |
| 220 | 220 | |
| 221 | - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') | |
| 221 | + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise') | |
| 222 | + enterprise.boxes << Box.new | |
| 222 | 223 | p1 = enterprise.products.create!(:name => 'product one', :product_category => @product_category) |
| 223 | 224 | p2 = enterprise.products.create!(:name => 'product two', :product_category => @product_category) |
| 224 | 225 | enterprise.boxes.first.blocks << block |
| ... | ... | @@ -238,7 +239,8 @@ class ProfileDesignControllerTest < Test::Unit::TestCase |
| 238 | 239 | should 'be able to save ProductsBlock' do |
| 239 | 240 | block = ProductsBlock.new |
| 240 | 241 | |
| 241 | - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') | |
| 242 | + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise') | |
| 243 | + enterprise.boxes << Box.new | |
| 242 | 244 | p1 = enterprise.products.create!(:name => 'product one', :product_category => @product_category) |
| 243 | 245 | p2 = enterprise.products.create!(:name => 'product two', :product_category => @product_category) |
| 244 | 246 | enterprise.boxes.first.blocks << block |
| ... | ... | @@ -266,7 +268,7 @@ class ProfileDesignControllerTest < Test::Unit::TestCase |
| 266 | 268 | env = Environment.default |
| 267 | 269 | env.enable('disable_products_for_enterprises') |
| 268 | 270 | env.save! |
| 269 | - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) | |
| 271 | + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) | |
| 270 | 272 | person = create_user_with_permission('test_user', 'edit_profile_design', ent) |
| 271 | 273 | login_as(person.user.login) |
| 272 | 274 | ... | ... |
test/functional/profile_members_controller_test.rb
| ... | ... | @@ -23,7 +23,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 23 | 23 | |
| 24 | 24 | should 'not access index if dont have permission' do |
| 25 | 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 | 27 | login_as :test_user |
| 28 | 28 | |
| 29 | 29 | get 'index', :profile => 'test_enterprise' |
| ... | ... | @@ -33,7 +33,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 33 | 33 | end |
| 34 | 34 | |
| 35 | 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 | 37 | user = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 38 | 38 | login_as :test_user |
| 39 | 39 | |
| ... | ... | @@ -44,7 +44,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | 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 | 48 | role = Profile::Roles.member(Environment.default) |
| 49 | 49 | |
| 50 | 50 | member = create_user('test_member').person |
| ... | ... | @@ -63,7 +63,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 63 | 63 | end |
| 64 | 64 | |
| 65 | 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 | 67 | not_member = create_user('test_member').person |
| 68 | 68 | user = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 69 | 69 | login_as :test_user |
| ... | ... | @@ -76,7 +76,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 76 | 76 | end |
| 77 | 77 | |
| 78 | 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 | 80 | role1 = Role.create!(:name => 'member_role', :permissions => ['edit_profile'], :environment => ent.environment) |
| 81 | 81 | role2 = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) |
| 82 | 82 | |
| ... | ... | @@ -95,7 +95,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 95 | 95 | end |
| 96 | 96 | |
| 97 | 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 | 99 | role = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) |
| 100 | 100 | |
| 101 | 101 | not_member = create_user('test_member').person |
| ... | ... | @@ -129,7 +129,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 129 | 129 | end |
| 130 | 130 | |
| 131 | 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 | 133 | role = Role.create!(:name => 'some role', :environment => env2, :permissions => ['manage_memberships']) |
| 134 | 134 | |
| 135 | 135 | com = Community.create!(:name => 'test community') |
| ... | ... | @@ -145,7 +145,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 145 | 145 | end |
| 146 | 146 | |
| 147 | 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 | 149 | u = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 150 | 150 | login_as :test_user |
| 151 | 151 | |
| ... | ... | @@ -177,7 +177,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 177 | 177 | end |
| 178 | 178 | |
| 179 | 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 | 181 | u = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 182 | 182 | login_as :test_user |
| 183 | 183 | |
| ... | ... | @@ -188,7 +188,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 188 | 188 | end |
| 189 | 189 | |
| 190 | 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 | 192 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 193 | 193 | login_as :test_user |
| 194 | 194 | |
| ... | ... | @@ -198,12 +198,12 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 198 | 198 | end |
| 199 | 199 | |
| 200 | 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 | 202 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 203 | 203 | login_as :test_user |
| 204 | 204 | |
| 205 | 205 | u = create_user('member_wannabe').person |
| 206 | - post :add_member, :profile => ent.identifier, :id => u.identifier | |
| 206 | + post :add_member, :profile => ent.identifier, :id => u.id | |
| 207 | 207 | ent.reload |
| 208 | 208 | |
| 209 | 209 | assert_includes ent.members, p |
| ... | ... | @@ -211,12 +211,12 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 211 | 211 | end |
| 212 | 212 | |
| 213 | 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 | 215 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 216 | 216 | login_as :test_user |
| 217 | 217 | |
| 218 | 218 | u = create_user('member_wannabe').person |
| 219 | - post :add_member, :profile => ent.identifier, :id => u.identifier | |
| 219 | + post :add_member, :profile => ent.identifier, :id => u.id | |
| 220 | 220 | |
| 221 | 221 | assert_equivalent Profile::Roles.all_roles(ent.environment).compact, u.role_assignments.find_all_by_resource_id(ent.id).map(&:role).compact |
| 222 | 222 | end |
| ... | ... | @@ -234,7 +234,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 234 | 234 | end |
| 235 | 235 | |
| 236 | 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 | 238 | user = create_user_full('test_user').person |
| 239 | 239 | u = create_user_with_permission('ent_user', 'manage_memberships', ent) |
| 240 | 240 | login_as :ent_user |
| ... | ... | @@ -245,7 +245,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 245 | 245 | end |
| 246 | 246 | |
| 247 | 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 | 249 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 250 | 250 | login_as :test_user |
| 251 | 251 | |
| ... | ... | @@ -258,7 +258,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 258 | 258 | daniel = create_user_full('daniel').person |
| 259 | 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 | 262 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 263 | 263 | login_as :test_user |
| 264 | 264 | |
| ... | ... | @@ -269,7 +269,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 269 | 269 | end |
| 270 | 270 | |
| 271 | 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 | 273 | p = create_user_with_permission('test_user', 'manage_memberships', ent) |
| 274 | 274 | login_as :test_user |
| 275 | 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 < Test::Unit::TestCase |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 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 | 35 | give_permission('ze', 'manage_environment_validators', environment) |
| 36 | 36 | region = Region.new(:name => 'my region') |
| 37 | 37 | environment.regions << region |
| ... | ... | @@ -47,7 +47,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase |
| 47 | 47 | end |
| 48 | 48 | |
| 49 | 49 | should 'search possible validators by name' do |
| 50 | - environment = Environment.create!(:name => "my environment") | |
| 50 | + environment = fast_create(Environment, :name => "my environment") | |
| 51 | 51 | give_permission('ze', 'manage_environment_validators', environment) |
| 52 | 52 | region = Region.new(:name => 'my region') |
| 53 | 53 | environment.regions << region |
| ... | ... | @@ -63,7 +63,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase |
| 63 | 63 | end |
| 64 | 64 | |
| 65 | 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 | 67 | give_permission('ze', 'manage_environment_validators', environment) |
| 68 | 68 | region = Region.new(:name => 'my region') |
| 69 | 69 | environment.regions << region |
| ... | ... | @@ -80,7 +80,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase |
| 80 | 80 | end |
| 81 | 81 | |
| 82 | 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 | 84 | give_permission('ze', 'manage_environment_validators', environment) |
| 85 | 85 | region = Region.new(:name => 'my region') |
| 86 | 86 | environment.regions << region | ... | ... |