aslon_scaffold 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +26 -0
  5. data/Rakefile +2 -0
  6. data/aslon_scaffold.gemspec +33 -0
  7. data/config/locales/aslon_scaffold.fr.yml +14 -0
  8. data/init.rb +1 -0
  9. data/install.rb +1 -0
  10. data/lib/app/controllers/articles_controller.rb +7 -0
  11. data/lib/app/helpers/application_helper.rb +410 -0
  12. data/lib/app/views/aslon_scaffolds/_search.haml +1 -0
  13. data/lib/app/views/aslon_scaffolds/index.haml +4 -0
  14. data/lib/app/views/aslon_scaffolds/new_edit.haml +8 -0
  15. data/lib/app/views/aslon_scaffolds/show.haml +9 -0
  16. data/lib/aslon_scaffold.rb +34 -0
  17. data/lib/aslon_scaffold/aslon_scaffold.rb +237 -0
  18. data/lib/aslon_scaffold/version.rb +4 -0
  19. data/lib/generators/haml.rb +11 -0
  20. data/lib/generators/haml/scaffold/scaffold_generator.rb +25 -0
  21. data/lib/generators/haml/scaffold/templates/_new_edit.haml.erb +6 -0
  22. data/lib/generators/haml/scaffold/templates/_search.haml.erb +6 -0
  23. data/lib/generators/haml/scaffold/templates/edit.haml.erb +5 -0
  24. data/lib/generators/haml/scaffold/templates/index.haml.erb +10 -0
  25. data/lib/generators/haml/scaffold/templates/layout.haml.erb +17 -0
  26. data/lib/generators/haml/scaffold/templates/new.haml.erb +6 -0
  27. data/lib/generators/haml/scaffold/templates/new_edit.haml.erb +13 -0
  28. data/lib/generators/haml/scaffold/templates/show.haml.erb +14 -0
  29. data/lib/generators/nifty.rb +28 -0
  30. data/lib/generators/nifty/aslon/USAGE +51 -0
  31. data/lib/generators/nifty/aslon/aslon_generator.rb +320 -0
  32. data/lib/generators/nifty/aslon/templates/actions/create.rb +8 -0
  33. data/lib/generators/nifty/aslon/templates/actions/destroy.rb +5 -0
  34. data/lib/generators/nifty/aslon/templates/actions/edit.rb +3 -0
  35. data/lib/generators/nifty/aslon/templates/actions/index.rb +3 -0
  36. data/lib/generators/nifty/aslon/templates/actions/new.rb +3 -0
  37. data/lib/generators/nifty/aslon/templates/actions/show.rb +3 -0
  38. data/lib/generators/nifty/aslon/templates/actions/update.rb +8 -0
  39. data/lib/generators/nifty/aslon/templates/controller.rb +10 -0
  40. data/lib/generators/nifty/aslon/templates/fixtures.yml +9 -0
  41. data/lib/generators/nifty/aslon/templates/helper.rb +2 -0
  42. data/lib/generators/nifty/aslon/templates/migration.rb +16 -0
  43. data/lib/generators/nifty/aslon/templates/model.rb +4 -0
  44. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/create.rb +11 -0
  45. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/destroy.rb +6 -0
  46. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/edit.rb +4 -0
  47. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/index.rb +4 -0
  48. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/new.rb +4 -0
  49. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/show.rb +4 -0
  50. data/lib/generators/nifty/aslon/templates/tests/rspec/actions/update.rb +11 -0
  51. data/lib/generators/nifty/aslon/templates/tests/rspec/controller.rb +8 -0
  52. data/lib/generators/nifty/aslon/templates/tests/rspec/model.rb +7 -0
  53. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/create.rb +13 -0
  54. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/destroy.rb +8 -0
  55. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/edit.rb +6 -0
  56. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/index.rb +6 -0
  57. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/new.rb +6 -0
  58. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/show.rb +6 -0
  59. data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/update.rb +13 -0
  60. data/lib/generators/nifty/aslon/templates/tests/shoulda/controller.rb +5 -0
  61. data/lib/generators/nifty/aslon/templates/tests/shoulda/model.rb +7 -0
  62. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/create.rb +11 -0
  63. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/destroy.rb +6 -0
  64. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/edit.rb +4 -0
  65. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/index.rb +4 -0
  66. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/new.rb +4 -0
  67. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/show.rb +4 -0
  68. data/lib/generators/nifty/aslon/templates/tests/testunit/actions/update.rb +11 -0
  69. data/lib/generators/nifty/aslon/templates/tests/testunit/controller.rb +5 -0
  70. data/lib/generators/nifty/aslon/templates/tests/testunit/model.rb +7 -0
  71. data/lib/generators/nifty/aslon/templates/views/haml/_new_edit.html.haml +6 -0
  72. data/lib/generators/nifty/aslon/templates/views/haml/_search.html.haml +6 -0
  73. data/lib/generators/nifty/aslon/templates/views/haml/index.html.haml +10 -0
  74. data/lib/generators/nifty/aslon/templates/views/haml/layout.haml.erb +17 -0
  75. data/lib/generators/nifty/aslon/templates/views/haml/new_edit.html.haml +13 -0
  76. data/lib/generators/nifty/aslon/templates/views/haml/show.html.haml +14 -0
  77. data/lib/generators/nifty/layout/USAGE +25 -0
  78. data/lib/generators/nifty/layout/layout_generator.rb +42 -0
  79. data/lib/generators/nifty/layout/templates/_default.html.haml +9 -0
  80. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/add.gif +0 -0
  81. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/delete.gif +0 -0
  82. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/edit.gif +0 -0
  83. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/folder.gif +0 -0
  84. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid-blue-hd.gif +0 -0
  85. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid-split.gif +0 -0
  86. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid3-hrow.gif +0 -0
  87. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/indicator.gif +0 -0
  88. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/magnifier.png +0 -0
  89. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/sort_asc.gif +0 -0
  90. data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/sort_desc.gif +0 -0
  91. data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/base.css.sass +263 -0
  92. data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/formtastic.css.sass +176 -0
  93. data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/formtastic_changes.css.sass +31 -0
  94. data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/table_coffee_with_milk.css.sass +94 -0
  95. data/lib/generators/nifty/layout/templates/error_messages_helper.rb +23 -0
  96. data/lib/generators/nifty/layout/templates/layout.html.haml +13 -0
  97. data/lib/generators/nifty/layout/templates/layout_helper.rb +22 -0
  98. data/lib/generators/nifty/layout/templates/locales/aslon_scaffold.fr.yml +14 -0
  99. data/lib/generators/nifty/scaffold/USAGE +51 -0
  100. data/lib/generators/nifty/scaffold/scaffold_generator.rb +319 -0
  101. data/lib/generators/nifty/scaffold/templates/actions/create.rb +8 -0
  102. data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +5 -0
  103. data/lib/generators/nifty/scaffold/templates/actions/edit.rb +3 -0
  104. data/lib/generators/nifty/scaffold/templates/actions/index.rb +3 -0
  105. data/lib/generators/nifty/scaffold/templates/actions/new.rb +3 -0
  106. data/lib/generators/nifty/scaffold/templates/actions/show.rb +3 -0
  107. data/lib/generators/nifty/scaffold/templates/actions/update.rb +8 -0
  108. data/lib/generators/nifty/scaffold/templates/controller.rb +3 -0
  109. data/lib/generators/nifty/scaffold/templates/fixtures.yml +9 -0
  110. data/lib/generators/nifty/scaffold/templates/helper.rb +2 -0
  111. data/lib/generators/nifty/scaffold/templates/migration.rb +16 -0
  112. data/lib/generators/nifty/scaffold/templates/model.rb +4 -0
  113. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb +11 -0
  114. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
  115. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
  116. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb +4 -0
  117. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb +4 -0
  118. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb +4 -0
  119. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb +11 -0
  120. data/lib/generators/nifty/scaffold/templates/tests/rspec/controller.rb +8 -0
  121. data/lib/generators/nifty/scaffold/templates/tests/rspec/model.rb +7 -0
  122. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
  123. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
  124. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
  125. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
  126. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
  127. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
  128. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
  129. data/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb +5 -0
  130. data/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb +7 -0
  131. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb +11 -0
  132. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
  133. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
  134. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb +4 -0
  135. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb +4 -0
  136. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb +4 -0
  137. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb +11 -0
  138. data/lib/generators/nifty/scaffold/templates/tests/testunit/controller.rb +5 -0
  139. data/lib/generators/nifty/scaffold/templates/tests/testunit/model.rb +7 -0
  140. data/lib/generators/nifty/scaffold/templates/views/erb/_form.html.erb +10 -0
  141. data/lib/generators/nifty/scaffold/templates/views/erb/edit.html.erb +14 -0
  142. data/lib/generators/nifty/scaffold/templates/views/erb/index.html.erb +29 -0
  143. data/lib/generators/nifty/scaffold/templates/views/erb/new.html.erb +7 -0
  144. data/lib/generators/nifty/scaffold/templates/views/erb/show.html.erb +20 -0
  145. data/lib/generators/nifty/scaffold/templates/views/haml/_new_edit.html.haml +6 -0
  146. data/lib/generators/nifty/scaffold/templates/views/haml/_search.html.haml +6 -0
  147. data/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml +10 -0
  148. data/lib/generators/nifty/scaffold/templates/views/haml/layout.haml.erb +17 -0
  149. data/lib/generators/nifty/scaffold/templates/views/haml/new_edit.haml.erb +13 -0
  150. data/lib/generators/nifty/scaffold/templates/views/haml/show.haml.erb +14 -0
  151. data/lib/generators/templates/rails/scaffold_controller/controller.rb +11 -0
  152. data/lib/tasks/aslon_scaffold_tasks.rake +91 -0
  153. data/lib/tasks/task.rake +113 -0
  154. data/test/articles_controller_test.rb +24 -0
  155. data/test/database.yml +8 -0
  156. data/test/schema.rb +6 -0
  157. data/test/test_helper.rb +39 -0
  158. data/test/undeletable_plugin.sqlite.db +0 -0
  159. data/test/undeletable_plugin2.sqlite3.db +0 -0
  160. data/uninstall.rb +1 -0
  161. data/vendor/assets/images/aslon_scaffold/add.gif +0 -0
  162. data/vendor/assets/images/aslon_scaffold/delete.gif +0 -0
  163. data/vendor/assets/images/aslon_scaffold/edit.gif +0 -0
  164. data/vendor/assets/images/aslon_scaffold/folder.gif +0 -0
  165. data/vendor/assets/images/aslon_scaffold/grid-blue-hd.gif +0 -0
  166. data/vendor/assets/images/aslon_scaffold/grid-split.gif +0 -0
  167. data/vendor/assets/images/aslon_scaffold/grid3-hrow.gif +0 -0
  168. data/vendor/assets/images/aslon_scaffold/indicator.gif +0 -0
  169. data/vendor/assets/images/aslon_scaffold/magnifier.png +0 -0
  170. data/vendor/assets/images/aslon_scaffold/sort_asc.gif +0 -0
  171. data/vendor/assets/images/aslon_scaffold/sort_desc.gif +0 -0
  172. data/vendor/assets/stylesheets/aslon_scaffold_base.css.sass +116 -0
  173. data/vendor/assets/stylesheets/aslon_scaffold_base.css.sass.old +263 -0
  174. data/vendor/assets/stylesheets/aslon_scaffold_table.css.sass +94 -0
  175. data/vendor/assets/stylesheets/formtastic_changes.css.sass +31 -0
  176. metadata +185 -4
