From 01946cfcb312b53d8946e5452f4194451382dbad Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 23 Dec 2011 00:11:13 +0000 Subject: [PATCH] Fix broken tests --- test/functional/categories_controller_test.rb | 3 +-- test/functional/manage_products_controller_test.rb | 17 +++++++++-------- test/functional/profile_editor_controller_test.rb | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index 0b9d3f5..724a772 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -29,8 +29,7 @@ class CategoriesControllerTest < ActionController::TestCase end def test_index - assert user = login_as(create_admin_user(Environment.default)) - assert user.person.has_permission?('manage_environment_categories',Environment.default ), "#{user.login} don't have permission to manage_environment_categories in #{Environment.default.name}" + login_as(create_admin_user(Environment.default)) get :index assert_response :success assert_template 'index' diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index 1f51925..5a8bc95 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -383,9 +383,10 @@ class ManageProductsControllerTest < ActionController::TestCase end should 'not display tabs if description and inputs are empty and user is not allowed' do - not_allowed_person = fast_create(Person) + create_user('foo') + + login_as 'foo' - login_as not_allowed_person.identifier product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) get :show, :id => product.id, :profile => @enterprise.identifier @@ -402,9 +403,9 @@ class ManageProductsControllerTest < ActionController::TestCase end should 'display only description tab if inputs are empty and user is not allowed' do - not_allowed_person = fast_create(Person) + create_user('foo') - login_as not_allowed_person.identifier + login_as 'foo' product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) get :show, :id => product.id, :profile => @enterprise.identifier assert_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }, :descendant => {:tag => 'a', :attributes => {:href => '#product-description'}, :content => 'Description'} @@ -412,9 +413,9 @@ class ManageProductsControllerTest < ActionController::TestCase end should 'display only inputs tab if description is empty and user is not allowed' do - not_allowed_person = fast_create(Person) + create_user 'foo' - login_as not_allowed_person.identifier + login_as 'foo' product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) @@ -424,9 +425,9 @@ class ManageProductsControllerTest < ActionController::TestCase end should 'display tabs if description and inputs are not empty and user is not allowed' do - not_allowed_person = fast_create(Person) + create_user('foo') - login_as not_allowed_person.identifier + login_as 'foo' product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index fe2eefe..87bd0f8 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -818,7 +818,7 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'be able to destroy communities' do community = fast_create(Community) - person = fast_create(Person) + person = create_user('foo').person community.add_admin(person) assert_difference Community, :count, -1 do @@ -828,11 +828,12 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'not be able to destroy communities if is a regular member' do community = fast_create(Community) + community.add_admin(fast_create(Person)) # first member is admin by default - person = fast_create(Person) - community.add_admin(person) + person = create_user('foo').person + community.add_member(person) - login_as(person.identifier) + login_as 'foo' assert_difference Community, :count, 0 do post :destroy_profile, :profile => community.identifier end @@ -841,7 +842,7 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'be able to destroy enterprise' do enterprise = fast_create(Enterprise) - person = fast_create(Person) + person = create_user('foo').person enterprise.add_admin(person) assert_difference Enterprise, :count, -1 do @@ -851,11 +852,12 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'not be able to destroy enterprise if is a regular member' do enterprise = fast_create(Enterprise) + enterprise.add_member(fast_create(Person)) # first member is admin by default - person = fast_create(Person) - enterprise.add_admin(person) + person = create_user('foo').person + enterprise.add_member(person) - login_as(person.identifier) + login_as('foo') assert_difference Enterprise, :count, 0 do post :destroy_profile, :profile => enterprise.identifier end -- libgit2 0.21.2