fixed image/HWP associations and some additional fixes to spec tests and 
controllers/forms.

Signed-off-by: Scott Seago <[email protected]>
---
 src/app/controllers/cloud_accounts_controller.rb   |   19 +++---
 src/app/controllers/provider_controller.rb         |   13 ----
 src/app/models/cloud_account.rb                    |   61 ++++++++++++++++
 src/app/models/hardware_profile.rb                 |   30 +++-----
 src/app/models/image.rb                            |   18 ++---
 src/app/models/pool.rb                             |   73 ++-----------------
 src/app/models/provider.rb                         |   12 +++
 src/app/util/taskomatic.rb                         |    8 ++
 src/app/views/cloud_accounts/_form.erb             |   13 ----
 src/app/views/cloud_accounts/_form.html.erb        |    2 +-
 src/app/views/cloud_accounts/new.html.erb          |   10 +--
 .../views/cloud_accounts/new_from_pool.html.erb    |   11 ---
 src/app/views/provider/accounts.html.erb           |    2 +-
 src/app/views/provider/new_account.html.erb        |   11 ---
 src/app/views/provider/show.html.erb               |   21 ------
 .../20090804135630_create_hardware_profiles.rb     |    1 -
 src/db/migrate/20090804140143_create_images.rb     |    1 -
 src/features/pool.feature                          |   16 ----
 .../controllers/cloud_accounts_controller_spec.rb  |   12 +++
 src/spec/controllers/provider_controller_spec.rb   |   10 ---
 src/spec/factories/image.rb                        |    3 +-
 src/spec/models/hardware_profile_spec.rb           |   55 ++-------------
 src/spec/models/image_spec.rb                      |   27 +-------
 23 files changed, 144 insertions(+), 285 deletions(-)
 delete mode 100644 src/app/views/cloud_accounts/_form.erb
 delete mode 100644 src/app/views/cloud_accounts/new_from_pool.html.erb
 delete mode 100644 src/app/views/provider/new_account.html.erb

diff --git a/src/app/controllers/cloud_accounts_controller.rb 
b/src/app/controllers/cloud_accounts_controller.rb
index ea0a34a..29be676 100644
--- a/src/app/controllers/cloud_accounts_controller.rb
+++ b/src/app/controllers/cloud_accounts_controller.rb
@@ -23,20 +23,21 @@ class CloudAccountsController < ApplicationController
   before_filter :require_user
 
   def new
+    @provider = Provider.find(params[:provider_id])
     @cloud_account = CloudAccount.new
-    @providers = []
-    all_providers = Provider.all
-    all_providers.each {|provider|
-      @providers << provider if authorized?(Privilege::PROVIDER_VIEW,provider)
-    }
+    require_privilege(Privilege::ACCOUNT_MODIFY, @provider)
   end
 
   def create
-    @cloud_account = CloudAccount.new(params[:cloud_account])
-    @provider = Provider.find(params[:provider][:id])
+    @provider = Provider.find(params[:cloud_account][:provider_id])
     require_privilege(Privilege::ACCOUNT_MODIFY,@provider)
-    @cloud_account.provider = @provider
-    @cloud_account.save!
+    @cloud_account = CloudAccount.new(params[:cloud_account])
+    if request.post? && @cloud_account.save && 
@cloud_account.populate_realms_and_images
+      flash[:notice] = "Provider account added."
+      redirect_to :controller => "provider", :action => "accounts", :id => 
@provider
+    else
+      render :action => "new"
+    end
   end
 
   def edit
diff --git a/src/app/controllers/provider_controller.rb 
b/src/app/controllers/provider_controller.rb
index 23b5ba0..7a4cefc 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -67,17 +67,4 @@ class ProviderController < ApplicationController
     require_privilege(Privilege::PROVIDER_VIEW, @provider)
   end
 
-  def new_account
-     @provider = Provider.find(params[:id])
-     require_privilege(Privilege::ACCOUNT_MODIFY, @provider)
-  end
-
-  def create_account
-     require_privilege(Privilege::ACCOUNT_MODIFY)
-     @acct = CloudAccount.find_or_create(params[:cloud_account])
-     @provider = Provider.find(params[:cloud_account][:provider_id])
-     @provider.cloud_accounts << @acct
-     redirect_to :action => 'accounts', :id => @provider.id
-  end
-
 end
