From b80bd744ad873f6fc43018bc4bfb90677de167bd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 17 Dec 2012 12:01:45 +0100 Subject: Start of GS5. --- .../scaffold/templates/tests/shoulda/actions/create.rb | 13 +++++++++++++ .../scaffold/templates/tests/shoulda/actions/destroy.rb | 8 ++++++++ .../nifty/scaffold/templates/tests/shoulda/actions/edit.rb | 6 ++++++ .../nifty/scaffold/templates/tests/shoulda/actions/index.rb | 6 ++++++ .../nifty/scaffold/templates/tests/shoulda/actions/new.rb | 6 ++++++ .../nifty/scaffold/templates/tests/shoulda/actions/show.rb | 6 ++++++ .../scaffold/templates/tests/shoulda/actions/update.rb | 13 +++++++++++++ .../nifty/scaffold/templates/tests/shoulda/controller.rb | 5 +++++ .../nifty/scaffold/templates/tests/shoulda/model.rb | 7 +++++++ 9 files changed, 70 insertions(+) create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb (limited to 'lib/generators/nifty/scaffold/templates/tests/shoulda') 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 diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb new file mode 100644 index 0000000..e9f9764 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class <%= plural_class_name %>ControllerTest < ActionController::TestCase + <%= controller_methods 'tests/shoulda/actions' %> +end diff --git a/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb b/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb new file mode 100644 index 0000000..9065963 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class <%= class_name %>Test < ActiveSupport::TestCase + should "be valid" do + assert <%= class_name %>.new.valid? + end +end -- cgit v1.2.3