@@ -0,0 +1,8 @@
1
+ def create
2
+ @<%= instance_name %> = <%= class_name %>.new(params[:<%= instance_name %>])
3
+ if @<%= instance_name %>.save
4
+ redirect_to <%= item_url %>, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
5
+ else
6
+ render :new
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ def destroy
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ @<%= instance_name %>.destroy
4
+ redirect_to <%= items_url %>, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
5
+ end
@@ -0,0 +1,3 @@
1
+ def edit
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ end
@@ -0,0 +1,3 @@
1
+ def index
2
+ @<%= instances_name %> = <%= class_name %>.all
3
+ end
@@ -0,0 +1,3 @@
1
+ def new
2
+ @<%= instance_name %> = <%= class_name %>.new
3
+ end
@@ -0,0 +1,3 @@
1
+ def show
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ end
@@ -0,0 +1,8 @@
1
+ def update
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
+ redirect_to <%= item_url %>, :notice => "Successfully updated <%= class_name.underscore.humanize.downcase %>."
5
+ else
6
+ render :edit
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ class <%= plural_class_name %>Controller < ApplicationController
2
+ <%= controller_methods :actions %>
3
+ end
@@ -0,0 +1,9 @@
1
+ one:
2
+ <%- for attribute in model_attributes -%>
3
+ <%= attribute.name %>: <%= attribute.default %>
4
+ <%- end -%>
5
+
6
+ two:
7
+ <%- for attribute in model_attributes -%>
8
+ <%= attribute.name %>: <%= attribute.default %>
9
+ <%- end -%>
@@ -0,0 +1,2 @@
1
+ module <%= plural_class_name %>Helper
2
+ end
@@ -0,0 +1,16 @@
1
+ class Create<%= class_name.pluralize.delete('::') %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :<%= table_name || plural_name.split('/').last %> do |t|
4
+ <%- for attribute in model_attributes -%>
5
+ t.<%= attribute.type %> :<%= attribute.name %>
6
+ <%- end -%>
7
+ <%- unless options[:skip_timestamps] -%>
8
+ t.timestamps
9
+ <%- end -%>
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :<%= table_name || plural_name.split('/').last %>
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ <%= " set_table_name :#{table_name}\n" if table_name -%>
3
+ attr_accessible <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>
4
+ end
@@ -0,0 +1,11 @@
1
+ it "create action should render new template when model is invalid" do
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ post :create
4
+ response.should render_template(:new)
5
+ end
6
+
7
+ it "create action should redirect when model is valid" do
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ post :create
10
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
11
+ end
@@ -0,0 +1,6 @@
1
+ it "destroy action should destroy model and redirect to index action" do
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ response.should redirect_to(<%= items_url %>)
5
+ <%= class_name %>.exists?(<%= instance_name %>.id).should be_false
6
+ end
@@ -0,0 +1,4 @@
1
+ it "edit action should render edit template" do
2
+ get :edit, :id => <%= class_name %>.first
3
+ response.should render_template(:edit)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "index action should render index template" do
2
+ get :index
3
+ response.should render_template(:index)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "new action should render new template" do
2
+ get :new
3
+ response.should render_template(:new)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "show action should render show template" do
2
+ get :show, :id => <%= class_name %>.first
3
+ response.should render_template(:show)
4
+ end
@@ -0,0 +1,11 @@
1
+ it "update action should render edit template when model is invalid" do
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ put :update, :id => <%= class_name %>.first
4
+ response.should render_template(:edit)
5
+ end
6
+
7
+ it "update action should redirect when model is valid" do
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ put :update, :id => <%= class_name %>.first
10
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
11
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe <%= plural_class_name %>Controller do
4
+ fixtures :all
5
+ render_views
6
+
7
+ <%= controller_methods 'tests/rspec/actions' %>
8
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe <%= class_name %> do
4
+ it "should be valid" do
5
+ <%= class_name %>.new.should be_valid
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ context "create action" do
2
+ should "render new template when model is invalid" do
3
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
4
+ post :create
5
+ assert_template 'new'
6
+ end
7
+
8
+ should "redirect when model is valid" do
9
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
10
+ post :create
11
+ assert_redirected_to <%= item_path_for_test('url') %>
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ context "destroy action" do
2
+ should "destroy model and redirect to index action" do
3
+ <%= instance_name %> = <%= class_name %>.first
4
+ delete :destroy, :id => <%= instance_name %>
5
+ assert_redirected_to <%= items_url %>
6
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ context "edit action" do
2
+ should "render edit template" do
3
+ get :edit, :id => <%= class_name %>.first
4
+ assert_template 'edit'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "index action" do
2
+ should "render index template" do
3
+ get :index
4
+ assert_template 'index'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "new action" do
2
+ should "render new template" do
3
+ get :new
4
+ assert_template 'new'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "show action" do
2
+ should "render show template" do
3
+ get :show, :id => <%= class_name %>.first
4
+ assert_template 'show'
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ context "update action" do
2
+ should "render edit template when model is invalid" do
3
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
4
+ put :update, :id => <%= class_name %>.first
5
+ assert_template 'edit'
6
+ end
7
+
8
+ should "redirect when model is valid" do
9
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
10
+ put :update, :id => <%= class_name %>.first
11
+ assert_redirected_to <%= item_path_for_test('url') %>
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/shoulda/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ should "be valid" do
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ def test_create_invalid
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ post :create
4
+ assert_template 'new'
5
+ end
6
+
7
+ def test_create_valid
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ post :create
10
+ assert_redirected_to <%= item_path_for_test('url') %>
11
+ end
@@ -0,0 +1,6 @@
1
+ def test_destroy
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ assert_redirected_to <%= items_url %>
5
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
6
+ end
@@ -0,0 +1,4 @@
1
+ def test_edit
2
+ get :edit, :id => <%= class_name %>.first
3
+ assert_template 'edit'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_index
2
+ get :index
3
+ assert_template 'index'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_new
2
+ get :new
3
+ assert_template 'new'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_show
2
+ get :show, :id => <%= class_name %>.first
3
+ assert_template 'show'
4
+ end
@@ -0,0 +1,11 @@
1
+ def test_update_invalid
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ put :update, :id => <%= class_name %>.first
4
+ assert_template 'edit'
5
+ end
6
+
7
+ def test_update_valid
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ put :update, :id => <%= class_name %>.first
10
+ assert_redirected_to <%= item_path_for_test('url') %>
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/testunit/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ def test_should_be_valid
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ <%%= form_for <%= item_path :instance_variable => true %> do |f| %>
2
+ <%%= f.error_messages %>
3
+ <%- for attribute in model_attributes -%>
4
+ <div class="field">
5
+ <%%= f.label :<%= attribute.name %> %>
6
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
7
+ </div>
8
+ <%- end -%>
9
+ <div class="actions"><%%= f.submit %></div>
10
+ <%% end %>
@@ -0,0 +1,14 @@
1
+ <%% title "Edit <%= singular_name.titleize %>" %>
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if actions? :show, :index -%>
6
+ <p>
7
+ <%- if action? :show -%>
8
+ <%%= link_to "Show", <%= item_path :instance_variable => true %> %> |
9
+ <%- end -%>
10
+ <%- if action? :index -%>
11
+ <%%= link_to "View All", <%= items_path %> %>
12
+ <%- end -%>
13
+ </p>
14
+ <%- end -%>
@@ -0,0 +1,29 @@
1
+ <%% title "<%= plural_name.titleize %>" %>
2
+
3
+ <table>
4
+ <tr>
5
+ <%- for attribute in model_attributes -%>
6
+ <th><%= attribute.model_name.human.titleize %></th>
7
+ <%- end -%>
8
+ </tr>
9
+ <%% for <%= instance_name %> in @<%= instances_name %> %>
10
+ <tr>
11
+ <%- for attribute in model_attributes -%>
12
+ <td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
13
+ <%- end -%>
14
+ <%- if action? :show -%>
15
+ <td><%%= link_to "Show", <%= item_path %> %></td>
16
+ <%- end -%>
17
+ <%- if action? :edit -%>
18
+ <td><%%= link_to "Edit", <%= item_path :action => :edit %> %></td>
19
+ <%- end -%>
20
+ <%- if action? :destroy -%>
21
+ <td><%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %></td>
22
+ <%- end -%>
23
+ </tr>
24
+ <%% end %>
25
+ </table>
26
+
27
+ <%- if action? :new -%>
28
+ <p><%%= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %> %></p>
29
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ <%% title "New <%= singular_name.titleize %>" %>
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if action? :index -%>
6
+ <p><%%= link_to "Back to List", <%= items_path %> %></p>
7
+ <%- end -%>
@@ -0,0 +1,20 @@
1
+ <%% title "<%= singular_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <strong><%= attribute.model_name.human.titleize %>:</strong>
6
+ <%%= @<%= instance_name %>.<%= attribute.name %> %>
7
+ </p>
8
+ <%- end -%>
9
+
10
+ <p>
11
+ <%- if action? :edit -%>
12
+ <%%= link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %> %> |
13
+ <%- end -%>
14
+ <%- if action? :destroy -%>
15
+ <%%= link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete %> |
16
+ <%- end -%>
17
+ <%- if action? :index -%>
18
+ <%%= link_to "View All", <%= items_path %> %>
19
+ <%- end -%>
20
+ </p>
@@ -0,0 +1,6 @@
1
+ - semantic_form_for @<%= singular_name %> do |f|
2
+ - f.inputs :name => "Basic", :id => "basic" do
3
+ <% for attribute in attributes -%>
4
+ = f.input :<%= attribute.name%>
5
+ <% end -%>
6
+ = f.buttons
@@ -0,0 +1,6 @@
1
+ -# encoding UTF-8
2
+ -# autogenerated_by_scaffold
3
+ =table("<%= singular_name %>",@<%= plural_name %>,[<% for attribute in attributes -%>{:<%=attribute.name%>=>'<%= attribute.name %>'},<% end -%>],['show','edit','delete'])
4
+
5
+
6
+