diff --git a/src/app/models/cloud_account.rb b/src/app/models/cloud_account.rb
index f3dc317..9b8458d 100644
--- a/src/app/models/cloud_account.rb
+++ b/src/app/models/cloud_account.rb
@@ -63,7 +63,68 @@ class CloudAccount < ActiveRecord::Base
     provider.name + Realm::AGGREGATOR_REALM_PROVIDER_DELIMITER + username
   end
 
+  def pools
+    pools = []
+    instances.each do |instance|
+      pools << instance.pool
+    end
+  end
+
   def name
     username
   end
+
+  # FIXME: for already-mapped accounts, update rather than add new
+  def populate_realms_and_images
+    client = connect
+    realms = client.realms
+    # FIXME: the "self" filtering has to go as soon as we have a decent image 
selection UI
+    if client.driver_name == "ec2"
+      images = client.images(:owner_id=>:self)
+    else
+      images = client.images
+    end
+    # FIXME: this should probably be in the same transaction as 
cloud_account.save
+    self.transaction do
+      realms.each do |realm|
+        #ignore if it exists
+        #FIXME: we need to handle keeping in sync forupdates as well as
+        # account permissions
+        unless Realm.find_by_external_key_and_provider_id(realm.id,
+                                                          provider.id)
+          ar_realm = Realm.new(:external_key => realm.id,
+                               :name => realm.name ? realm.name : realm.id,
+                               :provider_id => provider.id)
+          ar_realm.save!
+        end
+      end
+      images.each do |image|
+        #ignore if it exists
+        #FIXME: we need to handle keeping in sync for updates as well as
+        # account permissions
+        ar_image = Image.find_by_external_key_and_provider_id(image.id,
+                                                              provider.id)
+        unless ar_image
+          ar_image = Image.new(:external_key => image.id,
+                               :name => image.name ? image.name :
+                               (image.description ? image.description :
+                                image.id),
+                               :architecture => image.architecture,
+                               :provider_id => provider.id)
+          ar_image.save!
+          front_end_image = Image.new(:external_key =>
+                                      provider.name +
+                                      
Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER +
+                                      ar_image.external_key,
+                                      :name => provider.name +
+                                      
Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER +
+                                      ar_image.name,
+                                      :architecture => ar_image.architecture)
+          front_end_image.provider_images << ar_image
+          front_end_image.save!
+        end
+      end
+    end
+  end
+
 end
diff --git a/src/app/models/hardware_profile.rb 
b/src/app/models/hardware_profile.rb
index 8330388..d98c2f9 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -24,7 +24,6 @@ class HardwareProfile < ActiveRecord::Base
   has_many :provider_instances, :class_name => "Instance",
            :foreign_key => "provider_hardware_profile_id"
   belongs_to :provider
-  belongs_to :pool
 
   has_and_belongs_to_many :aggregator_hardware_profiles,
                           :class_name => "HardwareProfile",
@@ -39,10 +38,10 @@ class HardwareProfile < ActiveRecord::Base
                           :association_foreign_key => 
"provider_hardware_profile_id"
 
   validates_presence_of :external_key
-  validates_uniqueness_of :external_key, :scope => [:provider_id, :pool_id]
+  validates_uniqueness_of :external_key, :scope => [:provider_id]
 
   validates_presence_of :name
-  validates_uniqueness_of :name
+  validates_uniqueness_of :name, :scope => [:provider_id]
 
   validates_presence_of :storage
   validates_numericality_of :storage, :greater_than => 0
@@ -51,28 +50,21 @@ class HardwareProfile < ActiveRecord::Base
 
   validates_presence_of :architecture, :if => :provider
 
+  def provider_hardware_profile?
+    !provider.nil?
+  end
+
+  # FIXME: what about custom instance profiles?
   def validate
