new ui / backend, cleaned up, and included tests
---
src/app/controllers/portal_pool_controller.rb | 4 +++
src/app/views/portal_pool/accounts.html.erb | 21 ++++++++++++++++++++
.../controllers/portal_pool_controller_spec.rb | 19 ++++++++++++++++++
src/spec/factories/portal_pool.rb | 8 +++++++
4 files changed, 52 insertions(+), 0 deletions(-)
create mode 100644 src/app/views/portal_pool/accounts.html.erb
create mode 100644 src/spec/controllers/portal_pool_controller_spec.rb
create mode 100644 src/spec/factories/portal_pool.rb
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb
index 24e530d..0b6ea6e 100644
--- a/src/app/controllers/portal_pool_controller.rb
+++ b/src/app/controllers/portal_pool_controller.rb
@@ -33,6 +33,10 @@ class PortalPoolController < ApplicationController
@instances = @pool.instances
end
+ def accounts
+ @pool = PortalPool.find(params[:id])
+ end
+
def new
@portal_pool = PortalPool.new
@account = CloudAccount.new
diff --git a/src/app/views/portal_pool/accounts.html.erb b/src/app/views/portal_pool/accounts.html.erb
new file mode 100644
index 0000000..b6042d6
--- /dev/null
+++ b/src/app/views/portal_pool/accounts.html.erb
@@ -0,0 +1,21 @@
+<% if @pool.cloud_accounts.size == 0 %>
+<h1>There are no accounts to display</h1>
+<% else %>
+ <table>
+ <thead>
+ <tr>
+ <th scope="col">Provider</th>
+ <th scope="col">Username</th>
+ </tr>
+ </thead>
+ <tbody>
+ <%(a)pool.cloud_accounts.each {|account| %>
+ <tr>
+ <td><%= account.provider.name %></td>
+ <td><%= account.username %></td>
+ </tr>
+ <% } %>
+ </tbody>
+ </table>
+<% end %>
+<%= link_to "Add an account", {:controller => "portal_pool", :action => "new_account", :pool => @pool.id}, :class => "actionlink" %>
diff --git a/src/spec/controllers/portal_pool_controller_spec.rb b/src/spec/controllers/portal_pool_controller_spec.rb
new file mode 100644
index 0000000..6b3a09c
--- /dev/null
+++ b/src/spec/controllers/portal_pool_controller_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe PortalPoolController do
+
+ before(:each) do
+ @pool = Factory :tpool
+ @tuser = Factory :tuser
+ activate_authlogic
+ end
+
+ it "should get cloud accounts" do
+ UserSession.create(@tuser)
+ get :accounts, :id => @pool.id
+ response.should be_success
+ response.should render_template("accounts")
+ @pool.should_not == nil
+ end
+
+end
diff --git a/src/spec/factories/portal_pool.rb b/src/spec/factories/portal_pool.rb
new file mode 100644
index 0000000..0b20647
--- /dev/null
+++ b/src/spec/factories/portal_pool.rb
@@ -0,0 +1,8 @@
+Factory.define :portal_pool do |p|
+ p.name 'mypool'
+ p.owner { |owner| owner.association(:user, :login => 'pool_owner', :email => 'pool_owner(a)example.com') }
+end
+
+Factory.define :tpool, :parent => :portal_pool do |p|
+ p.name 'tpool'
+end
--
1.6.2.5