Commit 01946cfcb312b53d8946e5452f4194451382dbad
1 parent
8aebd432
Exists in
master
and in
29 other branches
Fix broken tests
Showing
3 changed files
with
20 additions
and
18 deletions
Show diff stats
test/functional/categories_controller_test.rb
@@ -29,8 +29,7 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -29,8 +29,7 @@ class CategoriesControllerTest < ActionController::TestCase | ||
29 | end | 29 | end |
30 | 30 | ||
31 | def test_index | 31 | def test_index |
32 | - assert user = login_as(create_admin_user(Environment.default)) | ||
33 | - assert user.person.has_permission?('manage_environment_categories',Environment.default ), "#{user.login} don't have permission to manage_environment_categories in #{Environment.default.name}" | 32 | + login_as(create_admin_user(Environment.default)) |
34 | get :index | 33 | get :index |
35 | assert_response :success | 34 | assert_response :success |
36 | assert_template 'index' | 35 | assert_template 'index' |
test/functional/manage_products_controller_test.rb
@@ -383,9 +383,10 @@ class ManageProductsControllerTest < ActionController::TestCase | @@ -383,9 +383,10 @@ class ManageProductsControllerTest < ActionController::TestCase | ||
383 | end | 383 | end |
384 | 384 | ||
385 | should 'not display tabs if description and inputs are empty and user is not allowed' do | 385 | should 'not display tabs if description and inputs are empty and user is not allowed' do |
386 | - not_allowed_person = fast_create(Person) | 386 | + create_user('foo') |
387 | + | ||
388 | + login_as 'foo' | ||
387 | 389 | ||
388 | - login_as not_allowed_person.identifier | ||
389 | product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) | 390 | product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
390 | get :show, :id => product.id, :profile => @enterprise.identifier | 391 | get :show, :id => product.id, :profile => @enterprise.identifier |
391 | 392 | ||
@@ -402,9 +403,9 @@ class ManageProductsControllerTest < ActionController::TestCase | @@ -402,9 +403,9 @@ class ManageProductsControllerTest < ActionController::TestCase | ||
402 | end | 403 | end |
403 | 404 | ||
404 | should 'display only description tab if inputs are empty and user is not allowed' do | 405 | should 'display only description tab if inputs are empty and user is not allowed' do |
405 | - not_allowed_person = fast_create(Person) | 406 | + create_user('foo') |
406 | 407 | ||
407 | - login_as not_allowed_person.identifier | 408 | + login_as 'foo' |
408 | product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) | 409 | product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
409 | get :show, :id => product.id, :profile => @enterprise.identifier | 410 | get :show, :id => product.id, :profile => @enterprise.identifier |
410 | assert_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }, :descendant => {:tag => 'a', :attributes => {:href => '#product-description'}, :content => 'Description'} | 411 | 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 | @@ -412,9 +413,9 @@ class ManageProductsControllerTest < ActionController::TestCase | ||
412 | end | 413 | end |
413 | 414 | ||
414 | should 'display only inputs tab if description is empty and user is not allowed' do | 415 | should 'display only inputs tab if description is empty and user is not allowed' do |
415 | - not_allowed_person = fast_create(Person) | 416 | + create_user 'foo' |
416 | 417 | ||
417 | - login_as not_allowed_person.identifier | 418 | + login_as 'foo' |
418 | product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) | 419 | product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
419 | input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) | 420 | input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) |
420 | 421 | ||
@@ -424,9 +425,9 @@ class ManageProductsControllerTest < ActionController::TestCase | @@ -424,9 +425,9 @@ class ManageProductsControllerTest < ActionController::TestCase | ||
424 | end | 425 | end |
425 | 426 | ||
426 | should 'display tabs if description and inputs are not empty and user is not allowed' do | 427 | should 'display tabs if description and inputs are not empty and user is not allowed' do |
427 | - not_allowed_person = fast_create(Person) | 428 | + create_user('foo') |
428 | 429 | ||
429 | - login_as not_allowed_person.identifier | 430 | + login_as 'foo' |
430 | product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) | 431 | product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
431 | input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) | 432 | input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id) |
432 | 433 |
test/functional/profile_editor_controller_test.rb
@@ -818,7 +818,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -818,7 +818,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
818 | should 'be able to destroy communities' do | 818 | should 'be able to destroy communities' do |
819 | community = fast_create(Community) | 819 | community = fast_create(Community) |
820 | 820 | ||
821 | - person = fast_create(Person) | 821 | + person = create_user('foo').person |
822 | community.add_admin(person) | 822 | community.add_admin(person) |
823 | 823 | ||
824 | assert_difference Community, :count, -1 do | 824 | assert_difference Community, :count, -1 do |
@@ -828,11 +828,12 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -828,11 +828,12 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
828 | 828 | ||
829 | should 'not be able to destroy communities if is a regular member' do | 829 | should 'not be able to destroy communities if is a regular member' do |
830 | community = fast_create(Community) | 830 | community = fast_create(Community) |
831 | + community.add_admin(fast_create(Person)) # first member is admin by default | ||
831 | 832 | ||
832 | - person = fast_create(Person) | ||
833 | - community.add_admin(person) | 833 | + person = create_user('foo').person |
834 | + community.add_member(person) | ||
834 | 835 | ||
835 | - login_as(person.identifier) | 836 | + login_as 'foo' |
836 | assert_difference Community, :count, 0 do | 837 | assert_difference Community, :count, 0 do |
837 | post :destroy_profile, :profile => community.identifier | 838 | post :destroy_profile, :profile => community.identifier |
838 | end | 839 | end |
@@ -841,7 +842,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -841,7 +842,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
841 | should 'be able to destroy enterprise' do | 842 | should 'be able to destroy enterprise' do |
842 | enterprise = fast_create(Enterprise) | 843 | enterprise = fast_create(Enterprise) |
843 | 844 | ||
844 | - person = fast_create(Person) | 845 | + person = create_user('foo').person |
845 | enterprise.add_admin(person) | 846 | enterprise.add_admin(person) |
846 | 847 | ||
847 | assert_difference Enterprise, :count, -1 do | 848 | assert_difference Enterprise, :count, -1 do |
@@ -851,11 +852,12 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -851,11 +852,12 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
851 | 852 | ||
852 | should 'not be able to destroy enterprise if is a regular member' do | 853 | should 'not be able to destroy enterprise if is a regular member' do |
853 | enterprise = fast_create(Enterprise) | 854 | enterprise = fast_create(Enterprise) |
855 | + enterprise.add_member(fast_create(Person)) # first member is admin by default | ||
854 | 856 | ||
855 | - person = fast_create(Person) | ||
856 | - enterprise.add_admin(person) | 857 | + person = create_user('foo').person |
858 | + enterprise.add_member(person) | ||
857 | 859 | ||
858 | - login_as(person.identifier) | 860 | + login_as('foo') |
859 | assert_difference Enterprise, :count, 0 do | 861 | assert_difference Enterprise, :count, 0 do |
860 | post :destroy_profile, :profile => enterprise.identifier | 862 | post :destroy_profile, :profile => enterprise.identifier |
861 | end | 863 | end |