-    if (provider.nil? and pool.nil?)
+    if provider.nil?
       if !aggregator_hardware_profiles.empty?
         errors.add(:aggregator_hardware_profiles,
-                   "Aggregator profiles are not allowed for custom Instance 
profiles")
-      end
-      if !provider_hardware_profiles.empty?
-        errors.add(:provider_hardware_profiles,
-                   "Provider profiles are not allowed for custom Instance 
profiles")
+                   "Aggregator profiles only allowed for provider profiles")
       end
-    elsif (!provider.nil? and !pool.nil?)
-      errors.add(:provider, "provider or pool must be blank")
-      errors.add(:pool, "provider or pool must be blank")
-    elsif provider.nil?
+    else
       if !provider_hardware_profiles.empty?
         errors.add(:provider_hardware_profiles,
-                   "Provider profiles only allowed for provider profiles")
-      end
-    elsif pool.nil?
-      if !aggregator_hardware_profiles.empty?
-        errors.add(:aggregator_hardware_profiles,
-                   "Aggregator profiles only allowed for pool profiles")
+                   "Provider profiles only allowed for aggregator profiles")
       end
     end
   end
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index 6670149..86806a4 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -22,7 +22,6 @@
 class Image < ActiveRecord::Base
   has_many :instances
   belongs_to :provider
-  belongs_to :pool
 
   has_and_belongs_to_many :aggregator_images,
                           :class_name => "Image",
@@ -37,26 +36,25 @@ class Image < ActiveRecord::Base
                           :association_foreign_key => "provider_image_id"
 
   validates_presence_of :external_key
-  validates_uniqueness_of :external_key, :scope => [:provider_id, :pool_id]
+  validates_uniqueness_of :external_key, :scope => [:provider_id]
 
   validates_presence_of :name
   validates_length_of :name, :maximum => 1024
 
   validates_presence_of :architecture, :if => :provider
 
+
+  def provider_image?
+    !provider.nil?
+  end
+
   def validate
-    if (provider.nil? and pool.nil?)
-      errors.add(:provider, "provider or pool must be specified")
-      errors.add(:pool, "provider or pool must be specified")
-    elsif (!provider.nil? and !pool.nil?)
-      errors.add(:provider, "provider or pool must be blank")
-      errors.add(:pool, "provider or pool must be blank")
-    elsif provider.nil?
+    if provider.nil?
       if !aggregator_images.empty?
         errors.add(:aggregator_images,
                    "Aggregator image only allowed for provider images")
       end
-    elsif pool.nil?
+    else
       if !provider_images.empty?
         errors.add(:provider_images,
                    "Provider images only allowed for aggregator images")
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 5b89a6b..a8657ee 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -48,6 +48,14 @@ class Pool < ActiveRecord::Base
     end
   end
 
+  def images
+    Image.find(:all, :conditions => {:provider_id => nil})
+  end
+
+  def hardware_profiles
+    HardwareProfile.find(:all, :conditions => {:provider_id => nil})
+  end
+
   #FIXME: do we still allow explicit cloud/account choice via realm selection?
   #FIXME: How is account list for realm defined without explicit pool-account 
relationship?
   def realms
@@ -63,69 +71,4 @@ class Pool < ActiveRecord::Base
     realm_list
   end
 
-  # FIXME: for already-mapped accounts, update rather than add new
-  # FIXME: this needs to be revised to handle the removal of the account-pool 
association
-  def populate_realms_and_images(accounts=CloudAccount.all)
-    accounts.each do |cloud_account|
-      client = cloud_account.connect
-      realms = client.realms
-      if client.driver_name == "ec2"
-        images = client.images(:owner_id=>:self)
-      else
-        images = client.images
-      end
-      # FIXME: this should probably be in the same transaction as pool.save
-      self.transaction do
-        realms.each do |realm|
-          #ignore if it exists
-          #FIXME: we need to handle keeping in sync forupdates as well as
-          # account permissions
-          unless Realm.find_by_external_key_and_provider_id(realm.id,
-                                                            
cloud_account.provider.id)
-            ar_realm = Realm.new(:external_key => realm.id,
-                                 :name => realm.name ? realm.name : realm.id,
-                                 :provider_id => cloud_account.provider.id)
-            ar_realm.save!
-          end
-        end
-        images.each do |image|
-          #ignore if it exists
-          #FIXME: we need to handle keeping in sync for updates as well as
-          # account permissions
-          ar_image = Image.find_by_external_key_and_provider_id(image.id,
-                                                     cloud_account.provider.id)
-          unless ar_image
-            ar_image = Image.new(:external_key => image.id,
-                                 :name => image.name ? image.name :
-                                          (image.description ? 
image.description :
-                                                               image.id),
-                                 :architecture => image.architecture,
-                                 :provider_id => cloud_account.provider.id)
-            ar_image.save!
-          end
-          front_end_image = Image.new(:external_key =>
-                                         
cloud_account.account_prefix_for_realm +
-                                         
Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER +
-                                         ar_image.external_key,
-                                  :name => ar_image.name,
-                                  :architecture => ar_image.architecture,
-                                  :pool_id => id)
-          front_end_image.save!
-        end
-        cloud_account.provider.hardware_profiles.each do |hardware_profile|
-          front_hardware_profile = HardwareProfile.new(:external_key =>
-                                         
cloud_account.account_prefix_for_realm +
-                                                       
hardware_profile.external_key,
-                               :name => hardware_profile.name,
-                               :memory => hardware_profile.memory,
-                               :storage => hardware_profile.storage,
-                               :architecture => hardware_profile.architecture,
-                               :pool_id => id)
-          front_hardware_profile.save!
-        end
-      end
-    end
-  end
-
-
 end
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index 4e4e3b7..20b9e1e 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -61,6 +61,18 @@ class Provider < ActiveRecord::Base
                                :architecture => hardware_profile.architecture,
                                :provider_id => id)
         ar_hardware_profile.save!
