Commit a1b213861c9bcdae59c2816ca7ae34a61ca3ada5
1 parent
50f157d5
Exists in
master
and in
28 other branches
ActionItem114: changed some test cases and fixed some errors and added some all_…
…fixtures to some tests git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@825 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
15 changed files
with
50 additions
and
38 deletions
Show diff stats
app/controllers/application.rb
... | ... | @@ -38,7 +38,8 @@ class ApplicationController < ActionController::Base |
38 | 38 | end |
39 | 39 | |
40 | 40 | def load_profile |
41 | - @profile = Profile.find_by_identifier(params[:profile]) | |
41 | + @profile ||= Profile.find_by_identifier(params[:profile]) | |
42 | +# @profile ||= Profile.find(:first) | |
42 | 43 | render_not_found(request.path) unless @profile |
43 | 44 | end |
44 | 45 | ... | ... |
app/controllers/profile_admin/profile_editor_controller.rb
test/functional/application_controller_test.rb
... | ... | @@ -6,8 +6,8 @@ class TestController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ApplicationControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :profiles, :environments, :domains, :design_boxes | |
10 | - | |
9 | +# all_fixtures:profiles, :environments, :domains, :design_boxes | |
10 | + all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = TestController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/categories_controller_test.rb
... | ... | @@ -5,7 +5,7 @@ require 'categories_controller' |
5 | 5 | class CategoriesController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class CategoriesControllerTest < Test::Unit::TestCase |
8 | - | |
8 | + all_fixtures | |
9 | 9 | def setup |
10 | 10 | @controller = CategoriesController.new |
11 | 11 | @request = ActionController::TestRequest.new |
... | ... | @@ -17,7 +17,7 @@ class CategoriesControllerTest < Test::Unit::TestCase |
17 | 17 | assert (@cat1 = env.categories.create(:name => 'another category')) |
18 | 18 | login_as(create_admin_user(@env)) |
19 | 19 | end |
20 | - all_fixtures | |
20 | + | |
21 | 21 | attr_reader :env, :cat1, :cat2 |
22 | 22 | |
23 | 23 | def test_index | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -6,8 +6,8 @@ class ContentViewerController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ContentViewerControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :domains, :environments, :users, :profiles, :comatose_pages | |
10 | - | |
9 | +# all_fixtures:domains, :environments, :users, :profiles, :comatose_pages | |
10 | +all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = ContentViewerController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/edit_template_controller_test.rb
... | ... | @@ -7,7 +7,7 @@ require 'edit_template_controller' |
7 | 7 | class EditTemplateController; def rescue_action(e) raise e end; end |
8 | 8 | |
9 | 9 | class EditTemplateControllerTest < Test::Unit::TestCase |
10 | - | |
10 | + all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = EditTemplateController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/enterprise_registration_controller_test.rb
... | ... | @@ -6,8 +6,8 @@ class EnterpriseRegistrationController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class EnterpriseRegistrationControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :users | |
10 | - | |
9 | +# all_fixtures:users | |
10 | +all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = EnterpriseRegistrationController.new |
13 | 13 | @request = ActionController::TestRequest.new |
... | ... | @@ -46,9 +46,16 @@ class EnterpriseRegistrationControllerTest < Test::Unit::TestCase |
46 | 46 | validator1 = mock() |
47 | 47 | validator1.expects(:id).returns(1) |
48 | 48 | validator1.expects(:name).returns("validator1") |
49 | + validator1.expects(:validation_methodology).returns("methodology1") | |
50 | + validator1.expects(:validation_restrictions).returns("restrictions1") | |
51 | + | |
49 | 52 | validator2 = mock() |
50 | 53 | validator2.expects(:id).returns(2) |
51 | 54 | validator2.expects(:name).returns("validator2") |
55 | + validator2.expects(:validation_methodology).returns("methodology2") | |
56 | + validator2.expects(:validation_restrictions).returns("restrictions2") | |
57 | + | |
58 | + | |
52 | 59 | region = mock() |
53 | 60 | region.expects(:validators).returns([validator1, validator2]).at_least_once |
54 | 61 | create_enterprise.expects(:region).returns(region) | ... | ... |
test/functional/enterprise_validation_test.rb
... | ... | @@ -6,8 +6,8 @@ class EnterpriseValidationController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class EnterpriseValidationControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :users | |
10 | - | |
9 | +# all_fixtures:users | |
10 | +all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = EnterpriseValidationController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/home_controller_test.rb
... | ... | @@ -6,8 +6,8 @@ class HomeController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class HomeControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :profiles, :environments, :domains | |
10 | - | |
9 | +# all_fixtures:profiles, :environments, :domains | |
10 | +all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = HomeController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/manage_tags_controller_test.rb
... | ... | @@ -6,8 +6,8 @@ class ManageTagsController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ManageTagsControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :profiles, :design_boxes, :design_blocks, :domains | |
10 | - | |
9 | +# all_fixtures:profiles, :design_boxes, :design_blocks, :domains | |
10 | +all_fixtures | |
11 | 11 | def setup |
12 | 12 | @controller = ManageTagsController.new |
13 | 13 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/profile_admin_controller_test.rb
test/functional/profile_editor_controller_test.rb
... | ... | @@ -5,6 +5,8 @@ require 'profile_editor_controller' |
5 | 5 | class ProfileEditorController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ProfileEditorControllerTest < Test::Unit::TestCase |
8 | + all_fixtures | |
9 | + | |
8 | 10 | def setup |
9 | 11 | @controller = ProfileEditorController.new |
10 | 12 | @request = ActionController::TestRequest.new |
... | ... | @@ -13,10 +15,14 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
13 | 15 | end |
14 | 16 | |
15 | 17 | def test_index |
16 | - profile = Profile.create(:name => 'a test profile', :identifier => 'test_profile') | |
17 | - | |
18 | - get :index, :profile => profile.identifier | |
19 | - assert_template :index | |
18 | + person = User.create(:login => 'test_profile', :email => 'test@noosfero.org', :password => 'test', :password_confirmation => 'test').person | |
19 | + person.person_info.name = 'a test profile' | |
20 | + person.person_info.address = 'my address' | |
21 | + person.person_info.contact_information = 'my contact information' | |
22 | + person.person_info.save | |
23 | + | |
24 | + get :index, :profile => person.identifier | |
25 | + assert_template 'index' | |
20 | 26 | assert_response :success |
21 | 27 | assert_not_nil assigns(:profile) |
22 | 28 | |
... | ... | @@ -26,26 +32,23 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
26 | 32 | end |
27 | 33 | |
28 | 34 | def test_edit_person_info |
29 | - profile = Person.new | |
30 | - profile.name = 'a test profile' | |
31 | - profile.person_info.address = 'my address' | |
32 | - profile.person_info.contact_information = 'my contact information' | |
33 | - @controller.instance_variable_set('@profile', profile) | |
35 | + person = User.create(:login => 'test_profile', :email => 'test@noosfero.org', :password => 'test', :password_confirmation => 'test').person | |
34 | 36 | |
35 | - get :edit, :profile => 'test_profile' | |
37 | + assert person.valid? | |
38 | + get :edit, :profile => person.identifier | |
39 | + assert_template 'person_info' | |
36 | 40 | assert_response :success |
37 | 41 | assert_template 'person_info' |
38 | 42 | |
39 | 43 | end |
40 | 44 | |
41 | - def test_saving_profile_info | |
42 | - profile = Person.new | |
43 | - profile.name = 'a test profile' | |
44 | - profile.person_info.address = 'my address' | |
45 | - profile.person_info.contact_information = 'my contact information' | |
46 | - @controller.instance_variable_set('@profile', profile) | |
47 | - | |
48 | - profile.person_info.expects(:update_attributes).with({ 'contact_information' => 'new contact information', 'address' => 'new address' }).returns(true) | |
45 | + def test_saving_profile_info | |
46 | + person = User.create(:login => 'test_profile', :email => 'test@noosfero.org', :password => 'test', :password_confirmation => 'test').person | |
47 | + person.person_info.address = 'my address' | |
48 | + person.person_info.contact_information = 'my contact information' | |
49 | + person.person_info.save | |
50 | + | |
51 | +# profile.person_info.expects(:update_attributes).with({ 'contact_information' => 'new contact information', 'address' => 'new address' }).returns(true) | |
49 | 52 | post :edit, :profile => 'test_profile', :info => { 'contact_information' => 'new contact information', 'address' => 'new address' } |
50 | 53 | |
51 | 54 | assert_redirected_to :action => 'index' | ... | ... |
test/functional/region_validators_controller_test.rb
... | ... | @@ -5,7 +5,7 @@ require 'region_validators_controller' |
5 | 5 | class RegionValidatorsController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class RegionValidatorsControllerTest < Test::Unit::TestCase |
8 | - | |
8 | + all_fixtures | |
9 | 9 | def setup |
10 | 10 | @controller = RegionValidatorsController.new |
11 | 11 | @request = ActionController::TestRequest.new | ... | ... |
test/functional/role_controller_test.rb