sunrise-scaffold 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/Rakefile +0 -20
  2. data/lib/generators/sunrise/scaffold/manage_generator.rb +2 -2
  3. data/lib/generators/sunrise/scaffold/templates/multiplay/controller.rb +4 -9
  4. data/lib/generators/sunrise/scaffold/templates/multiplay/spec/controller_spec.rb +96 -0
  5. data/lib/generators/sunrise/scaffold/templates/multiplay/views/index.html.erb +5 -1
  6. data/lib/generators/sunrise/scaffold/templates/multiplay/views/item.html.erb +7 -2
  7. data/lib/generators/sunrise/scaffold/templates/multiplay/views/model_filter.html.erb +11 -9
  8. data/lib/generators/sunrise/scaffold/templates/single/controller.rb +4 -9
  9. data/lib/generators/sunrise/scaffold/templates/single/spec/controller_spec.rb +94 -0
  10. data/lib/generators/sunrise/scaffold/templates/single/views/index.html.erb +7 -1
  11. data/lib/generators/sunrise/scaffold/templates/single/views/item.html.erb +8 -3
  12. data/lib/generators/sunrise/scaffold/templates/single/views/model_filter.html.erb +12 -11
  13. data/lib/sunrise/scaffold/version.rb +1 -1
  14. data/test/dummy/Rakefile +7 -0
  15. data/test/dummy/app/controllers/application_controller.rb +3 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/comment.rb +3 -0
  18. data/test/dummy/app/models/post.rb +3 -0
  19. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/test/dummy/config/application.rb +45 -0
  21. data/test/dummy/config/boot.rb +10 -0
  22. data/test/dummy/config/database.yml +22 -0
  23. data/test/dummy/config/environment.rb +5 -0
  24. data/test/dummy/config/environments/development.rb +26 -0
  25. data/test/dummy/config/environments/production.rb +49 -0
  26. data/test/dummy/config/environments/test.rb +35 -0
  27. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  28. data/test/dummy/config/initializers/inflections.rb +10 -0
  29. data/test/dummy/config/initializers/mime_types.rb +5 -0
  30. data/test/dummy/config/initializers/secret_token.rb +7 -0
  31. data/test/dummy/config/initializers/session_store.rb +8 -0
  32. data/test/dummy/config/locales/en.yml +5 -0
  33. data/test/dummy/config/routes.rb +58 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/db/migrate/20110722084440_create_posts.rb +14 -0
  36. data/test/dummy/db/migrate/20110722085934_create_comments.rb +15 -0
  37. data/test/dummy/db/test.sqlite3 +0 -0
  38. data/test/dummy/log/development.log +0 -0
  39. data/test/dummy/log/production.log +0 -0
  40. data/test/dummy/log/server.log +0 -0
  41. data/test/dummy/log/test.log +135 -0
  42. data/test/dummy/public/404.html +26 -0
  43. data/test/dummy/public/422.html +26 -0
  44. data/test/dummy/public/500.html +26 -0
  45. data/test/dummy/public/favicon.ico +0 -0
  46. data/test/dummy/public/javascripts/application.js +2 -0
  47. data/test/dummy/public/javascripts/controls.js +965 -0
  48. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  49. data/test/dummy/public/javascripts/effects.js +1123 -0
  50. data/test/dummy/public/javascripts/prototype.js +6001 -0
  51. data/test/dummy/public/javascripts/rails.js +191 -0
  52. data/test/dummy/script/rails +6 -0
  53. data/test/generators/manage_generator_test.rb +32 -0
  54. data/test/integration/navigation_test.rb +7 -0
  55. data/test/support/integration_case.rb +4 -0
  56. data/test/test_helper.rb +29 -0
  57. data/test/tmp/app/controllers/manage/posts_controller.rb +26 -0
  58. data/test/tmp/app/helpers/manage/posts_helper.rb +2 -0
  59. data/test/tmp/app/views/manage/posts/_form.html.erb +18 -0
  60. data/test/tmp/app/views/manage/posts/_model_filter.html.erb +34 -0
  61. data/test/tmp/app/views/manage/posts/_post.html.erb +32 -0
  62. data/test/tmp/app/views/manage/posts/edit.html.erb +6 -0
  63. data/test/tmp/app/views/manage/posts/index.html.erb +36 -0
  64. data/test/tmp/app/views/manage/posts/new.html.erb +6 -0
  65. data/test/tmp/app/views/manage/posts/show.html.erb +29 -0
  66. data/test/tmp/spec/controllers/manage/posts_controller_spec.rb +94 -0
  67. metadata +137 -35
  68. data/Gemfile.lock +0 -75
  69. data/lib/generators/sunrise/scaffold/templates/multiplay/functional_test.rb +0 -103
  70. data/lib/generators/sunrise/scaffold/templates/single/functional_test.rb +0 -98
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunrise-scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 5
10
- version: 0.1.5
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Galeta
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-27 00:00:00 +03:00
19
+ date: 2011-09-01 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -27,41 +27,91 @@ executables: []
27
27
  extensions: []