+        front_hwp = HardwareProfile.new(:external_key =>
+                                        name +
+                                        
Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER +
+                                        ar_hardware_profile.external_key,
+                                        :name => name +
+                                        
Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER +
+                                        ar_hardware_profile.name,
+                                        :memory => ar_hardware_profile.memory,
+                                        :storage => 
ar_hardware_profile.storage,
+                                        :architecture => 
ar_hardware_profile.architecture)
+        front_hwp.provider_hardware_profiles << ar_hardware_profile
+        front_hwp.save!
       end
     end
   end
diff --git a/src/app/util/taskomatic.rb b/src/app/util/taskomatic.rb
index c0dcbef..e66bb62 100644
--- a/src/app/util/taskomatic.rb
+++ b/src/app/util/taskomatic.rb
@@ -50,6 +50,14 @@ class Taskomatic
     begin
       client = @task.instance.cloud_account.connect
       realm = @task.instance.realm.external_key rescue nil
+
+      # Map aggregator HWP/image to back-end provider HWP/image in instance
+      unless @task.instance.image.provider_image?
+        @task.instance.image = @task.instance.image.provider_images[0]
+      end
+      unless @task.instance.hardware_profile.provider_hardware_profile?
+        @task.instance.hardware_profile = 
@task.instance.hardware_profile.provider_hardware_profiles[0]
+      end
       dcloud_instance = 
