summaryrefslogtreecommitdiff
path: root/lib/generators/nifty/scaffold/templates/tests/testunit/actions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/nifty/scaffold/templates/tests/testunit/actions')
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb11
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb11
7 files changed, 44 insertions, 0 deletions
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb
new file mode 100644
index 0000000..5a6d2ac
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb
@@ -0,0 +1,11 @@
+ def test_create_invalid
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ post :create
+ assert_template 'new'
+ end
+
+ def test_create_valid
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ post :create
+ assert_redirected_to <%= item_path_for_test('url') %>
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb
new file mode 100644
index 0000000..adedf91
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb
@@ -0,0 +1,6 @@
+ def test_destroy
+ <%= instance_name %> = <%= class_name %>.first
+ delete :destroy, :id => <%= instance_name %>
+ assert_redirected_to <%= items_url %>
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb
new file mode 100644
index 0000000..55ed24a
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb
@@ -0,0 +1,4 @@
+ def test_edit
+ get :edit, :id => <%= class_name %>.first
+ assert_template 'edit'
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb
new file mode 100644
index 0000000..22d3bad
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb
@@ -0,0 +1,4 @@
+ def test_index
+ get :index
+ assert_template 'index'
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb
new file mode 100644
index 0000000..c551327
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb
@@ -0,0 +1,4 @@
+ def test_new
+ get :new
+ assert_template 'new'
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb
new file mode 100644
index 0000000..b74f371
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb
@@ -0,0 +1,4 @@
+ def test_show
+ get :show, :id => <%= class_name %>.first
+ assert_template 'show'
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb
new file mode 100644
index 0000000..b588bfc
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb
@@ -0,0 +1,11 @@
+ def test_update_invalid
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ put :update, :id => <%= class_name %>.first
+ assert_template 'edit'
+ end
+
+ def test_update_valid
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ put :update, :id => <%= class_name %>.first
+ assert_redirected_to <%= item_path_for_test('url') %>
+ end