From ae2c32316f541c8c3d89e96650d4bffcaf8e8039 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 8 Nov 2007 20:42:19 +0000 Subject: [PATCH] ActionItem16: checkpoint; almost there --- app/controllers/profile_admin/enterprise_validation_controller.rb | 30 ++++++++++++++++++++++++++++++ app/views/enterprise_validation/_details.rhtml | 42 ++++++++++++++++++++++++++++++++++++++++++ app/views/enterprise_validation/details.rhtml | 43 +------------------------------------------ app/views/enterprise_validation/view_processed.rhtml | 3 +++ test/functional/enterprise_validation_test.rb | 30 ++++++++++++++++++++++++++++-- 5 files changed, 104 insertions(+), 44 deletions(-) create mode 100644 app/views/enterprise_validation/_details.rhtml create mode 100644 app/views/enterprise_validation/view_processed.rhtml diff --git a/app/controllers/profile_admin/enterprise_validation_controller.rb b/app/controllers/profile_admin/enterprise_validation_controller.rb index 8b66296..c493859 100644 --- a/app/controllers/profile_admin/enterprise_validation_controller.rb +++ b/app/controllers/profile_admin/enterprise_validation_controller.rb @@ -11,4 +11,34 @@ class EnterpriseValidationController < ProfileAdminController end end + post_only :approve + def approve + @pending = profile.find_pending_validation(params[:id]) + if @pending + @pending.approve + redirect_to :action => 'view_processed', :id => @pending.code + else + render_not_found + end + end + + post_only :reject + def reject + @pending = profile.find_pending_validation(params[:id]) + @pending.reject_explanation = params[:reject_explanation] + if @pending + @pending.reject + redirect_to :action => 'view_processed', :id => @pending.code + else + render_not_found + end + end + + def view_processed + @processed = profile.find_processed_validation(params[:id]) + unless @processed + render_not_found + end + end + end diff --git a/app/views/enterprise_validation/_details.rhtml b/app/views/enterprise_validation/_details.rhtml new file mode 100644 index 0000000..7fa49fe --- /dev/null +++ b/app/views/enterprise_validation/_details.rhtml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= _('Name') %><%= request.name %>
<%= _('Address') %><%= request.address %>
<%= _('Contact Phone') %><%= request.contact_phone %>
<%= _('Contact Person') %><%= request.contact_person %>
<%= _('Acronym') %><%= request.acronym %>
<%= _('Identifier') %><%= request.identifier %>
<%= _('Foundation Year') %><%= request.foundation_year %>
<%= _('Legal Year') %><%= request.legal_form %>
<%= _('Economic Activity') %><%= request.economic_activity %>
<%= _('Management Information') %><%= request.management_information %>
diff --git a/app/views/enterprise_validation/details.rhtml b/app/views/enterprise_validation/details.rhtml index 4cd917c..d34efc0 100644 --- a/app/views/enterprise_validation/details.rhtml +++ b/app/views/enterprise_validation/details.rhtml @@ -2,48 +2,7 @@

<%= _('Provided information') %>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= _('Name') %><%= @pending.name %>
<%= _('Address') %><%= @pending.address %>
<%= _('Contact Phone') %><%= @pending.contact_phone %>
<%= _('Contact Person') %><%= @pending.contact_person %>
<%= _('Acronym') %><%= @pending.acronym %>
<%= _('Identifier') %><%= @pending.identifier %>
<%= _('Foundation Year') %><%= @pending.foundation_year %>
<%= _('Legal Year') %><%= @pending.legal_form %>
<%= _('Economic Activity') %><%= @pending.economic_activity %>
<%= _('Management Information') %><%= @pending.management_information %>
+<%= render :partial => 'details', :locals => { :request => @pending } %>

<%= _('Final decision') %>

diff --git a/app/views/enterprise_validation/view_processed.rhtml b/app/views/enterprise_validation/view_processed.rhtml new file mode 100644 index 0000000..9e33adb --- /dev/null +++ b/app/views/enterprise_validation/view_processed.rhtml @@ -0,0 +1,3 @@ +

<%= _('Processed validation request for %s ') % @processed.name %>

+ +<%= render :partial => 'details', :locals => { :request => @processed } %> diff --git a/test/functional/enterprise_validation_test.rb b/test/functional/enterprise_validation_test.rb index 1b6cca3..cf0a496 100644 --- a/test/functional/enterprise_validation_test.rb +++ b/test/functional/enterprise_validation_test.rb @@ -41,15 +41,41 @@ all_fixtures end should 'be able to actually validate enterprise on request' do - flunk 'not yet' + 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 - flunk 'not yet' + 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' + assert_redirected_to :action => 'view_processed', :id => 'kakakaka' end should 'require the user to fill in the justification for an rejection' do + validation = CreateEnterprise.new + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) + 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 flunk 'not yet' 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 end -- libgit2 0.21.2