[PATCH conductor 2/2] Added rspec examples for flash[:error] in deployables#new

jzigmund at redhat.com jzigmund at redhat.com
Thu Feb 2 15:26:06 UTC 2012


From: Jozef Zigmund <jzigmund at redhat.com>

---
 .../controllers/deployables_controller_spec.rb     |   29 ++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/spec/controllers/deployables_controller_spec.rb b/src/spec/controllers/deployables_controller_spec.rb
index ec96d7c..e45e232 100644
--- a/src/spec/controllers/deployables_controller_spec.rb
+++ b/src/spec/controllers/deployables_controller_spec.rb
@@ -15,6 +15,7 @@
 #
 
 require 'spec_helper'
+require "pry"
 
 describe DeployablesController do
 
@@ -25,6 +26,34 @@ describe DeployablesController do
     mock_warden(@admin)
   end
 
+  describe "#new" do
+    context "with params[:create_from_image]" do
+      before do
+        @deployable = stub_model(Deployable, :name => "test_new", :id => 1)
+        @image = mock(Aeolus::Image::Warehouse::Image, :id => '3c58e0d6-d11a-4e68-8b12-233783e56d35', :name => 'image1', :uuid => '3c58e0d6-d11a-4e68-8b12-233783e56d35')
+        Aeolus::Image::Warehouse::Image.stub(:find).and_return(@image)
+      end
+
+      it "returns flash[:error] when no hardware profile exists" do
+        get :new, :create_from_image => @image.id
+        flash[:error].should eql(["No hardware profile exists! Please create one."])
+      end
+
+      it "returns flash[:error] when no catalog and hardware profile exists" do
+        Catalog.stub(:list_for_user).and_return([])
+        get :new, :create_from_image => @image.id
+        flash[:error].should eql(["No catalog exists! Please create one.","No hardware profile exists! Please create one."])
+      end
+
+      it "returns flash[:error] when no catalog exists" do
+        Catalog.stub(:list_for_user).and_return([])
+        HardwareProfile.stub(:list_for_user).and_return([mock(HardwareProfile)])
+        get :new, :create_from_image => @image.id
+        flash[:error].should eql(["No catalog exists! Please create one."])
+      end
+    end
+  end
+
   describe "#create" do
     before(:each) do
       @image = mock(Aeolus::Image::Warehouse::Image, :id => '3c58e0d6-d11a-4e68-8b12-233783e56d35', :name => 'image1', :uuid => '3c58e0d6-d11a-4e68-8b12-233783e56d35')
-- 
1.7.7.6




More information about the aeolus-devel mailing list