diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index eb7d608..9f8991a 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -40,8 +40,8 @@ class ApplicationController < ActionController::Base
end
end
- def render_not_found(path)
- @path = path
+ def render_not_found(path = nil)
+ @path ||= request.path
render(:file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'not_found.rhtml'), :layout => 'not_found', :status => 404) && false
end
diff --git a/app/controllers/profile_admin/enterprise_validation_controller.rb b/app/controllers/profile_admin/enterprise_validation_controller.rb
index 21d04eb..36ddd50 100644
--- a/app/controllers/profile_admin/enterprise_validation_controller.rb
+++ b/app/controllers/profile_admin/enterprise_validation_controller.rb
@@ -1,8 +1,14 @@
class EnterpriseValidationController < ProfileAdminController
def index
- #@pending = profile.pending_validations
- render :text => profile.inspect
+ @pending_validations = profile.pending_validations
+ end
+
+ def details
+ @pending = profile.pending_validations(:code => params[:id]).first
+ unless @pending
+ render_not_found
+ end
end
end
diff --git a/app/controllers/public/enterprise_registration_controller.rb b/app/controllers/public/enterprise_registration_controller.rb
index 92c2edf..7977982 100644
--- a/app/controllers/public/enterprise_registration_controller.rb
+++ b/app/controllers/public/enterprise_registration_controller.rb
@@ -1,5 +1,7 @@
class EnterpriseRegistrationController < ApplicationController
+ before_filter :login_required
+
# Just go to the first step.
#
# FIXME: shouldn't this action present some sort of welcome message and point
diff --git a/app/views/enterprise_validation/index.rhtml b/app/views/enterprise_validation/index.rhtml
new file mode 100644
index 0000000..a4247d1
--- /dev/null
+++ b/app/views/enterprise_validation/index.rhtml
@@ -0,0 +1,21 @@
+
<%= _("Pending enterprise validations") %>
+
+<% for pending in @pending_validations %>
+ <%= pending.name %>
+
+ -
+ <%= _('Address') %>:
+ <%= pending.address %>
+
+ -
+ <%= _('Contact Phone') %>:
+ <%= pending.contact_phone %>
+
+ -
+ <%= _('Contact Person') %>:
+ <%= pending.contact_person %>
+
+
+
+ <%= link_to _("See details/approve/reject"), :action => 'details', :id => pending.code %>
+<% end %>
diff --git a/test/functional/enterprise_validation_test.rb b/test/functional/enterprise_validation_test.rb
index e75aa45..fec65c6 100644
--- a/test/functional/enterprise_validation_test.rb
+++ b/test/functional/enterprise_validation_test.rb
@@ -13,18 +13,39 @@ all_fixtures
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as 'ze'
+
+ @org = Organization.create!(:identifier => 'myorg', :name => "My Org")
+ Profile.expects(:find_by_identifier).with('myorg').returns(@org).at_least_once
end
should 'list pending validations on index' do
- flunk 'not yet'
+ empty = []
+ @org.expects(:pending_validations).returns(empty)
+ get :index, :profile => 'myorg'
+ assert_same empty, assigns(:pending_validations)
+ assert_template 'index'
end
- should 'prompt for needed data when approving or rejecting enterprise' do
- flunk 'not yet'
+ should 'display details and prompt for needed data when approving or rejecting enterprise' do
+ validating = CreateEnterprise.new
+ @org.expects(:pending_validations).with(:code => 'kakakaka').returns([validating])
+
+ get :details, :profile => 'myorg', :id => 'kakakaka'
+ assert_same validating, assigns(:pending)
+ end
+
+ should 'refuse to validate unexisting request' do
+ @org.expects(:pending_validations).with(:code => 'kakakaka').returns([])
+ get :details , :profile => 'myorg', :id => 'kakakaka'
+ assert_response 404
end
should 'be able to actually validate enterprise on request' do
flunk 'not yet'
end
+ should 'be able to reject an enterprise' do
+ flunk 'not yet'
+ end
+
end
--
libgit2 0.21.2