summaryrefslogtreecommitdiff
path: root/lib/generators/nifty/scaffold/templates/tests/shoulda/actions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/nifty/scaffold/templates/tests/shoulda/actions')
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb13
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb8
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb13
7 files changed, 58 insertions, 0 deletions
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb
new file mode 100644
index 0000000..f305367
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb
@@ -0,0 +1,13 @@
+ context "create action" do
+ should "render new template when model is invalid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ post :create
+ assert_template 'new'
+ end
+
+ should "redirect when model is valid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ post :create
+ assert_redirected_to <%= item_path_for_test('url') %>
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb
new file mode 100644
index 0000000..ea20133
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb
@@ -0,0 +1,8 @@
+ context "destroy action" do
+ should "destroy model and redirect to index action" do
+ <%= instance_name %> = <%= class_name %>.first
+ delete :destroy, :id => <%= instance_name %>
+ assert_redirected_to <%= items_url %>
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb
new file mode 100644
index 0000000..47597d0
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb
@@ -0,0 +1,6 @@
+ context "edit action" do
+ should "render edit template" do
+ get :edit, :id => <%= class_name %>.first
+ assert_template 'edit'
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb
new file mode 100644
index 0000000..44b056b
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb
@@ -0,0 +1,6 @@
+ context "index action" do
+ should "render index template" do
+ get :index
+ assert_template 'index'
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb
new file mode 100644
index 0000000..5857a55
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb
@@ -0,0 +1,6 @@
+ context "new action" do
+ should "render new template" do
+ get :new
+ assert_template 'new'
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb
new file mode 100644
index 0000000..75b37f6
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb
@@ -0,0 +1,6 @@
+ context "show action" do
+ should "render show template" do
+ get :show, :id => <%= class_name %>.first
+ assert_template 'show'
+ end
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb
new file mode 100644
index 0000000..fc46f72
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb
@@ -0,0 +1,13 @@
+ context "update action" do
+ should "render edit template when model is invalid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ put :update, :id => <%= class_name %>.first
+ assert_template 'edit'
+ end
+
+ should "redirect when model is valid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ put :update, :id => <%= class_name %>.first
+ assert_redirected_to <%= item_path_for_test('url') %>
+ end
+ end