ajax_scaffold_generator 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2006 Richard White
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2006 Richard White
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README CHANGED
@@ -1,28 +1,28 @@
1
- Description:
2
- The ajax scaffold generator creates a controller to interact with a model.
3
- If the model does not exist, it creates the model as well. Unlike the
4
- standard scaffold, the ajax scaffold generator uses AJAX.
5
-
6
- The generator takes a model name, an optional controller name, and a
7
- list of views as arguments. Scaffolded actions and views are created
8
- automatically. Any views left over generate empty stubs.
9
-
10
- If a controller name is not given, the plural form of the model name
11
- will be used. The model and controller names may be given in CamelCase
12
- or under_score and should not be suffixed with 'Model' or 'Controller'.
13
- Both model and controller names may be prefixed with a module like a
14
- file path; see the Modules Example for usage.
15
-
16
- Example:
17
- ./script/generate ajax_scaffold Account Bank debit credit
18
-
19
- This will generate an Account model and BankController with a full test
20
- suite and a basic user interface. Now create the accounts table in your
21
- database and browse to http://localhost/bank/ -- voila, you're on Rails!
22
-
23
- Modules Example:
24
- ./script/generate ajax_scaffold CreditCard 'admin/credit_card' suspend late_fee
25
-
26
- This will generate a CreditCard model and CreditCardController controller
27
- in the admin module.
28
-
1
+ Description:
2
+ The ajax scaffold generator creates a controller to interact with a model.
3
+ If the model does not exist, it creates the model as well. Unlike the
4
+ standard scaffold, the ajax scaffold generator uses AJAX.
5
+
6
+ The generator takes a model name, an optional controller name, and a
7
+ list of views as arguments. Scaffolded actions and views are created
8
+ automatically. Any views left over generate empty stubs.
9
+
10
+ If a controller name is not given, the plural form of the model name
11
+ will be used. The model and controller names may be given in CamelCase
12
+ or under_score and should not be suffixed with 'Model' or 'Controller'.
13
+ Both model and controller names may be prefixed with a module like a
14
+ file path; see the Modules Example for usage.
15
+
16
+ Example:
17
+ ./script/generate ajax_scaffold Account Bank debit credit
18
+
19
+ This will generate an Account model and BankController with a full test
20
+ suite and a basic user interface. Now create the accounts table in your
21
+ database and browse to http://localhost/bank/ -- voila, you're on Rails!
22
+
23
+ Modules Example:
24
+ ./script/generate ajax_scaffold CreditCard 'admin/credit_card' suspend late_fee
25
+
26
+ This will generate a CreditCard model and CreditCardController controller
27
+ in the admin module.
28
+
@@ -1,123 +1,123 @@
1
- require "rails_generator/generators/components/scaffold/scaffold_generator"
2
-
3
- class AjaxScaffoldingSandbox < ScaffoldingSandbox
4
- def default_input_block
5
- Proc.new { |record, column| "<div class=\"form-element\">\n <label for=\"#{record}_#{column.name}\">#{column.human_name}</label>\n #{input(record, column.name)}\n</div>\n" }
6
- end
7
- end
8
-
9
- class AjaxScaffoldGenerator < ScaffoldGenerator
10
-
11
- def manifest
12
- record do |m|
13
- # Check for class naming collisions.
14
- m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
15
-
16
- # Controller, helper, views, and test directories.
17
- m.directory File.join('app/controllers', controller_class_path)
18
- m.directory File.join('app/helpers', controller_class_path)
19
- m.directory File.join('app/views', controller_class_path, controller_file_name)
20
- m.directory File.join('public/images')
21
- m.directory File.join('test/functional', controller_class_path)
22
-
23
- # Depend on model generator but skip if the model exists.
24
- m.dependency 'model', [singular_name], :collision => :skip
25
-
26
- # Scaffolded forms.
27
- m.complex_template 'form.rhtml',
28
- File.join('app/views',
29
- controller_class_path,
30
- controller_file_name,
31
- '_form.rhtml'),
32
- :insert => 'form_scaffolding.rhtml',
33
- :sandbox => lambda { create_sandbox },
34
- :begin_mark => 'form',
35
- :end_mark => 'eoform',
36
- :mark_id => singular_name
37
-
38
- # Scaffolded partials.
39
- m.template "partial_item.rhtml",
40
- File.join('app/views',
41
- controller_class_path,
42
- controller_file_name,
43
- "_#{controller_file_name}.rhtml")
44
-
45
- m.template "partial_form_errors.rhtml",
46
- File.join('app/views',
47
- controller_class_path,
48
- controller_file_name,
49
- "_form_errors.rhtml")
50
-
51
- # Scaffolded views.
52
- scaffold_views.each do |action|
53
- m.template "view_#{action}.rhtml",
54
- File.join('app/views',
55
- controller_class_path,
56
- controller_file_name,
57
- "#{action}.rhtml"),
58
- :assigns => { :action => action }
59
- end
60
-
61
- # Controller class, functional test, helper, and views.
62
- m.template 'controller.rb',
63
- File.join('app/controllers',
64
- controller_class_path,
65
- "#{controller_file_name}_controller.rb")
66
-
67
- m.template 'functional_test.rb',
68
- File.join('test/functional',
69
- controller_class_path,
70
- "#{controller_file_name}_controller_test.rb")
71
-
72
- m.template 'helper.rb',
73
- File.join('app/helpers',
74
- controller_class_path,
75
- "#{controller_file_name}_helper.rb")
76
-
77
- # Layout and stylesheet.
78
- m.template 'layout.rhtml', "app/views/layouts/#{controller_file_name}.rhtml"
79
- m.template 'style.css', 'public/stylesheets/ajax_scaffold.css'
80
- m.template 'script.js', 'public/javascripts/ajax_scaffold.js'
81
- m.template 'rico_corner.js', 'public/javascripts/rico_corner.js'
82
- m.template 'indicator.gif', 'public/images/indicator.gif'
83
- m.template 'add.gif', 'public/images/add.gif'
84
- m.template 'error.gif', 'public/images/error.gif'
85
-
86
- # Unscaffolded views.
87
- unscaffolded_actions.each do |action|
88
- path = File.join('app/views',
89
- controller_class_path,
90
- controller_file_name,
91
- "#{action}.rhtml")
92
-
93
- m.template 'controller:view.rhtml', path,
94
- :assigns => { :action => action, :path => path }
95
- end
96
- end
97
- end
98
-
99
- protected
100
- # Override with your own usage banner.
101
- def banner
102
- "Usage: #{$0} ajax_scaffold ModelName [ControllerName] [action, ...]"
103
- end
104
-
105
- def scaffold_views
106
- %w( list edit new index )
107
- end
108
-
109
- def create_sandbox
110
- sandbox = AjaxScaffoldingSandbox.new
111
- sandbox.singular_name = singular_name
112
- begin
113
- sandbox.model_instance = model_instance
114
- sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
115
- rescue ActiveRecord::StatementInvalid => e
116
- logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
117
- raise SystemExit
118
- end
119
- sandbox.suffix = suffix
120
- sandbox
121
- end
122
-
123
- end
1
+ require "rails_generator/generators/components/scaffold/scaffold_generator"
2
+
3
+ class AjaxScaffoldingSandbox < ScaffoldingSandbox
4
+ def default_input_block
5
+ Proc.new { |record, column| "<div class=\"form-element\">\n <label for=\"#{record}_#{column.name}\">#{column.human_name}</label>\n #{input(record, column.name)}\n</div>\n" }
6
+ end
7
+ end
8
+
9
+ class AjaxScaffoldGenerator < ScaffoldGenerator
10
+
11
+ def manifest
12
+ record do |m|
13
+ # Check for class naming collisions.
14
+ m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
15
+
16
+ # Controller, helper, views, and test directories.
17
+ m.directory File.join('app/controllers', controller_class_path)
18
+ m.directory File.join('app/helpers', controller_class_path)
19
+ m.directory File.join('app/views', controller_class_path, controller_file_name)
20
+ m.directory File.join('public/images')
21
+ m.directory File.join('test/functional', controller_class_path)
22
+
23
+ # Depend on model generator but skip if the model exists.
24
+ m.dependency 'model', [singular_name], :collision => :skip
25
+
26
+ # Scaffolded forms.
27
+ m.complex_template 'form.rhtml',
28
+ File.join('app/views',
29
+ controller_class_path,
30
+ controller_file_name,
31
+ '_form.rhtml'),
32
+ :insert => 'form_scaffolding.rhtml',
33
+ :sandbox => lambda { create_sandbox },
34
+ :begin_mark => 'form',
35
+ :end_mark => 'eoform',
36
+ :mark_id => singular_name
37
+
38
+ # Scaffolded partials.
39
+ m.template "partial_item.rhtml",
40
+ File.join('app/views',
41
+ controller_class_path,
42
+ controller_file_name,
43
+ "_#{singular_name}.rhtml")
44
+
45
+ m.template "partial_form_errors.rhtml",
46
+ File.join('app/views',
47
+ controller_class_path,
48
+ controller_file_name,
49
+ "_form_errors.rhtml")
50
+
51
+ # Scaffolded views.
52
+ scaffold_views.each do |action|
53
+ m.template "view_#{action}.rhtml",
54
+ File.join('app/views',
55
+ controller_class_path,
56
+ controller_file_name,
57
+ "#{action}.rhtml"),
58
+ :assigns => { :action => action }
59
+ end
60
+
61
+ # Controller class, functional test, helper, and views.
62
+ m.template 'controller.rb',
63
+ File.join('app/controllers',
64
+ controller_class_path,
65
+ "#{controller_file_name}_controller.rb")
66
+
67
+ m.template 'functional_test.rb',
68
+ File.join('test/functional',
69
+ controller_class_path,
70
+ "#{controller_file_name}_controller_test.rb")
71
+
72
+ m.template 'helper.rb',
73
+ File.join('app/helpers',
74
+ controller_class_path,
75
+ "#{controller_file_name}_helper.rb")
76
+
77
+ # Layout and stylesheet.
78
+ m.template 'layout.rhtml', "app/views/layouts/#{controller_file_name}.rhtml"
79
+ m.template 'style.css', 'public/stylesheets/ajax_scaffold.css'
80
+ m.template 'script.js', 'public/javascripts/ajax_scaffold.js'
81
+ m.template 'rico_corner.js', 'public/javascripts/rico_corner.js'
82
+ m.template 'indicator.gif', 'public/images/indicator.gif'
83
+ m.template 'add.gif', 'public/images/add.gif'
84
+ m.template 'error.gif', 'public/images/error.gif'
85
+
86
+ # Unscaffolded views.
87
+ unscaffolded_actions.each do |action|
88
+ path = File.join('app/views',
89
+ controller_class_path,
90
+ controller_file_name,
91
+ "#{action}.rhtml")
92
+
93
+ m.template 'controller:view.rhtml', path,
94
+ :assigns => { :action => action, :path => path }
95
+ end
96
+ end
97
+ end
98
+
99
+ protected
100
+ # Override with your own usage banner.
101
+ def banner
102
+ "Usage: #{$0} ajax_scaffold ModelName [ControllerName] [action, ...]"
103
+ end
104
+
105
+ def scaffold_views
106
+ %w( list edit new index )
107
+ end
108
+
109
+ def create_sandbox
110
+ sandbox = AjaxScaffoldingSandbox.new
111
+ sandbox.singular_name = singular_name
112
+ begin
113
+ sandbox.model_instance = model_instance
114
+ sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
115
+ rescue ActiveRecord::StatementInvalid => e
116
+ logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
117
+ raise SystemExit
118
+ end
119
+ sandbox.suffix = suffix
120
+ sandbox
121
+ end
122
+
123
+ end
@@ -1,61 +1,61 @@
1
- class <%= controller_class_name %>Controller < ApplicationController
2
-
3
- <% unless suffix -%>
4
- def index
5
-
6
- end
7
- <% end -%>
8
-
9
- <% for action in unscaffolded_actions -%>
10
- def <%= action %><%= suffix %>
11
- end
12
- <% end -%>
13
-
14
- def list<%= suffix %>
15
- @<%= plural_name %> = <%= model_name %>.find :all
16
- render :layout => false
17
- end
18
-
19
- def new<%= suffix %>
20
- @<%= singular_name %> = <%= model_name %>.new
21
-
22
- @temp_id = Time.new.to_i
23
- @headers['<%= singular_name %>-id'] = @temp_id
24
- @headers['Content-Type'] = 'text/html; charset=utf-8'
25
-
26
- render :layout => false
27
-
28
- # If you want to send an error message:
29
- # render :inline => "Error text goes here", :layout => false, :status => 500
30
- end
31
-
32
- def create<%= suffix %>
33
- @<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>])
34
- if @<%= singular_name %>.save
35
- @headers['<%= singular_name %>-id'] = @<%= singular_name %>.id
36
- @headers['Content-Type'] = 'text/html; charset=utf-8'
37
- render :partial => '<%= singular_name %><%= suffix %>', :layout => false
38
- else
39
- render :partial => 'form_errors', :layout => false, :status => 500
40
- end
41
- end
42
-
43
- def edit<%= suffix %>
44
- @<%= singular_name %> = <%= model_name %>.find(params[:id])
45
- render :layout => false
46
- end
47
-
48
- def update
49
- @<%= singular_name %> = <%= model_name %>.find(params[:id])
50
- if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
51
- render :partial => '<%= singular_name %><%= suffix %>', :layout => false
52
- else
53
- render :partial => 'form_errors', :layout => false, :status => 500
54
- end
55
- end
56
-
57
- def destroy<%= suffix %>
58
- <%= model_name %>.find(params[:id]).destroy
59
- render :nothing => true
60
- end
61
- end
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+
3
+ <% unless suffix -%>
4
+ def index
5
+
6
+ end
7
+ <% end -%>
8
+
9
+ <% for action in unscaffolded_actions -%>
10
+ def <%= action %><%= suffix %>
11
+ end
12
+ <% end -%>
13
+
14
+ def list<%= suffix %>
15
+ @<%= plural_name %> = <%= model_name %>.find :all
16
+ render :layout => false
17
+ end
18
+
19
+ def new<%= suffix %>
20
+ @<%= singular_name %> = <%= model_name %>.new
21
+
22
+ @temp_id = Time.new.to_i
23
+ @headers['<%= singular_name %>-id'] = @temp_id
24
+ @headers['Content-Type'] = 'text/html; charset=utf-8'
25
+
26
+ render :layout => false
27
+
28
+ # If you want to send an error message:
29
+ # render :inline => "Error text goes here", :layout => false, :status => 500
30
+ end
31
+
32
+ def create<%= suffix %>
33
+ @<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>])
34
+ if @<%= singular_name %>.save
35
+ @headers['<%= singular_name %>-id'] = @<%= singular_name %>.id
36
+ @headers['Content-Type'] = 'text/html; charset=utf-8'
37
+ render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true }
38
+ else
39
+ render :partial => 'form_errors', :layout => false, :status => 500
40
+ end
41
+ end
42
+
43
+ def edit<%= suffix %>
44
+ @<%= singular_name %> = <%= model_name %>.find(params[:id])
45
+ render :layout => false
46
+ end
47
+
48
+ def update
49
+ @<%= singular_name %> = <%= model_name %>.find(params[:id])
50
+ if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
51
+ render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true }
52
+ else
53
+ render :partial => 'form_errors', :layout => false, :status => 500
54
+ end
55
+ end
56
+
57
+ def destroy<%= suffix %>
58
+ <%= model_name %>.find(params[:id]).destroy
59
+ render :nothing => true
60
+ end
61
+ end
data/templates/form.rhtml CHANGED
@@ -1,5 +1,5 @@
1
- <fieldset>
2
- <div class="row">
3
- <%= template_for_inclusion %>
4
- </div>
1
+ <fieldset>
2
+ <div class="row">
3
+ <%= template_for_inclusion %>
4
+ </div>
5
5
  </fieldset>