client.create_instance(@task.instance.image.external_key,
                                                :flavor => 
@task.instance.hardware_profile.external_key,
                                                :realm => realm,
diff --git a/src/app/views/cloud_accounts/_form.erb 
b/src/app/views/cloud_accounts/_form.erb
deleted file mode 100644
index 4fa1a79..0000000
--- a/src/app/views/cloud_accounts/_form.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-<ul>
-  <li>
-    <%= form.label :username, "Cloud Account username" %>
-    <%= form.text_field :username %>
-  </li>
-  <li>
-    <%= form.label :password, "Cloud Account password" %>
-    <%= form.password_field :password %>
-  </li>
-  <li>
-     <%= select("provider", "id", @providers.map{|p| [p.name,p.id]} , { 
:include_blank => false }) %>
-  </li>
-</ul>
diff --git a/src/app/views/cloud_accounts/_form.html.erb 
b/src/app/views/cloud_accounts/_form.html.erb
index 9b7b176..0d71953 100644
--- a/src/app/views/cloud_accounts/_form.html.erb
+++ b/src/app/views/cloud_accounts/_form.html.erb
@@ -3,7 +3,7 @@
 <%= hidden_field :cloud_account,  :id %>
 <%= hidden_field :cloud_account, :provider_id, :value => @provider.id %>
 <ul>
-<% if @cloud_account.nil? %>
+<% if @cloud_account.id.nil? %>
 <li><label>UserName<span>UserName for the account you wish to connect to this 
pool.</span></label><%= text_field :cloud_account, :username %></li>
 <% end %>
 <li><label>Password<span>Password for the account you wish to connect to this 
pool.</span></label><%=password_field :cloud_account, :password %></li>
diff --git a/src/app/views/cloud_accounts/new.html.erb 
b/src/app/views/cloud_accounts/new.html.erb
index 40f32cb..c8e6d60 100644
--- a/src/app/views/cloud_accounts/new.html.erb
+++ b/src/app/views/cloud_accounts/new.html.erb
@@ -1,14 +1,10 @@
-<% if @providers.size == 0 %>
-<h1>No Providers available to associate with a new cloud account</h1>
-<% else %>
-<h2 class="greeting">New Cloud Account</h2>
-
 <div class="dcloud_form">
+  <%= error_messages_for 'account' %>
+
+  <h2>Add a new Account from this Provider</h2><br />
   <% form_for @cloud_account, :url => { :action => "create" } do |f| %>
     <%= f.error_messages %>
       <%= render :partial => "form", :object => f %>
-    <%= f.submit "Create Cloud Account", :class => "submit" %>
   <% end %>
   <%= link_to "Cancel", root_path, :class => 'actionlink'  %>
 </div>
-<% end %>
diff --git a/src/app/views/cloud_accounts/new_from_pool.html.erb 
b/src/app/views/cloud_accounts/new_from_pool.html.erb
deleted file mode 100644
index 747df03..0000000
--- a/src/app/views/cloud_accounts/new_from_pool.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<h2 class="greeting">New Cloud Account</h2>
-
-<div class="dcloud_form">
-  <% form_for @cloud_account, :url => { :action => "create_from_pool" } do |f| 
%>
-    <%= f.error_messages %>
-      <%= render :partial => "form", :object => f %>
-    <%= hidden_field :pool, :id %>
-    <%= f.submit "Create Cloud Account", :class => "submit" %>
-  <% end %>
-  <%= link_to "Cancel", root_path, :class => 'actionlink'  %>
-</div>
diff --git a/src/app/views/provider/accounts.html.erb 
b/src/app/views/provider/accounts.html.erb
index a763a33..ddc8f27 100644
--- a/src/app/views/provider/accounts.html.erb
+++ b/src/app/views/provider/accounts.html.erb
@@ -20,4 +20,4 @@
     </tbody>
   </table>
 <% end %>
-<%= link_to "Add an account", {:action => "new_account", :id => @provider}, 
:class => "actionlink" %>
+<%= link_to "Add an account", {:controller => "cloud_accounts", :action => 
"new", :provider_id => @provider}, :class => "actionlink" %>
diff --git a/src/app/views/provider/new_account.html.erb 
b/src/app/views/provider/new_account.html.erb
deleted file mode 100644
index eed474f..0000000
--- a/src/app/views/provider/new_account.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<div class="dcloud_form">
-  <%= error_messages_for 'pool' %>
-  <%= error_messages_for 'account' %>
-
-  <h2>Create an Account for this Provider</h2><br />
-
-  <% form_tag :action => 'create_account' do |form| -%>
-    <%= render :partial => 'cloud_accounts/form' %>
-  <% end %>
-
-</div>
diff --git a/src/app/views/provider/show.html.erb 
b/src/app/views/provider/show.html.erb
index 0897828..f4213a9 100644
--- a/src/app/views/provider/show.html.erb
+++ b/src/app/views/provider/show.html.erb
@@ -1,24 +1,3 @@
-<% if @provider.pools.size == 0 %>
-<h1>There are no pools to display</h1>
-<% else %>
-    <table>
-      <thead>
-        <tr>
-        <th scope="col">Name</th>
-        <th scope="col">Instances</th>
-        </tr>
-      </thead>
-      <tbody>
-  <%[email protected] {|pool| %>
-        <tr>
-          <td><%= pool.name %></td>
-          <td><%= pool.instances.count %></td>
-        </tr>
-      <% } %>
-    </tbody>
-  </table>
-<% end %>
-<%= link_to "Add a pool",     {:controller => "pool", :action => "new", 
:provider => @provider}, :class => "actionlink" %>
 <%= link_to "Realms",  {:action => "realms", :id => @provider.id}, 
:class=>"actionlink"%>
 <%= link_to "Accounts",  {:action => "accounts", :id => @provider.id}, 
:class=>"actionlink"%>
 <%= link_to "User access",  {:controller => "permissions", :action => "list", 
:provider_id => @provider.id}, :class=>"actionlink" if has_view_perms? %>
diff --git a/src/db/migrate/20090804135630_create_hardware_profiles.rb 
b/src/db/migrate/20090804135630_create_hardware_profiles.rb
index f3e1b65..95bc0ce 100644
--- a/src/db/migrate/20090804135630_create_hardware_profiles.rb
+++ b/src/db/migrate/20090804135630_create_hardware_profiles.rb
@@ -28,7 +28,6 @@ class CreateHardwareProfiles < ActiveRecord::Migration
       t.float   :storage, :null => false
       t.string  :architecture, :null => false
       t.integer :provider_id
-      t.integer :pool_id
       t.integer :lock_version, :default => 0
       t.timestamps
     end
diff --git a/src/db/migrate/20090804140143_create_images.rb 
b/src/db/migrate/20090804140143_create_images.rb
index bb3db82..8c9c962 100644
--- a/src/db/migrate/20090804140143_create_images.rb
+++ b/src/db/migrate/20090804140143_create_images.rb
@@ -26,7 +26,6 @@ class CreateImages < ActiveRecord::Migration
       t.string  :name, :null => false, :limit => 1024
       t.string  :architecture, :null => false
       t.integer :provider_id
-      t.integer :pool_id
       t.integer :lock_version, :default => 0
       t.timestamps
     end
diff --git a/src/features/pool.feature b/src/features/pool.feature
index c96c2a9..5d8f219 100644
--- a/src/features/pool.feature
+++ b/src/features/pool.feature
@@ -45,19 +45,3 @@ Feature: Manage Pools
          When I follow "Realms"
          Then I should see "Europe"
          And I should see "United States"
-
-  Scenario: View Pool's Images
-       Given I own a pool named "mockpool"
-       And the Pool has the following Images:
-       | name      | architecture |
-       | Fedora 10 | x86_64       |
-       | Fedora 10 | i386         |
-       | JBoss     | i386         |
-       And I am on the homepage
-       When I follow "mockpool"
-       Then I should be on the show pool page
-       When I follow "View Images"
-       Then I should see the following:
-       | Fedora 10 | x86_64 |
-       | Fedora 10 | i386   |
-       | JBoss     | i386   |
diff --git a/src/spec/controllers/cloud_accounts_controller_spec.rb 
b/src/spec/controllers/cloud_accounts_controller_spec.rb
index f1d4a0d..d3e0f18 100644
--- a/src/spec/controllers/cloud_accounts_controller_spec.rb
+++ b/src/spec/controllers/cloud_accounts_controller_spec.rb
@@ -48,4 +48,16 @@ describe CloudAccountsController do
     response.should_not be_success
   end
 
+  it "should provide ui to create new account" do
+     UserSession.create(@admin)
+     get :new, :provider_id => @provider.id
+     response.should be_success
+     response.should render_template("new")
+  end
+
+  it "should fail to grant access to account UIs for unauthenticated user" do
+     get :new
+     response.should_not be_success
+  end
+
 end
diff --git a/src/spec/controllers/provider_controller_spec.rb 
b/src/spec/controllers/provider_controller_spec.rb
index de894ca..096af3d 100644
--- a/src/spec/controllers/provider_controller_spec.rb
+++ b/src/spec/controllers/provider_controller_spec.rb
@@ -17,19 +17,9 @@ describe ProviderController do
      response.should render_template("accounts")
   end
 
-  it "should provide ui to create new account" do
-     UserSession.create(@admin)
-     get :new_account, :id => @provider.id
-     response.should be_success
-     response.should render_template("new_account")
-  end
-
   it "should fail to grant access to account UIs for unauthenticated user" do
      get :accounts
      response.should_not be_success
-
-     get :new_account
-     response.should_not be_success
   end
 
   it "should provide ui to view hardware profiles" do
diff --git a/src/spec/factories/image.rb b/src/spec/factories/image.rb
index dc55ac0..cc0bc17 100644
--- a/src/spec/factories/image.rb
+++ b/src/spec/factories/image.rb
@@ -8,7 +8,6 @@ Factory.define :image do |i|
   i.provider { |p| Provider.new }
 end
 
-Factory.define :pool_image, :parent => :image do |i|
+Factory.define :front_end_image, :parent => :image do |i|
   i.provider nil
-  i.association(:pool)
 end
diff --git a/src/spec/models/hardware_profile_spec.rb 
b/src/spec/models/hardware_profile_spec.rb
index 78fc0a2..e2b09b4 100644
--- a/src/spec/models/hardware_profile_spec.rb
+++ b/src/spec/models/hardware_profile_spec.rb
@@ -55,69 +55,28 @@ describe HardwareProfile do
     @hp.should_not be_valid
   end
 
-  it "should reject Aggregator profiles for custom Instance profiles" do
+  it "should allow Aggregator profiles only for provider profiles" do
+    @hp.provider = nil
+
     @hp.aggregator_hardware_profiles << @hp
-    @hp.should_not be_valid
     @hp.should have(1).error_on(:aggregator_hardware_profiles)
     @hp.errors.on(:aggregator_hardware_profiles).should eql(
-      "Aggregator profiles are not allowed for custom Instance profiles")
+      "Aggregator profiles only allowed for provider profiles")
 
     @hp.aggregator_hardware_profiles.clear
     @hp.should be_valid