28
28
 
29
29
  extra_rdoc_files:
30
- - Gemfile.lock
31
- - MIT-LICENSE
32
30
  - README.rdoc
33
31
  files:
34
- - Gemfile
35
- - Gemfile.lock
36
- - MIT-LICENSE
37
- - README.rdoc
38
- - Rakefile
39
- - lib/generators/sunrise/scaffold/USAGE
40
- - lib/generators/sunrise/scaffold/manage_generator.rb
41
- - lib/generators/sunrise/scaffold/templates/multiplay/controller.rb
42
- - lib/generators/sunrise/scaffold/templates/multiplay/functional_test.rb
43
- - lib/generators/sunrise/scaffold/templates/multiplay/helper.rb
32
+ - lib/sunrise-scaffold.rb
33
+ - lib/sunrise/scaffold/utils.rb
34
+ - lib/sunrise/scaffold/version.rb
35
+ - lib/sunrise/scaffold.rb
36
+ - lib/generators/sunrise/scaffold/templates/multiplay/views/new.html.erb
37
+ - lib/generators/sunrise/scaffold/templates/multiplay/views/model_filter.html.erb
44
38
  - lib/generators/sunrise/scaffold/templates/multiplay/views/edit.html.erb
39
+ - lib/generators/sunrise/scaffold/templates/multiplay/views/show.html.erb
40
+ - lib/generators/sunrise/scaffold/templates/multiplay/views/item.html.erb
45
41
  - lib/generators/sunrise/scaffold/templates/multiplay/views/form.html.erb
46
42
  - lib/generators/sunrise/scaffold/templates/multiplay/views/index.html.erb
47
- - lib/generators/sunrise/scaffold/templates/multiplay/views/item.html.erb
48
- - lib/generators/sunrise/scaffold/templates/multiplay/views/model_filter.html.erb
49
- - lib/generators/sunrise/scaffold/templates/multiplay/views/new.html.erb
50
- - lib/generators/sunrise/scaffold/templates/multiplay/views/show.html.erb
51
- - lib/generators/sunrise/scaffold/templates/single/controller.rb
52
- - lib/generators/sunrise/scaffold/templates/single/functional_test.rb
53
- - lib/generators/sunrise/scaffold/templates/single/helper.rb
43
+ - lib/generators/sunrise/scaffold/templates/multiplay/helper.rb
44
+ - lib/generators/sunrise/scaffold/templates/multiplay/controller.rb
45
+ - lib/generators/sunrise/scaffold/templates/multiplay/spec/controller_spec.rb
46
+ - lib/generators/sunrise/scaffold/templates/single/views/new.html.erb
47
+ - lib/generators/sunrise/scaffold/templates/single/views/model_filter.html.erb
54
48
  - lib/generators/sunrise/scaffold/templates/single/views/edit.html.erb
49
+ - lib/generators/sunrise/scaffold/templates/single/views/show.html.erb
50
+ - lib/generators/sunrise/scaffold/templates/single/views/item.html.erb
55
51
  - lib/generators/sunrise/scaffold/templates/single/views/form.html.erb
56
52
  - lib/generators/sunrise/scaffold/templates/single/views/index.html.erb