@@ -1,88 +1,88 @@
1
- require File.dirname(__FILE__) + '<%= "/.." * controller_class_nesting_depth %>/../test_helper'
2
- require '<%= controller_file_path %>_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
6
-
7
- class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
8
- fixtures :<%= table_name %>
9
-
10
- def setup
11
- @controller = <%= controller_class_name %>Controller.new
12
- @request = ActionController::TestRequest.new
13
- @response = ActionController::TestResponse.new
14
- end
15
-
16
- <% for action in unscaffolded_actions -%>
17
- def test_<%= action %>
18
- get :<%= action %>
19
- assert_response :success
20
- assert_template '<%= action %>'
21
- end
22
-
23
- <% end -%>
24
- <% unless suffix -%>
25
- def test_index
26
- get :index
27
- assert_response :success
28
- assert_template 'list'
29
- end
30
-
31
- <% end -%>
32
- def test_list<%= suffix %>
33
- get :list<%= suffix %>
34
-
35
- assert_response :success
36
- assert_template 'list<%= suffix %>'
37
-
38
- assert_not_nil assigns(:<%= plural_name %>)
39
- end
40
-
41
- def test_new<%= suffix %>
42
- get :new<%= suffix %>
43
-
44
- assert_response :success
45
- assert_template 'new<%= suffix %>'
46
-
47
- assert_not_nil assigns(:<%= singular_name %>)
48
- end
49
-
50
- def test_create
51
- num_<%= plural_name %> = <%= model_name %>.count
52
-
53
- post :create<%= suffix %>, :<%= singular_name %> => {}
54
-
55
- assert_response :redirect
56
- assert_redirected_to :action => 'list<%= suffix %>'
57
-
58
- assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
59
- end
60
-
61
- def test_edit<%= suffix %>
62
- get :edit<%= suffix %>, :id => 1
63
-
64
- assert_response :success
65
- assert_template 'edit<%= suffix %>'
66
-
67
- assert_not_nil assigns(:<%= singular_name %>)
68
- assert assigns(:<%= singular_name %>).valid?
69
- end
70
-
71
- def test_update<%= suffix %>
72
- post :update<%= suffix %>, :id => 1
73
- assert_response :redirect
74
- assert_redirected_to :action => 'show<%= suffix %>', :id => 1
75
- end
76
-
77
- def test_destroy<%= suffix %>
78
- assert_not_nil <%= model_name %>.find(1)
79
-
80
- post :destroy, :id => 1
81
- assert_response :redirect
82
- assert_redirected_to :action => 'list<%= suffix %>'
83
-
84
- assert_raise(ActiveRecord::RecordNotFound) {
85
- <%= model_name %>.find(1)
86
- }
87
- end
88
- end
1
+ require File.dirname(__FILE__) + '<%= "/.." * controller_class_nesting_depth %>/../test_helper'
2
+ require '<%= controller_file_path %>_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
6
+
7
+ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
8
+ fixtures :<%= table_name %>
9
+
10
+ def setup
11
+ @controller = <%= controller_class_name %>Controller.new
12
+ @request = ActionController::TestRequest.new
13
+ @response = ActionController::TestResponse.new
14
+ end
15
+
16
+ <% for action in unscaffolded_actions -%>
17
+ def test_<%= action %>
18
+ get :<%= action %>
19
+ assert_response :success
20
+ assert_template '<%= action %>'
21
+ end
22
+
23
+ <% end -%>
24
+ <% unless suffix -%>
25
+ def test_index
26
+ get :index
27
+ assert_response :success
28
+ assert_template 'list'
29
+ end
30
+
31
+ <% end -%>
32
+ def test_list<%= suffix %>
33
+ get :list<%= suffix %>
34
+
35
+ assert_response :success
36
+ assert_template 'list<%= suffix %>'
37
+
38
+ assert_not_nil assigns(:<%= plural_name %>)
39
+ end
40
+
41
+ def test_new<%= suffix %>
42
+ get :new<%= suffix %>
43
+
44
+ assert_response :success
45
+ assert_template 'new<%= suffix %>'
46
+
47
+ assert_not_nil assigns(:<%= singular_name %>)
48
+ end
49
+
50
+ def test_create
51
+ num_<%= plural_name %> = <%= model_name %>.count
52
+
53
+ post :create<%= suffix %>, :<%= singular_name %> => {}
54
+
55
+ assert_response :redirect
56
+ assert_redirected_to :action => 'list<%= suffix %>'
57
+
58
+ assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
59
+ end
60
+
61
+ def test_edit<%= suffix %>
62
+ get :edit<%= suffix %>, :id => 1
63
+
64
+ assert_response :success
65
+ assert_template 'edit<%= suffix %>'
66
+
67
+ assert_not_nil assigns(:<%= singular_name %>)
68
+ assert assigns(:<%= singular_name %>).valid?
69
+ end
70
+
71
+ def test_update<%= suffix %>
72
+ post :update<%= suffix %>, :id => 1
73
+ assert_response :redirect
74
+ assert_redirected_to :action => 'show<%= suffix %>', :id => 1
75
+ end
76
+
77
+ def test_destroy<%= suffix %>
78
+ assert_not_nil <%= model_name %>.find(1)
79
+
80
+ post :destroy, :id => 1
81
+ assert_response :redirect
82
+ assert_redirected_to :action => 'list<%= suffix %>'
83
+
84
+ assert_raise(ActiveRecord::RecordNotFound) {
85
+ <%= model_name %>.find(1)
86
+ }
87
+ end
88
+ end