- end
-
-  it "should reject Provider profiles for custom Instance profiles" do
-    @hp.provider_hardware_profiles << @hp
-    @hp.should_not be_valid
-    @hp.should have(1).error_on(:provider_hardware_profiles)
-    @hp.errors.on(:provider_hardware_profiles).should eql(
-      "Provider profiles are not allowed for custom Instance profiles")
-
-    @hp.provider_hardware_profiles.clear
-    @hp.should be_valid
   end
 
-  it "should require either provider or pool to be blank" do
+  it "should allow Provider profiles only for aggregator profiles" do
     @hp.provider = Provider.new
-    @hp.pool = Pool.new
-    @hp.should_not be_valid
-    @hp.should have(1).error_on(:provider)
-    @hp.errors.on(:provider).should eql("provider or pool must be blank")
-    @hp.should have(1).error_on(:pool)
-    @hp.errors.on(:pool).should eql("provider or pool must be blank")
-
-    @hp.provider = nil
-    @hp.should be_valid
 
-    @hp.provider = Provider.new
-    @hp.pool = nil
-    @hp.should be_valid
-  end
-
-  it "should allow Provider profiles only for provider profiles" do
-    @hp.provider = nil
-    @hp.pool = Pool.new
-
-    @hp.provider_hardware_profiles << @hp
+    @hp.aggregator_hardware_profiles << @hp
     @hp.should have(1).error_on(:provider_hardware_profiles)
     @hp.errors.on(:provider_hardware_profiles).should eql(
-      "Provider profiles only allowed for provider profiles")
+      "Provider profiles only allowed for aggregator profiles")
 
     @hp.provider_hardware_profiles.clear
     @hp.should be_valid
   end
 
