diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index e6241fe..d193b6b 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -49,7 +49,7 @@ class AccountControllerTest < Test::Unit::TestCase end should 'redirect to where was when login on other environment' do - e = Environment.create!(:name => 'other_environment') + e = fast_create(Environment, :name => 'other_environment') e.domains << Domain.new(:name => 'other.environment') e.save! u = create_user('test_user', :environment => e).person @@ -338,7 +338,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :cnpj => '0'*14, :enabled => true) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => true) + ent.update_attribute(:cnpj, '0'*14) task = mock task.expects(:enterprise).returns(ent).at_least_once EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once @@ -352,7 +353,7 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent') task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -367,7 +368,7 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -382,7 +383,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -397,7 +399,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :cnpj => '0'*14, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:cnpj, '0'*14) task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -412,7 +415,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => '1998', :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) ent.block task = mock @@ -428,7 +432,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -440,7 +445,8 @@ class AccountControllerTest < Test::Unit::TestCase end should 'require login for accept terms' do - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = mock task.expects(:enterprise).returns(ent).never @@ -455,7 +461,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = mock task.expects(:enterprise).returns(ent).at_least_once @@ -478,7 +485,8 @@ class AccountControllerTest < Test::Unit::TestCase env.terms_of_enterprise_use = 'Some terms' env.save! - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = EnterpriseActivation.create!(:enterprise => ent) EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once @@ -492,7 +500,8 @@ class AccountControllerTest < Test::Unit::TestCase person = create_user('mylogin').person login_as(person.identifier) - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) ent.block ent.save @@ -509,7 +518,8 @@ class AccountControllerTest < Test::Unit::TestCase env = Environment.default env.terms_of_use = 'some terms' env.save! - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = EnterpriseActivation.create!(:enterprise => ent) EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).never @@ -519,7 +529,8 @@ class AccountControllerTest < Test::Unit::TestCase end should 'not activate if user does not accept terms' do - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person login_as(p.identifier) @@ -534,7 +545,8 @@ class AccountControllerTest < Test::Unit::TestCase end should 'activate enterprise and make logged user admin' do - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) p = create_user('test_user', :password => 'blih', :password_confirmation => 'blih', :email => 'test@noosfero.com').person login_as(p.identifier) @@ -555,7 +567,8 @@ class AccountControllerTest < Test::Unit::TestCase env = Environment.default env.terms_of_use = 'some terms' env.save! - ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent = fast_create(Enterprise, :name => 'test enterprise', :identifier => 'test_ent', :enabled => false) + ent.update_attribute(:foundation_year, 1998) task = EnterpriseActivation.create!(:enterprise => ent) EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once @@ -583,7 +596,7 @@ class AccountControllerTest < Test::Unit::TestCase template.boxes << Box.new template.boxes[0].blocks << Block.new template.save! - env = Environment.create!(:name => 'test_env') + env = fast_create(Environment, :name => 'test_env') env.settings[:person_template_id] = template.id env.save! @@ -658,7 +671,7 @@ class AccountControllerTest < Test::Unit::TestCase end should 'check_url is available on environment' do - env = Environment.create(:name => 'Environment test') + env = fast_create(Environment, :name => 'Environment test') @controller.expects(:environment).returns(env).at_least_once profile = create_user('mylogin').person get :check_url, :identifier => 'mylogin' diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index 885715b..290b70e 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -24,7 +24,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase end should 'manage the correct environment' do - current = Environment.create!(:name => 'test environment', :is_default => false) + current = fast_create(Environment, :name => 'test environment', :is_default => false) current.domains.create!(:name => 'example.com') @request.expects(:host).returns('example.com').at_least_once @@ -241,7 +241,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase should 'not have a portal community from other environment' do e = Environment.default @controller.stubs(:environment).returns(e) - other_e = Environment.create!(:name => 'other environment') + other_e = fast_create(Environment, :name => 'other environment') c = Community.create!(:name => 'portal community', :environment => other_e) post :set_portal_community, :portal_community_identifier => c.identifier diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index b0e2c87..bb26a36 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -49,7 +49,7 @@ class ApplicationControllerTest < Test::Unit::TestCase Environment.stubs(:default).returns(default) default.stubs(:top_url).returns('http://default.com/') - current = Environment.create!(:name => 'test environment') + current = fast_create(Environment, :name => 'test environment') current.domains.create!(:name => 'example.com') @request.expects(:host).returns('example.com').at_least_once @@ -387,7 +387,7 @@ class ApplicationControllerTest < Test::Unit::TestCase should 'display menu links for my environment when logged in other environment' do @controller.stubs(:get_layout).returns('application') - e = Environment.create!(:name => 'other_environment') + e = fast_create(Environment, :name => 'other_environment') e.domains << Domain.new(:name => 'other.environment') e.save! diff --git a/test/functional/catalog_controller_test.rb b/test/functional/catalog_controller_test.rb index 79aee27..457b012 100644 --- a/test/functional/catalog_controller_test.rb +++ b/test/functional/catalog_controller_test.rb @@ -10,12 +10,12 @@ class CatalogControllerTest < Test::Unit::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @enterprise = Enterprise.create!(:name => 'My enterprise', :identifier => 'testent') + @enterprise = fast_create(Enterprise, :name => 'My enterprise', :identifier => 'testent') end attr_accessor :enterprise def test_local_files_reference - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') assert_local_files_reference :get, :index, :profile => ent.identifier end @@ -35,13 +35,13 @@ class CatalogControllerTest < Test::Unit::TestCase end should 'list products of enterprise' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') get :index, :profile => ent.identifier assert_kind_of Array, assigns(:products) end should 'show product of enterprise' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') prod = ent.products.create!(:name => 'Product test') get :show, :id => prod.id, :profile => ent.identifier assert_tag :tag => 'h1', :content => /#{prod.name}/ @@ -70,28 +70,28 @@ class CatalogControllerTest < Test::Unit::TestCase env = Environment.default env.enable('disable_products_for_enterprises') env.save! - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) get :index, :profile => ent.identifier assert_redirected_to :controller => 'profile', :action => 'index', :profile => ent.identifier end should 'not show product price when listing products if not informed' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') prod = ent.products.create!(:name => 'Product test') get :index, :profile => ent.identifier assert_no_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ end should 'show product price when listing products if informed' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') prod = ent.products.create!(:name => 'Product test', :price => 50.00) get :index, :profile => ent.identifier assert_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ end should 'not show product price when showing product if not informed' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') prod = ent.products.create!(:name => 'Product test') get :show, :id => prod.id, :profile => ent.identifier @@ -99,7 +99,7 @@ class CatalogControllerTest < Test::Unit::TestCase end should 'show product price when showing product if informed' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') prod = ent.products.create!(:name => 'Product test', :price => 50.00) get :show, :id => prod.id, :profile => ent.identifier @@ -107,7 +107,7 @@ class CatalogControllerTest < Test::Unit::TestCase end should 'not crash on index when product has no product_category and enterprise not enabled' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1', :enabled => false) + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1', :enabled => false) prod = ent.products.create!(:name => 'Product test', :price => 50.00, :product_category => nil) assert_nothing_raised do get :index, :profile => ent.identifier diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index 8218656..26b2646 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -12,7 +12,7 @@ class CategoriesControllerTest < Test::Unit::TestCase @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new - @env = Environment.create!(:name => "My test environment") + @env = fast_create(Environment, :name => "My test environment") Environment.stubs(:default).returns(env) assert (@cat1 = env.categories.create(:name => 'a test category')) assert (@cat1 = env.categories.create(:name => 'another category')) diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 4b4ec1a..fb6068b 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -583,7 +583,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'make enterprise homepage available to enterprises' do - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent')) assert_includes @controller.available_article_types, EnterpriseHomepage end @@ -786,7 +786,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not offer folder to blog articles' do - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent')) blog = Blog.create!(:name => 'Blog for test', :profile => profile) @controller.stubs(:params).returns({ :parent_id => blog.id }) @@ -794,7 +794,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not offer rssfeed to blog articles' do - @controller.stubs(:profile).returns(Enterprise.create(:name => 'test_ent', :identifier => 'test_ent')) + @controller.stubs(:profile).returns(fast_create(Enterprise, :name => 'test_ent', :identifier => 'test_ent')) blog = Blog.create!(:name => 'Blog for test', :profile => profile) @controller.stubs(:params).returns({ :parent_id => blog.id }) diff --git a/test/functional/contact_controller_test.rb b/test/functional/contact_controller_test.rb index cb5e0ea..0fa3f2b 100644 --- a/test/functional/contact_controller_test.rb +++ b/test/functional/contact_controller_test.rb @@ -14,7 +14,7 @@ class ContactControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new @profile = create_user('contact_test_user').person - @enterprise = Enterprise.create!(:identifier => 'contact_test_enterprise', :name => 'Test contact enteprise') + @enterprise = fast_create(Enterprise, :identifier => 'contact_test_enterprise', :name => 'Test contact enteprise') login_as('contact_test_user') end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index ea9ce3c..ee606d7 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -360,7 +360,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase should 'not show message for disabled enterprise if there is a block for it' do login_as(@profile.identifier) - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) ent.boxes << Box.new ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new ent.save @@ -595,7 +595,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase should 'not show a profile in an environment that is not its home environment' do p = Profile.create!(:identifier => 'mytestprofile', :name => 'My test profile', :environment => Environment.default) - current = Environment.create!(:name => 'test environment') + current = fast_create(Environment, :name => 'test environment') current.domains.create!(:name => 'example.com') uses_host 'www.example.com' diff --git a/test/functional/favorite_enterprises_controller_test.rb b/test/functional/favorite_enterprises_controller_test.rb index 74753c9..33482d6 100644 --- a/test/functional/favorite_enterprises_controller_test.rb +++ b/test/functional/favorite_enterprises_controller_test.rb @@ -14,7 +14,7 @@ class FavoriteEnterprisesControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new self.profile = create_user('testuser').person - self.favorite_enterprise = Enterprise.create!(:name => 'the_enterprise', :identifier => 'the_enterprise') + self.favorite_enterprise = fast_create(Enterprise, :name => 'the_enterprise', :identifier => 'the_enterprise') login_as ('testuser') end attr_accessor :profile, :favorite_enterprise diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index b09c21b..1091909 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -11,7 +11,7 @@ class ManageProductsControllerTest < Test::Unit::TestCase @request = ActionController::TestRequest.new @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new - @enterprise = Enterprise.create(:name => 'teste', :identifier => 'test_ent') + @enterprise = fast_create(Enterprise, :name => 'teste', :identifier => 'test_ent') @user = create_user_with_permission('test_user', 'manage_products', @enterprise) login_as :test_user end diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index fa5087d..4b01512 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -99,7 +99,7 @@ class MembershipsControllerTest < Test::Unit::TestCase end should 'not show description to enterprises on list' do - enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise') + enterprise = fast_create(Enterprise, :identifier => 'enterprise-test', :name => 'my test enterprise') enterprise.add_member(profile) get :index, :profile => profile.identifier assert_no_tag :tag => 'li', :content => /Description:/ @@ -130,7 +130,7 @@ class MembershipsControllerTest < Test::Unit::TestCase should 'display destroy link only to communities' do community = Community.create!(:name => 'A community to destroy') - enterprise = Enterprise.create!(:name => 'A enterprise test', :identifier => 'enterprise-test') + enterprise = fast_create(Enterprise, :name => 'A enterprise test', :identifier => 'enterprise-test') person = Person['testuser'] community.add_admin(person) @@ -173,7 +173,7 @@ class MembershipsControllerTest < Test::Unit::TestCase template.boxes[0].blocks << Block.new template.save! - env = Environment.create!(:name => 'test_env') + env = fast_create(Environment, :name => 'test_env') env.settings[:community_template_id] = template.id env.save! diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index efecf6e..edf4eab 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -122,7 +122,7 @@ class ProfileControllerTest < Test::Unit::TestCase end should 'not show enterprises link to enterprise' do - ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') get :index, :profile => ent.identifier assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ } end @@ -257,7 +257,7 @@ class ProfileControllerTest < Test::Unit::TestCase should 'show message for disabled enterprise' do login_as(@profile.identifier) - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) get :index, :profile => ent.identifier assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise end @@ -271,7 +271,7 @@ class ProfileControllerTest < Test::Unit::TestCase should 'not show message for disabled enterprise if there is a block for it' do login_as(@profile.identifier) - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) ent.boxes << Box.new ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new ent.save @@ -280,7 +280,7 @@ class ProfileControllerTest < Test::Unit::TestCase end should 'display "Products" link for enterprise' do - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) get :index, :profile => 'my-test-enterprise' assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ @@ -290,7 +290,7 @@ class ProfileControllerTest < Test::Unit::TestCase env = Environment.default env.enable('disable_products_for_enterprises') env.save! - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false, :environment => env) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false, :environment_id => env.id) get :index, :profile => 'my-test-enterprise' assert_no_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ @@ -346,7 +346,8 @@ class ProfileControllerTest < Test::Unit::TestCase end should 'display contact us only if enabled' do - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enable_contact_us => false) + ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise') + ent.update_attribute(:enable_contact_us, false) get :index, :profile => 'my-test-enterprise' assert_no_tag :tag => 'a', :attributes => { :href => "/contact/my-test-enterprise/new" }, :content => 'Contact us' end diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index c2af2f7..d99348a 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -208,7 +208,8 @@ class ProfileDesignControllerTest < Test::Unit::TestCase should 'be able to edit ProductsBlock' do block = ProductsBlock.new - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise') + enterprise.boxes << Box.new p1 = enterprise.products.create!(:name => 'product one') p2 = enterprise.products.create!(:name => 'product two') enterprise.boxes.first.blocks << block @@ -228,7 +229,8 @@ class ProfileDesignControllerTest < Test::Unit::TestCase should 'be able to save ProductsBlock' do block = ProductsBlock.new - enterprise = Enterprise.create!(:name => "test", :identifier => 'testenterprise') + enterprise = fast_create(Enterprise, :name => "test", :identifier => 'testenterprise') + enterprise.boxes << Box.new p1 = enterprise.products.create!(:name => 'product one') p2 = enterprise.products.create!(:name => 'product two') enterprise.boxes.first.blocks << block @@ -256,7 +258,7 @@ class ProfileDesignControllerTest < Test::Unit::TestCase env = Environment.default env.enable('disable_products_for_enterprises') env.save! - ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :environment => env) + ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) person = create_user_with_permission('test_user', 'edit_profile_design', ent) login_as(person.user.login) diff --git a/test/functional/profile_members_controller_test.rb b/test/functional/profile_members_controller_test.rb index 3efcd44..1194a1e 100644 --- a/test/functional/profile_members_controller_test.rb +++ b/test/functional/profile_members_controller_test.rb @@ -23,7 +23,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase should 'not access index if dont have permission' do user = create_user('test_user') - Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') login_as :test_user get 'index', :profile => 'test_enterprise' @@ -33,7 +33,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'access index' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') user = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -44,7 +44,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'show form to change role' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') role = Profile::Roles.member(Environment.default) member = create_user('test_member').person @@ -63,7 +63,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'not show form to change role if person is not member' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') not_member = create_user('test_member').person user = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -76,7 +76,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'update roles' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') role1 = Role.create!(:name => 'member_role', :permissions => ['edit_profile'], :environment => ent.environment) role2 = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) @@ -95,7 +95,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'not update roles if user is not profile member' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'test enterprise') + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') role = Role.create!(:name => 'owner_role', :permissions => ['edit_profile', 'destroy_profile'], :environment => ent.environment) not_member = create_user('test_member').person @@ -129,7 +129,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'not list roles from other environments' do - env2 = Environment.create!(:name => 'new env') + env2 = fast_create(Environment, :name => 'new env') role = Role.create!(:name => 'some role', :environment => env2, :permissions => ['manage_memberships']) com = Community.create!(:name => 'test community') @@ -145,7 +145,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'enterprises have a add members button' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') u = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -177,7 +177,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'have a add_members page' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') u = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -188,7 +188,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'list current members when adding new members' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -198,7 +198,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'add member to profile' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -211,7 +211,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'add member with all roles' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -234,7 +234,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'find users' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') user = create_user_full('test_user').person u = create_user_with_permission('ent_user', 'manage_memberships', ent) login_as :ent_user @@ -245,7 +245,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'not appear add button for member in add members page' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -258,7 +258,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase daniel = create_user_full('daniel').person daniela = create_user_full('daniela').person - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user @@ -269,7 +269,7 @@ class ProfileMembersControllerTest < Test::Unit::TestCase end should 'ignore roles with id zero' do - ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') + ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') p = create_user_with_permission('test_user', 'manage_memberships', ent) login_as :test_user r = ent.environment.roles.create!(:name => 'test_role', :permissions => ['some_perm']) diff --git a/test/functional/region_validators_controller_test.rb b/test/functional/region_validators_controller_test.rb index 004f2cf..6df044b 100644 --- a/test/functional/region_validators_controller_test.rb +++ b/test/functional/region_validators_controller_test.rb @@ -31,7 +31,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase end should 'view validators for a specific region' do - environment = Environment.create!(:name => "my environment") + environment = fast_create(Environment, :name => "my environment") give_permission('ze', 'manage_environment_validators', environment) region = Region.new(:name => 'my region') environment.regions << region @@ -47,7 +47,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase end should 'search possible validators by name' do - environment = Environment.create!(:name => "my environment") + environment = fast_create(Environment, :name => "my environment") give_permission('ze', 'manage_environment_validators', environment) region = Region.new(:name => 'my region') environment.regions << region @@ -63,7 +63,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase end should 'be able to add validators to the current region' do - environment = Environment.create!(:name => "my environment") + environment = fast_create(Environment, :name => "my environment") give_permission('ze', 'manage_environment_validators', environment) region = Region.new(:name => 'my region') environment.regions << region @@ -80,7 +80,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase end should 'be able to remove validators from the current region' do - environment = Environment.create!(:name => "my environment") + environment = fast_create(Environment, :name => "my environment") give_permission('ze', 'manage_environment_validators', environment) region = Region.new(:name => 'my region') environment.regions << region -- libgit2 0.21.2