From: Jan Provaznik <jprovazn(a)redhat.com>
---
.../controllers/catalog_entries_controller_spec.rb | 48 ++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
create mode 100644 src/spec/controllers/catalog_entries_controller_spec.rb
diff --git a/src/spec/controllers/catalog_entries_controller_spec.rb
b/src/spec/controllers/catalog_entries_controller_spec.rb
new file mode 100644
index 0000000..0f2aa68
--- /dev/null
+++ b/src/spec/controllers/catalog_entries_controller_spec.rb
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe CatalogEntriesController do
+ fixtures :all
+ before(:each) do
+ @admin_permission = FactoryGirl.create(:admin_permission)
+ @admin = @admin_permission.user
+ end
+
+ context "JSON format responses for " do
+ before do
+ accept_json
+ mock_warden(@admin)
+ end
+
+ describe "#create" do
+ before do
+ @entry = Factory.build(:catalog_entry)
+ CatalogEntry.stub!(:new).and_return(@entry)
+ post :create
+ end
+
+ it { response.should be_success }
+ it { ActiveSupport::JSON.decode(response.body)["name"].should ==
@entry.name }
+ end
+
+ describe "#update" do
+ before do
+ @entry = Factory.create(:catalog_entry)
+ post :update, {:id => @entry.id, :catalog_entry => {:name =>
'new_name'}}
+ end
+
+ it { response.should be_success }
+ it { ActiveSupport::JSON.decode(response.body)["name"].should ==
'new_name' }
+ end
+
+ describe "#destroy" do
+ before do
+ @entry = Factory.build(:deployment)
+ Deployment.stub!(:find).and_return([@entry])
+ delete :destroy, :id => @entry.id, :format => :json
+ end
+
+ it { response.should redirect_to(catalog_entries_path) }
+ end
+ end
+
+end
--
1.7.6.2