57
- - lib/generators/sunrise/scaffold/templates/single/views/item.html.erb
58
- - lib/generators/sunrise/scaffold/templates/single/views/model_filter.html.erb
59
- - lib/generators/sunrise/scaffold/templates/single/views/new.html.erb
60
- - lib/generators/sunrise/scaffold/templates/single/views/show.html.erb
61
- - lib/sunrise-scaffold.rb
62
- - lib/sunrise/scaffold.rb
63
- - lib/sunrise/scaffold/utils.rb
64
- - lib/sunrise/scaffold/version.rb
53
+ - lib/generators/sunrise/scaffold/templates/single/helper.rb
54
+ - lib/generators/sunrise/scaffold/templates/single/controller.rb
55
+ - lib/generators/sunrise/scaffold/templates/single/spec/controller_spec.rb
56
+ - lib/generators/sunrise/scaffold/USAGE
57
+ - lib/generators/sunrise/scaffold/manage_generator.rb
58
+ - MIT-LICENSE
59
+ - Rakefile
60
+ - Gemfile
61
+ - README.rdoc
62
+ - test/integration/navigation_test.rb
63
+ - test/generators/manage_generator_test.rb
64
+ - test/dummy/public/500.html
65
+ - test/dummy/public/404.html
66
+ - test/dummy/public/favicon.ico
67
+ - test/dummy/public/javascripts/application.js
68
+ - test/dummy/public/javascripts/dragdrop.js
69
+ - test/dummy/public/javascripts/effects.js
70
+ - test/dummy/public/javascripts/prototype.js
71
+ - test/dummy/public/javascripts/controls.js
72
+ - test/dummy/public/javascripts/rails.js
73
+ - test/dummy/public/422.html
74
+ - test/dummy/app/views/layouts/application.html.erb
75
+ - test/dummy/app/helpers/application_helper.rb
76
+ - test/dummy/app/models/comment.rb
77
+ - test/dummy/app/models/post.rb
78
+ - test/dummy/app/controllers/application_controller.rb
79
+ - test/dummy/log/production.log
80
+ - test/dummy/log/server.log
81
+ - test/dummy/log/test.log
82
+ - test/dummy/log/development.log
83
+ - test/dummy/Rakefile
84
+ - test/dummy/script/rails
85
+ - test/dummy/config/routes.rb
86
+ - test/dummy/config/environments/production.rb
87
+ - test/dummy/config/environments/test.rb
88
+ - test/dummy/config/environments/development.rb
89
+ - test/dummy/config/boot.rb
90
+ - test/dummy/config/application.rb
91
+ - test/dummy/config/database.yml
92
+ - test/dummy/config/initializers/session_store.rb
93
+ - test/dummy/config/initializers/inflections.rb
94
+ - test/dummy/config/initializers/mime_types.rb
95
+ - test/dummy/config/initializers/backtrace_silencers.rb
96
+ - test/dummy/config/initializers/secret_token.rb
97
+ - test/dummy/config/environment.rb
98
+ - test/dummy/config/locales/en.yml
99
+ - test/dummy/db/migrate/20110722085934_create_comments.rb
100
+ - test/dummy/db/migrate/20110722084440_create_posts.rb
101
+ - test/dummy/db/test.sqlite3
102
+ - test/dummy/config.ru
103
+ - test/tmp/app/views/manage/posts/new.html.erb
104
+ - test/tmp/app/views/manage/posts/_post.html.erb
105
+ - test/tmp/app/views/manage/posts/edit.html.erb
106
+ - test/tmp/app/views/manage/posts/_form.html.erb
107
+ - test/tmp/app/views/manage/posts/_model_filter.html.erb
108
+ - test/tmp/app/views/manage/posts/show.html.erb
109
+ - test/tmp/app/views/manage/posts/index.html.erb
110
+ - test/tmp/app/helpers/manage/posts_helper.rb
111
+ - test/tmp/app/controllers/manage/posts_controller.rb
112
+ - test/tmp/spec/controllers/manage/posts_controller_spec.rb
113
+ - test/support/integration_case.rb
114
+ - test/test_helper.rb
65
115
  has_rdoc: true
66
116
  homepage: https://github.com/galetahub/sunrise-scaffold
67
117
  licenses: []
@@ -91,10 +141,62 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
141
  version: "0"
92
142
  requirements: []
93
143
 
94
- rubyforge_project:
144
+ rubyforge_project: sunrise-core
95
145
  rubygems_version: 1.6.2
96
146
  signing_key:
97
147
  specification_version: 3
98
148
  summary: Rails CMS
