also some various small fixes
---
src/app/controllers/pool_controller.rb | 14 ++++++++++++++
src/app/views/pool/edit.html.erb | 14 ++++++++++++++
src/app/views/pool/new.html.erb | 1 +
src/app/views/pool/show.html.erb | 1 +
src/spec/controllers/pool_controller_spec.rb | 13 ++++++++++++-
5 files changed, 42 insertions(+), 1 deletions(-)
create mode 100644 src/app/views/pool/edit.html.erb
diff --git a/src/app/controllers/pool_controller.rb
b/src/app/controllers/pool_controller.rb
index cf751e0..6291aa2 100644
--- a/src/app/controllers/pool_controller.rb
+++ b/src/app/controllers/pool_controller.rb
@@ -81,6 +81,20 @@ class PoolController < ApplicationController
redirect_to :action => 'show', :id => @pool.id
end
+ def edit
+ @pool = Pool.find params[:id]
+ end
+
+ def update
+ @pool = Pool.find params[:id]
+ @name = params[:pool][:name]
+ unless @pool.nil? || @name.nil?
+ @pool.name = @name
+ @pool.save!
+ end
+ redirect_to :action => 'show', :id => @pool.id
+ end
+
def delete
end
diff --git a/src/app/views/pool/edit.html.erb b/src/app/views/pool/edit.html.erb
new file mode 100644
index 0000000..f1a0c6f
--- /dev/null
+++ b/src/app/views/pool/edit.html.erb
@@ -0,0 +1,14 @@
+<div class="dcloud_form">
+ <%= error_messages_for 'pool' %>
+
+ <h2>Edit Pool</h2>
+ <% form_tag({:action => 'update'}, :method => 'put') do
-%>
+ <fieldset>
+ <legend>Pool</legend>
+ <ul>
+ <li><label>Name<span>Provide a descriptive name for this
pool.</span></label><%= text_field :pool, :name, :value => @pool.name
%></li>
+ </ul>
+ </fieldset>
+ <%= submit_tag "Save", :class => "submit" %>
+ <% end %>
+</div>
diff --git a/src/app/views/pool/new.html.erb b/src/app/views/pool/new.html.erb
index b1e329f..2a30a7a 100644
--- a/src/app/views/pool/new.html.erb
+++ b/src/app/views/pool/new.html.erb
@@ -5,6 +5,7 @@
<h2>Create a new Pool</h2><br />
<% form_tag :action => 'create' do -%>
+ <fieldset>
<legend>Pool</legend>
<ul>
<li><label>Name<span>Provide a descriptive name for this
pool.</span></label><%= text_field :pool, :name %></li>
diff --git a/src/app/views/pool/show.html.erb b/src/app/views/pool/show.html.erb
index 015f13b..667240e 100644
--- a/src/app/views/pool/show.html.erb
+++ b/src/app/views/pool/show.html.erb
@@ -35,6 +35,7 @@
</tbody>
</table>
<% end %>
+<%= link_to "Edit Pool", {:action => "edit", :id =>
@pool.id}, :class=>"actionlink"%>
<%= link_to "Add a new instance", {:controller => "instance",
:action => "new", :id => @pool}, :class=>"actionlink"%>
<%= link_to "Back end Accounts", {:action => "accounts", :id
=> @pool.id}, :class=>"actionlink"%>
<%= link_to "User access", {:controller => "permissions",
:action => "list", :pool_id => @pool.id},
:class=>"actionlink" if has_view_perms? %>
diff --git a/src/spec/controllers/pool_controller_spec.rb
b/src/spec/controllers/pool_controller_spec.rb
index 71131b8..3448186 100644
--- a/src/spec/controllers/pool_controller_spec.rb
+++ b/src/spec/controllers/pool_controller_spec.rb
@@ -2,6 +2,7 @@ require 'spec_helper'
describe PoolController do
+ fixtures :all
before(:each) do
@admin_permission = Factory :admin_permission
@admin = @admin_permission.user
@@ -26,7 +27,17 @@ describe PoolController do
post :create, :pool => { :name => 'foopool' }
end.should change(Pool, :count).by(1)
id = Pool.find(:first, :conditions => ['name = ?',
'foopool']).id
- response.should redirect_to("http://test.host/pool/show/#{id}")
+ response.should redirect_to("http://test.host/pool/#{id}")
+ end
+
+ it "should provider means to update pool" do
+ UserSession.create(@admin)
+ post :create, :pool => { :name => 'update-test-pool' }
+ pool_id = Pool.find(:first, :conditions => ['name = ?',
'update-test-pool']).id
+
+ post :update, :id => pool_id, :pool => {:name =>
'new-update-test-pool'}
+ pool = Pool.find(:first, :conditions => ['name = ?',
'new-update-test-pool'])
+ pool.id.should == pool_id
end
it "should provide ui to view hardware profiles" do
--
1.6.2.5