-  it "should allow Aggregator profiles only for pool profiles" do
-    @hp.provider = Provider.new
-    @hp.pool = nil
-
-    @hp.aggregator_hardware_profiles << @hp
-    @hp.should have(1).error_on(:aggregator_hardware_profiles)
-    @hp.errors.on(:aggregator_hardware_profiles).should eql(
-      "Aggregator profiles only allowed for pool profiles")
-
-    @hp.aggregator_hardware_profiles.clear
-    @hp.should be_valid
-  end
-
 end
diff --git a/src/spec/models/image_spec.rb b/src/spec/models/image_spec.rb
index de68475..a0fd8ca 100644
--- a/src/spec/models/image_spec.rb
+++ b/src/spec/models/image_spec.rb
@@ -46,33 +46,8 @@ describe Image do
     i.should be_valid
   end
 
-  it "should have either a provider or a pool specified" do
-    i = Factory.build(:image, :provider => nil, :pool => nil)
-    i.should have(1).error_on(:provider)
-    i.should have(1).error_on(:pool)
-    i.errors.on(:provider).should eql(
-      "provider or pool must be specified")
-    i.errors.on(:pool).should eql(
-      "provider or pool must be specified")
-
-    i.provider = @provider
-    i.should be_valid
-
-    i.pool = Factory.build(:pool)
-    i.should have(1).error_on(:provider)
-    i.should have(1).error_on(:pool)
-    i.errors.on(:provider).should eql(
-      "provider or pool must be blank")
-    i.errors.on(:pool).should eql(
-      "provider or pool must be blank")
-
-    i.provider = nil
-    i.should be_valid
-  end
-
   it "should have provider images only if it has a provider" do
-    i = Factory.create(:image, :pool => Pool.new,
-                     :provider => nil)
+    i = Factory.create(:image, :provider => nil)
 
     i.aggregator_images << i
     i.should have(1).error_on(:aggregator_images)
-- 
1.6.2.5

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to