99
- test_files: []
100
-
149
+ test_files:
150
+ - test/integration/navigation_test.rb
151
+ - test/generators/manage_generator_test.rb
152
+ - test/dummy/public/500.html
153
+ - test/dummy/public/404.html
154
+ - test/dummy/public/favicon.ico
155
+ - test/dummy/public/javascripts/application.js
156
+ - test/dummy/public/javascripts/dragdrop.js
157
+ - test/dummy/public/javascripts/effects.js
158
+ - test/dummy/public/javascripts/prototype.js
159
+ - test/dummy/public/javascripts/controls.js
160
+ - test/dummy/public/javascripts/rails.js
161
+ - test/dummy/public/422.html
162
+ - test/dummy/app/views/layouts/application.html.erb
163
+ - test/dummy/app/helpers/application_helper.rb
164
+ - test/dummy/app/models/comment.rb
165
+ - test/dummy/app/models/post.rb
166
+ - test/dummy/app/controllers/application_controller.rb
167
+ - test/dummy/log/production.log
168
+ - test/dummy/log/server.log
169
+ - test/dummy/log/test.log
170
+ - test/dummy/log/development.log
171
+ - test/dummy/Rakefile
172
+ - test/dummy/script/rails
173
+ - test/dummy/config/routes.rb
174
+ - test/dummy/config/environments/production.rb
175
+ - test/dummy/config/environments/test.rb
176
+ - test/dummy/config/environments/development.rb
177
+ - test/dummy/config/boot.rb
178
+ - test/dummy/config/application.rb
179
+ - test/dummy/config/database.yml
180
+ - test/dummy/config/initializers/session_store.rb
181
+ - test/dummy/config/initializers/inflections.rb
182
+ - test/dummy/config/initializers/mime_types.rb
183
+ - test/dummy/config/initializers/backtrace_silencers.rb
184
+ - test/dummy/config/initializers/secret_token.rb
185
+ - test/dummy/config/environment.rb
186
+ - test/dummy/config/locales/en.yml
187
+ - test/dummy/db/migrate/20110722085934_create_comments.rb
188
+ - test/dummy/db/migrate/20110722084440_create_posts.rb
189
+ - test/dummy/db/test.sqlite3
190
+ - test/dummy/config.ru
191
+ - test/tmp/app/views/manage/posts/new.html.erb
192
+ - test/tmp/app/views/manage/posts/_post.html.erb
193
+ - test/tmp/app/views/manage/posts/edit.html.erb
194
+ - test/tmp/app/views/manage/posts/_form.html.erb
195
+ - test/tmp/app/views/manage/posts/_model_filter.html.erb
196
+ - test/tmp/app/views/manage/posts/show.html.erb
197
+ - test/tmp/app/views/manage/posts/index.html.erb
198
+ - test/tmp/app/helpers/manage/posts_helper.rb
199
+ - test/tmp/app/controllers/manage/posts_controller.rb
200
+ - test/tmp/spec/controllers/manage/posts_controller_spec.rb
201
+ - test/support/integration_case.rb
202
+ - test/test_helper.rb
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- abstract (1.0.0)
5
- actionmailer (3.0.9)
6
- actionpack (= 3.0.9)
7
- mail (~> 2.2.19)
8
- actionpack (3.0.9)
9
- activemodel (= 3.0.9)
10
- activesupport (= 3.0.9)
11
- builder (~> 2.1.2)
12
- erubis (~> 2.6.6)
13
- i18n (~> 0.5.0)
14
- rack (~> 1.2.1)
15
- rack-mount (~> 0.6.14)
16
- rack-test (~> 0.5.7)
17
- tzinfo (~> 0.3.23)
18
- activemodel (3.0.9)
19
- activesupport (= 3.0.9)
20
- builder (~> 2.1.2)
21
- i18n (~> 0.5.0)
22
- activerecord (3.0.9)
23
- activemodel (= 3.0.9)
24
- activesupport (= 3.0.9)
25
- arel (~> 2.0.10)
26
- tzinfo (~> 0.3.23)
27
- activeresource (3.0.9)
28
- activemodel (= 3.0.9)
29
- activesupport (= 3.0.9)
30
- activesupport (3.0.9)
31
- arel (2.0.10)
32
- builder (2.1.2)
33
- erubis (2.6.6)
34
- abstract (>= 1.0.0)
35
- i18n (0.5.0)
36
- mail (2.2.19)
37
- activesupport (>= 2.3.6)
38
- i18n (>= 0.4.0)
39
- mime-types (~> 1.16)
40
- treetop (~> 1.4.8)
41
- mime-types (1.16)
42
- polyglot (0.3.1)
43
- rack (1.2.3)
44
- rack-mount (0.6.14)
45
- rack (>= 1.0.0)
46
- rack-test (0.5.7)
47
- rack (>= 1.0)
48
- rails (3.0.9)
49
- actionmailer (= 3.0.9)
50
- actionpack (= 3.0.9)
51
- activerecord (= 3.0.9)
52
- activeresource (= 3.0.9)
53
- activesupport (= 3.0.9)
54
- bundler (~> 1.0)
55
- railties (= 3.0.9)
56
- railties (3.0.9)
57
- actionpack (= 3.0.9)
58
- activesupport (= 3.0.9)
59
- rake (>= 0.8.7)
60
- rdoc (~> 3.4)
61
- thor (~> 0.14.4)
62
- rake (0.9.2)
63
- rdoc (3.8)
64
- sqlite3 (1.3.3)
65
- thor (0.14.6)
66
- treetop (1.4.9)
67
- polyglot (>= 0.3.1)
68
- tzinfo (0.3.29)
69
-
70
- PLATFORMS
71
- ruby
72
-
73
- DEPENDENCIES
74
- rails (= 3.0.9)
75
- sqlite3
@@ -1,103 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Manage::<%= controller_class_name %>ControllerTest < ActionController::TestCase
4
-
5
- def setup
6
- @admin = users(:admin)
7
- @<%= parent_singular_name %> = <%= parent_class_name %>.find(:first)
8
- end
9
-
10
- test "index" do
11
- get :index, {:<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id }, {:user_id=>@admin.id}
12
-
13
- assert_response :success
14
- assert_not_nil assigns(:<%= plural_name %>)
15
- end
16
-
17
- test "new" do
18
- get :new, {:<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id }, {:user_id=>@admin.id}
19
-
20
- assert_response :success
21
- assert_not_nil assigns(:<%= singular_name %>)
22
- assert assigns(:<%= singular_name %>).new_record?
23
- end
24
-
25
- test "should_create_<%= singular_name %>" do
26
- assert_difference('<%= model_name %>.count') do
27
- post :create, {:<%= singular_name %> => { :title => '<%= model_name %> test title'},
28
- :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id},
29
- {:user_id=>@admin.id}
30
- end
31
-
32
- assert assigns(:<%= singular_name %>).valid?
33
- assert_equal assigns(:<%= singular_name %>).title, '<%= model_name %> test title'
34
-
35
- assert_redirected_to manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id)
36
- end
37
-
38
- test "should_error_create_<%= singular_name %>" do
39
- assert_no_difference('<%= model_name %>.count') do
40
- post :create, {:<%= singular_name %> => { :title => nil},
41
- :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id },
42
- {:user_id=>@admin.id}
43
- end
44
-
45
- assert !assigns(:<%= singular_name %>).valid?
46
- assert !assigns(:<%= singular_name %>).errors.empty?
47
- assert assigns(:<%= singular_name %>).errors.on(:title)
48
-
49
- assert_response :success
50
- end
51
-
52
- test "should_update_<%= singular_name %>" do
53
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
54
-
55
- assert_no_difference('<%= model_name %>.count') do
56
- put :update, {:id=><%= singular_name %>.id, :<%= singular_name %> => {
57
- :title => '<%= model_name %> test title updated'},
58
- :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id },
59
- {:user_id=>@admin.id}
60
- end
61
-
62
- assert assigns(:<%= singular_name %>).valid?
63
- assert_equal assigns(:<%= singular_name %>).title, '<%= model_name %> test title updated'
64
-
65
- assert_redirected_to manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id)
66
- end
67
-
68
- test "should_error_update_<%= singular_name %>" do
69
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
70
-
71
- assert_no_difference('<%= model_name %>.count') do
72
- put :update, {:id=><%= singular_name %>.id, :<%= singular_name %> => { :title =>nil},
73
- :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id },
74
- {:user_id=>@admin.id}
75
- end
76
-
77
- assert !assigns(:<%= singular_name %>).valid?
78
- assert !assigns(:<%= singular_name %>).errors.empty?
79
- assert assigns(:<%= singular_name %>).errors.on(:title)
80
-
81
- assert_response :success
82
- end
83
-
84
- test "should_destroy_<%= singular_name %>" do
85
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
86
-
87
- assert_difference('<%= model_name %>.count', -1) do
88
- delete :destroy, {:id=><%= singular_name %>.id, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id }, {:user_id=>@admin.id}
89
- end
90
-
91
- assert_redirected_to manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id)
92
-
93
- assert_raise(ActiveRecord::RecordNotFound) {
94
- <%= model_name %>.find(<%= singular_name %>.id)
95
- }
96
- end
97
-
98
- test "should_redirect_to_login" do
99
- get :index
100
-
101
- assert_redirected_to login_path
102
- end
103
- end
@@ -1,98 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Manage::<%= controller_class_name %>ControllerTest < ActionController::TestCase
4
-
5
- def setup
6
- @admin = users(:admin)
7
- end
8
-
9
- test "index" do
10
- get :index, nil, {:user_id=>@admin.id}
11
-
12
- assert_response :success
13
- assert_not_nil assigns(:<%= plural_name %>)
14
- end
15
-
16
- test "new" do
17
- get :new, nil, {:user_id=>@admin.id}
18
-
19
- assert_response :success
20
- assert_not_nil assigns(:<%= singular_name %>)
21
- assert assigns(:<%= singular_name %>).new_record?
22
- end
23
-
24
- test "should_create_<%= singular_name %>" do
25
- assert_difference('<%= model_name %>.count') do
26
- post :create, {:<%= singular_name %> => { :title => '<%= model_name %> test title'} },
27
- {:user_id=>@admin.id}
28
- end
29
-
30
- assert assigns(:<%= singular_name %>).valid?
31
- assert_equal assigns(:<%= singular_name %>).title, '<%= model_name %> test title'
32
-
33
- assert_redirected_to manage_<%= plural_name %>_path
34
- end
35
-
36
- test "should_error_create_<%= singular_name %>" do
37
- assert_no_difference('<%= model_name %>.count') do
38
- post :create, {:<%= singular_name %> => { :title => nil} },
39
- {:user_id=>@admin.id}
40
- end
41
-
42
- assert !assigns(:<%= singular_name %>).valid?
43
- assert !assigns(:<%= singular_name %>).errors.empty?
44
- assert assigns(:<%= singular_name %>).errors.on(:title)
45
-
46
- assert_response :success
47
- end
48
-
49
- test "should_update_<%= singular_name %>" do
50
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
51
-
52
- assert_no_difference('<%= model_name %>.count') do
53
- put :update, {:id=><%= singular_name %>.id, :<%= singular_name %> => {
54
- :title => '<%= model_name %> test title updated'} },
55
- {:user_id=>@admin.id}
56
- end
57
-
58
- assert assigns(:<%= singular_name %>).valid?
59
- assert_equal assigns(:<%= singular_name %>).title, '<%= model_name %> test title updated'
60
-
61
- assert_redirected_to manage_<%= plural_name %>_path
62
- end
63
-
64
- test "should_error_update_<%= singular_name %>" do
65
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
66
-
67
- assert_no_difference('<%= model_name %>.count') do
68
- put :update, {:id=><%= singular_name %>.id, :<%= singular_name %> => { :title =>nil} },
69
- {:user_id=>@admin.id}
70
- end
71
-
72
- assert !assigns(:<%= singular_name %>).valid?
73
- assert !assigns(:<%= singular_name %>).errors.empty?
74
- assert assigns(:<%= singular_name %>).errors.on(:title)
75
-
76
- assert_response :success
77
- end
78
-
79
- test "should_destroy_<%= singular_name %>" do
80
- <%= singular_name %> = <%= model_name %>.create(:title=>'<%= model_name %> test title')
81
-
82
- assert_difference('<%= model_name %>.count', -1) do
83
- delete :destroy, {:id=><%= singular_name %>.id}, {:user_id=>@admin.id}
84
- end
85
-
86
- assert_redirected_to manage_<%= plural_name %>_path
87
-
88
- assert_raise(ActiveRecord::RecordNotFound) {
89
- <%= model_name %>.find(<%= singular_name %>.id)
90
- }
91
- end
92
-
93
- test "should_redirect_to_login" do
94
- get :index
95
-
96
- assert_redirected_to login_path
97
- end
98
- end