Commit 01946cfcb312b53d8946e5452f4194451382dbad

Authored by Antonio Terceiro
1 parent 8aebd432

Fix broken tests

test/functional/categories_controller_test.rb
... ... @@ -29,8 +29,7 @@ class CategoriesControllerTest < ActionController::TestCase
29 29 end
30 30  
31 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 33 get :index
35 34 assert_response :success
36 35 assert_template 'index'
... ...
test/functional/manage_products_controller_test.rb
... ... @@ -383,9 +383,10 @@ class ManageProductsControllerTest < ActionController::TestCase
383 383 end
384 384  
385 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 390 product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
390 391 get :show, :id => product.id, :profile => @enterprise.identifier
391 392  
... ... @@ -402,9 +403,9 @@ class ManageProductsControllerTest < ActionController::TestCase
402 403 end
403 404  
404 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 409 product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
409 410 get :show, :id => product.id, :profile => @enterprise.identifier
410 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 413 end
413 414  
414 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 419 product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
419 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 425 end
425 426  
426 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 431 product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
431 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 818 should 'be able to destroy communities' do
819 819 community = fast_create(Community)
820 820  
821   - person = fast_create(Person)
  821 + person = create_user('foo').person
822 822 community.add_admin(person)
823 823  
824 824 assert_difference Community, :count, -1 do
... ... @@ -828,11 +828,12 @@ class ProfileEditorControllerTest < ActionController::TestCase
828 828  
829 829 should 'not be able to destroy communities if is a regular member' do
830 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 837 assert_difference Community, :count, 0 do
837 838 post :destroy_profile, :profile => community.identifier
838 839 end
... ... @@ -841,7 +842,7 @@ class ProfileEditorControllerTest < ActionController::TestCase
841 842 should 'be able to destroy enterprise' do
842 843 enterprise = fast_create(Enterprise)
843 844  
844   - person = fast_create(Person)
  845 + person = create_user('foo').person
845 846 enterprise.add_admin(person)
846 847  
847 848 assert_difference Enterprise, :count, -1 do
... ... @@ -851,11 +852,12 @@ class ProfileEditorControllerTest < ActionController::TestCase
851 852  
852 853 should 'not be able to destroy enterprise if is a regular member' do
853 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 861 assert_difference Enterprise, :count, 0 do
860 862 post :destroy_profile, :profile => enterprise.identifier
861 863 end
... ...