From ac4008f740e0ed151032ff648af58be94810c116 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 4 Sep 2008 16:06:22 +0000 Subject: [PATCH] ActionItem629: renaming controller the right way --- test/functional/enterprise_validation_controller_test.rb | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/functional/enterprise_validation_test.rb | 149 ----------------------------------------------------------------------------------------------------------------------------------------------------- 2 files changed, 149 insertions(+), 149 deletions(-) create mode 100644 test/functional/enterprise_validation_controller_test.rb delete mode 100644 test/functional/enterprise_validation_test.rb diff --git a/test/functional/enterprise_validation_controller_test.rb b/test/functional/enterprise_validation_controller_test.rb new file mode 100644 index 0000000..8c35346 --- /dev/null +++ b/test/functional/enterprise_validation_controller_test.rb @@ -0,0 +1,149 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'enterprise_validation_controller' + +# Re-raise errors caught by the controller. +class EnterpriseValidationController; def rescue_action(e) raise e end; end + +class EnterpriseValidationControllerTest < Test::Unit::TestCase + + all_fixtures + + def setup + @controller = EnterpriseValidationController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + login_as 'ze' + @org = Organization.create!(:identifier => 'myorg', :name => "My Org") + give_permission('ze', 'validate_enterprise', @org) + Profile.expects(:find_by_identifier).with('myorg').returns(@org).at_least_once + end + + def test_local_files_reference + assert_local_files_reference :get, :index, :profile => 'myorg' + end + + def test_valid_xhtml + + # FIXME remove this after enable assert_valid_xhtml + Profile.find_by_identifier('myorg') + + assert_valid_xhtml :get, :index, :profile => 'myorg' + end + + should 'list pending validations on index' do + empty = [] + @org.expects(:pending_validations).returns(empty) + get :index, :profile => 'myorg' + assert_same empty, assigns(:pending_validations) + assert_template 'index' + end + + should 'display details and prompt for needed data when approving or rejecting enterprise' do + validating = CreateEnterprise.new + @org.expects(:find_pending_validation).with('kakakaka').returns(validating) + + get :details, :profile => 'myorg', :id => 'kakakaka' + assert_same validating, assigns(:pending) + end + + should 'refuse to validate unexisting request' do + @org.expects(:find_pending_validation).with('kakakaka').returns(nil) + get :details , :profile => 'myorg', :id => 'kakakaka' + assert_response 404 + end + + should 'be able to actually validate enterprise on request' do + validation = CreateEnterprise.new + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) + validation.expects(:approve) + validation.expects(:code).returns('kakakaka') + post :approve, :profile => 'myorg', :id => 'kakakaka' + assert_redirected_to :action => 'view_processed', :id => 'kakakaka' + end + + should 'be able to reject an enterprise' do + validation = CreateEnterprise.new + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) + validation.expects(:reject) + validation.expects(:code).returns('kakakaka') + post :reject, :profile => 'myorg', :id => 'kakakaka', :reject_explanation => 'this is not a solidarity economy enterprise' + assert_redirected_to :action => 'view_processed', :id => 'kakakaka' + end + + should 'require the user to fill in the explanation for an rejection' do + validation = CreateEnterprise.new + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) + + # FIXME: this is not working, but should. Anyway the assert_response and + # assert_template below in some test some things we need. But the + # expectation below must be put to work. + # + #validation.expects(:reject).raises(ActiveRecord::RecordInvalid) + + post :reject, :profile => 'myorg', :id => 'kakakaka' + assert_response :success + assert_template 'details' + end + + should 'list validations already processed' do + processed_validations = [CreateEnterprise.new] + @org.expects(:processed_validations).returns(processed_validations) + + get :list_processed, :profile => 'myorg' + + assert_same processed_validations, assigns(:processed_validations) + + assert_response :success + assert_template 'list_processed' + end + + should 'be able to display a validation that was already processed' do + validation = CreateEnterprise.new + @org.expects(:find_processed_validation).with('kakakaka').returns(validation) + get :view_processed, :profile => 'myorg', :id => 'kakakaka' + assert_same validation, assigns(:processed) + end + + should 'display a form for editing the validation info' do + info = ValidationInfo.new(:validation_methodology => 'none') + @org.expects(:validation_info).returns(info) + get :edit_validation_info, :profile => 'myorg' + assert_response :success + assert_equal info, assigns(:info) + end + + should 'save an alteration of the validation info' do + info = ValidationInfo.new(:validation_methodology => 'none') + @org.expects(:validation_info).returns(info) + post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => 'new methodology'} + + assert_response :redirect + assert_redirected_to :action => 'index' + assert_equal info, assigns(:info) + end + + should 'not save an empaty validation mthodology' do + info = ValidationInfo.new(:validation_methodology => 'none') + @org.expects(:validation_info).returns(info) + post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => ''} + + assert_response :success + assert_equal info, assigns(:info) + end + + should 'filter html from methodology of the validation info' do + info = ValidationInfo.new(:validation_methodology => 'none') + @org.expects(:validation_info).returns(info) + post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => 'new methodology'} + assert_sanitized assigns(:info).validation_methodology + end + + should 'filter html from restrictions of the validation info' do + info = ValidationInfo.new(:validation_methodology => 'none') + @org.expects(:validation_info).returns(info) + post :edit_validation_info, :profile => 'myorg', :info => {:restrictions => 'new methodology'} + assert_sanitized assigns(:info).restrictions + end + +end diff --git a/test/functional/enterprise_validation_test.rb b/test/functional/enterprise_validation_test.rb deleted file mode 100644 index 8c35346..0000000 --- a/test/functional/enterprise_validation_test.rb +++ /dev/null @@ -1,149 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'enterprise_validation_controller' - -# Re-raise errors caught by the controller. -class EnterpriseValidationController; def rescue_action(e) raise e end; end - -class EnterpriseValidationControllerTest < Test::Unit::TestCase - - all_fixtures - - def setup - @controller = EnterpriseValidationController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - login_as 'ze' - @org = Organization.create!(:identifier => 'myorg', :name => "My Org") - give_permission('ze', 'validate_enterprise', @org) - Profile.expects(:find_by_identifier).with('myorg').returns(@org).at_least_once - end - - def test_local_files_reference - assert_local_files_reference :get, :index, :profile => 'myorg' - end - - def test_valid_xhtml - - # FIXME remove this after enable assert_valid_xhtml - Profile.find_by_identifier('myorg') - - assert_valid_xhtml :get, :index, :profile => 'myorg' - end - - should 'list pending validations on index' do - empty = [] - @org.expects(:pending_validations).returns(empty) - get :index, :profile => 'myorg' - assert_same empty, assigns(:pending_validations) - assert_template 'index' - end - - should 'display details and prompt for needed data when approving or rejecting enterprise' do - validating = CreateEnterprise.new - @org.expects(:find_pending_validation).with('kakakaka').returns(validating) - - get :details, :profile => 'myorg', :id => 'kakakaka' - assert_same validating, assigns(:pending) - end - - should 'refuse to validate unexisting request' do - @org.expects(:find_pending_validation).with('kakakaka').returns(nil) - get :details , :profile => 'myorg', :id => 'kakakaka' - assert_response 404 - end - - should 'be able to actually validate enterprise on request' do - validation = CreateEnterprise.new - @org.expects(:find_pending_validation).with('kakakaka').returns(validation) - validation.expects(:approve) - validation.expects(:code).returns('kakakaka') - post :approve, :profile => 'myorg', :id => 'kakakaka' - assert_redirected_to :action => 'view_processed', :id => 'kakakaka' - end - - should 'be able to reject an enterprise' do - validation = CreateEnterprise.new - @org.expects(:find_pending_validation).with('kakakaka').returns(validation) - validation.expects(:reject) - validation.expects(:code).returns('kakakaka') - post :reject, :profile => 'myorg', :id => 'kakakaka', :reject_explanation => 'this is not a solidarity economy enterprise' - assert_redirected_to :action => 'view_processed', :id => 'kakakaka' - end - - should 'require the user to fill in the explanation for an rejection' do - validation = CreateEnterprise.new - @org.expects(:find_pending_validation).with('kakakaka').returns(validation) - - # FIXME: this is not working, but should. Anyway the assert_response and - # assert_template below in some test some things we need. But the - # expectation below must be put to work. - # - #validation.expects(:reject).raises(ActiveRecord::RecordInvalid) - - post :reject, :profile => 'myorg', :id => 'kakakaka' - assert_response :success - assert_template 'details' - end - - should 'list validations already processed' do - processed_validations = [CreateEnterprise.new] - @org.expects(:processed_validations).returns(processed_validations) - - get :list_processed, :profile => 'myorg' - - assert_same processed_validations, assigns(:processed_validations) - - assert_response :success - assert_template 'list_processed' - end - - should 'be able to display a validation that was already processed' do - validation = CreateEnterprise.new - @org.expects(:find_processed_validation).with('kakakaka').returns(validation) - get :view_processed, :profile => 'myorg', :id => 'kakakaka' - assert_same validation, assigns(:processed) - end - - should 'display a form for editing the validation info' do - info = ValidationInfo.new(:validation_methodology => 'none') - @org.expects(:validation_info).returns(info) - get :edit_validation_info, :profile => 'myorg' - assert_response :success - assert_equal info, assigns(:info) - end - - should 'save an alteration of the validation info' do - info = ValidationInfo.new(:validation_methodology => 'none') - @org.expects(:validation_info).returns(info) - post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => 'new methodology'} - - assert_response :redirect - assert_redirected_to :action => 'index' - assert_equal info, assigns(:info) - end - - should 'not save an empaty validation mthodology' do - info = ValidationInfo.new(:validation_methodology => 'none') - @org.expects(:validation_info).returns(info) - post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => ''} - - assert_response :success - assert_equal info, assigns(:info) - end - - should 'filter html from methodology of the validation info' do - info = ValidationInfo.new(:validation_methodology => 'none') - @org.expects(:validation_info).returns(info) - post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => 'new methodology'} - assert_sanitized assigns(:info).validation_methodology - end - - should 'filter html from restrictions of the validation info' do - info = ValidationInfo.new(:validation_methodology => 'none') - @org.expects(:validation_info).returns(info) - post :edit_validation_info, :profile => 'myorg', :info => {:restrictions => 'new methodology'} - assert_sanitized assigns(:info).restrictions - end - -end -- libgit2 0.21.2