comfortable_mexican_sofa 1.9.3 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/.travis.yml +2 -6
  2. data/README.md +2 -2
  3. data/Rakefile +23 -2
  4. data/app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee +7 -1
  5. data/app/assets/stylesheets/comfortable_mexican_sofa/application.css.sass +1 -1
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +7 -4
  7. data/app/controllers/{cms_admin → admin/cms}/base_controller.rb +6 -6
  8. data/app/controllers/{cms_admin → admin/cms}/categories_controller.rb +1 -1
  9. data/app/controllers/{cms_admin → admin/cms}/files_controller.rb +4 -4
  10. data/app/controllers/{cms_admin → admin/cms}/layouts_controller.rb +3 -3
  11. data/app/controllers/{cms_admin → admin/cms}/pages_controller.rb +3 -3
  12. data/app/controllers/{cms_admin → admin/cms}/revisions_controller.rb +8 -8
  13. data/app/controllers/{cms_admin → admin/cms}/sites_controller.rb +7 -7
  14. data/app/controllers/{cms_admin → admin/cms}/snippets_controller.rb +2 -2
  15. data/app/controllers/cms/base_controller.rb +30 -0
  16. data/app/controllers/{cms_content_controller.rb → cms/content_controller.rb} +2 -22
  17. data/app/models/cms/file.rb +1 -3
  18. data/app/models/cms/layout.rb +1 -1
  19. data/app/models/cms/snippet.rb +1 -3
  20. data/app/views/{cms_admin → admin/cms}/categories/_categories.html.haml +0 -0
  21. data/app/views/{cms_admin → admin/cms}/categories/_edit.html.haml +1 -1
  22. data/app/views/{cms_admin → admin/cms}/categories/_form.html.haml +0 -0
  23. data/app/views/{cms_admin → admin/cms}/categories/_index.html.haml +3 -3
  24. data/app/views/{cms_admin → admin/cms}/categories/_show.html.haml +2 -2
  25. data/app/views/{cms_admin → admin/cms}/categories/create.js.erb +0 -0
  26. data/app/views/{cms_admin → admin/cms}/categories/destroy.js.erb +0 -0
  27. data/app/views/{cms_admin → admin/cms}/categories/edit.js.erb +0 -0
  28. data/app/views/{cms_admin → admin/cms}/categories/update.js.erb +0 -0
  29. data/app/views/{cms_admin → admin/cms}/files/_file.html.haml +1 -1
  30. data/app/views/{cms_admin → admin/cms}/files/_form.html.haml +3 -3
  31. data/app/views/{cms_admin → admin/cms}/files/_index.html.haml +2 -2
  32. data/app/views/{cms_admin → admin/cms}/files/_page_form.html.haml +1 -1
  33. data/app/views/{cms_admin → admin/cms}/files/destroy.js.coffee +0 -0
  34. data/app/views/{cms_admin → admin/cms}/files/edit.html.haml +0 -0
  35. data/app/views/{cms_admin → admin/cms}/files/index.html.haml +8 -8
  36. data/app/views/{cms_admin → admin/cms}/files/new.html.haml +0 -0
  37. data/app/views/{cms_admin → admin/cms}/layouts/_form.html.haml +3 -3
  38. data/app/views/{cms_admin → admin/cms}/layouts/_index_branch.html.haml +4 -4
  39. data/app/views/{cms_admin → admin/cms}/layouts/edit.html.haml +2 -2
  40. data/app/views/admin/cms/layouts/index.html.haml +13 -0
  41. data/app/views/{cms_admin → admin/cms}/layouts/new.html.haml +0 -0
  42. data/app/views/{cms_admin → admin/cms}/pages/_form.html.haml +10 -10
  43. data/app/views/{cms_admin → admin/cms}/pages/_form_blocks.html.haml +1 -1
  44. data/app/views/{cms_admin → admin/cms}/pages/_index_branch.html.haml +6 -6
  45. data/app/views/{cms_admin → admin/cms}/pages/edit.html.haml +2 -2
  46. data/app/views/{cms_admin → admin/cms}/pages/form_blocks.js.erb +0 -0
  47. data/app/views/admin/cms/pages/index.html.haml +15 -0
  48. data/app/views/{cms_admin → admin/cms}/pages/new.html.haml +0 -0
  49. data/app/views/{cms_admin → admin/cms}/pages/toggle_branch.js.erb +0 -0
  50. data/app/views/{cms_admin → admin/cms}/partials/_body_before.html.haml +1 -1
  51. data/app/views/{cms_admin → admin/cms}/partials/_file_form_after.html.haml +1 -1
  52. data/app/views/{cms_admin → admin/cms}/partials/_file_form_before.html.haml +1 -1
  53. data/app/views/{cms_admin → admin/cms}/partials/_files_after.html.haml +1 -1
  54. data/app/views/{cms_admin → admin/cms}/partials/_files_before.html.haml +1 -1
  55. data/app/views/{cms_admin → admin/cms}/partials/_html_footer.html.haml +1 -1
  56. data/app/views/{cms_admin → admin/cms}/partials/_html_head.html.haml +1 -1
  57. data/app/views/{cms_admin → admin/cms}/partials/_layout_form_after.html.haml +1 -1
  58. data/app/views/{cms_admin → admin/cms}/partials/_layout_form_before.html.haml +1 -1
  59. data/app/views/{cms_admin → admin/cms}/partials/_layouts_after.html.haml +1 -1
  60. data/app/views/{cms_admin → admin/cms}/partials/_layouts_before.html.haml +1 -1
  61. data/app/views/{cms_admin → admin/cms}/partials/_navigation_after.html.haml +1 -1
  62. data/app/views/{cms_admin → admin/cms}/partials/_navigation_before.html.haml +1 -1
  63. data/app/views/admin/cms/partials/_navigation_inner.html.haml +3 -0
  64. data/app/views/{cms_admin → admin/cms}/partials/_page_form_after.html.haml +1 -1
  65. data/app/views/{cms_admin → admin/cms}/partials/_page_form_before.html.haml +1 -1
  66. data/app/views/{cms_admin → admin/cms}/partials/_page_form_inner.html.haml +1 -1
  67. data/app/views/{cms_admin → admin/cms}/partials/_pages_after.html.haml +1 -1
  68. data/app/views/{cms_admin → admin/cms}/partials/_pages_before.html.haml +1 -1
  69. data/app/views/{cms_admin → admin/cms}/partials/_right_column_after.html.haml +1 -1
  70. data/app/views/{cms_admin → admin/cms}/partials/_right_column_before.html.haml +1 -1
  71. data/app/views/{cms_admin → admin/cms}/partials/_site_form_after.html.haml +1 -1
  72. data/app/views/{cms_admin → admin/cms}/partials/_site_form_before.html.haml +1 -1
  73. data/app/views/{cms_admin → admin/cms}/partials/_sites_after.html.haml +1 -1
  74. data/app/views/{cms_admin → admin/cms}/partials/_sites_before.html.haml +1 -1
  75. data/app/views/{cms_admin → admin/cms}/partials/_snippet_form_after.html.haml +1 -1
  76. data/app/views/{cms_admin → admin/cms}/partials/_snippet_form_before.html.haml +1 -1
  77. data/app/views/{cms_admin → admin/cms}/partials/_snippets_after.html.haml +1 -1
  78. data/app/views/{cms_admin → admin/cms}/partials/_snippets_before.html.haml +1 -1
  79. data/app/views/{cms_admin → admin/cms}/revisions/show.html.haml +6 -4
  80. data/app/views/{cms_admin → admin/cms}/sites/_form.html.haml +2 -2
  81. data/app/views/admin/cms/sites/_mirrors.html.haml +18 -0
  82. data/app/views/{cms_admin → admin/cms}/sites/edit.html.haml +0 -0
  83. data/app/views/{cms_admin → admin/cms}/sites/index.html.haml +7 -7
  84. data/app/views/{cms_admin → admin/cms}/sites/new.html.haml +0 -0
  85. data/app/views/{cms_admin → admin/cms}/snippets/_form.html.haml +4 -4
  86. data/app/views/{cms_admin → admin/cms}/snippets/edit.html.haml +2 -2
  87. data/app/views/{cms_admin → admin/cms}/snippets/index.html.haml +9 -9
  88. data/app/views/{cms_admin → admin/cms}/snippets/new.html.haml +0 -0
  89. data/app/views/{cms_content → cms/content}/render_sitemap.xml.builder +1 -1
  90. data/app/views/kaminari/_first_page.html.haml +2 -0
  91. data/app/views/kaminari/_gap.html.haml +2 -0
  92. data/app/views/kaminari/_last_page.html.haml +2 -0
  93. data/app/views/kaminari/_next_page.html.haml +2 -0
  94. data/app/views/kaminari/_page.html.haml +2 -0
  95. data/app/views/kaminari/_paginator.html.haml +12 -0
  96. data/app/views/kaminari/_prev_page.html.haml +2 -0
  97. data/app/views/layouts/admin/cms.html.haml +4 -0
  98. data/app/views/layouts/admin/cms/_body.html.haml +17 -0
  99. data/app/views/layouts/{cms_admin → admin/cms}/_center.html.haml +0 -0
  100. data/app/views/layouts/{cms_admin → admin/cms}/_footer.html.haml +0 -0
  101. data/app/views/layouts/{cms_admin → admin/cms}/_footer_js.html.haml +2 -2
  102. data/app/views/layouts/{cms_admin → admin/cms}/_head.html.haml +1 -1
  103. data/app/views/layouts/admin/cms/_left.html.haml +16 -0
  104. data/app/views/layouts/admin/cms/_right.html.haml +5 -0
  105. data/comfortable_mexican_sofa.gemspec +12 -10
  106. data/config/database.yml +1 -1
  107. data/config/locales/de.yml +137 -136
  108. data/config/locales/en.yml +136 -135
  109. data/config/locales/es.yml +129 -128
  110. data/config/locales/fr.yml +129 -128
  111. data/config/locales/ja.yml +129 -128
  112. data/config/locales/pl.yml +129 -128
  113. data/config/locales/pt-BR.yml +129 -128
  114. data/config/locales/ru.yml +137 -136
  115. data/config/locales/sv.yml +129 -128
  116. data/config/locales/zh-CN.yml +138 -137
  117. data/lib/comfortable_mexican_sofa/engine.rb +2 -1
  118. data/lib/comfortable_mexican_sofa/fixture.rb +7 -0
  119. data/lib/comfortable_mexican_sofa/fixture/layout.rb +1 -1
  120. data/lib/comfortable_mexican_sofa/fixture/page.rb +2 -2
  121. data/lib/comfortable_mexican_sofa/fixture/snippet.rb +1 -1
  122. data/lib/comfortable_mexican_sofa/form_builder.rb +1 -1
  123. data/lib/comfortable_mexican_sofa/routing.rb +32 -30
  124. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  125. data/lib/generators/comfy/cms/README +1 -1
  126. data/lib/generators/comfy/cms/cms_generator.rb +6 -6
  127. data/lib/generators/comfy/scaffold/scaffold_generator.rb +69 -0
  128. data/lib/generators/comfy/scaffold/templates/controller.rb +62 -0
  129. data/lib/generators/comfy/scaffold/templates/migration.rb +12 -0
  130. data/lib/generators/comfy/scaffold/templates/model.rb +21 -0
  131. data/lib/generators/comfy/scaffold/templates/tests/controller.rb +102 -0
  132. data/lib/generators/comfy/scaffold/templates/tests/fixture.yml +4 -0
  133. data/lib/generators/comfy/scaffold/templates/tests/model.rb +27 -0
  134. data/lib/generators/comfy/scaffold/templates/views/_form.haml +6 -0
  135. data/lib/generators/comfy/scaffold/templates/views/edit.haml +5 -0
  136. data/lib/generators/comfy/scaffold/templates/views/index.haml +23 -0
  137. data/lib/generators/comfy/scaffold/templates/views/new.haml +5 -0
  138. data/lib/generators/comfy/scaffold/templates/views/show.haml +4 -0
  139. data/test/controllers/{cms_admin → admin/cms}/base_controller_test.rb +3 -3
  140. data/test/controllers/{cms_admin → admin/cms}/categories_controller_test.rb +2 -2
  141. data/test/controllers/{cms_admin → admin/cms}/files_controller_test.rb +4 -4
  142. data/test/controllers/{cms_admin → admin/cms}/layouts_controller_test.rb +5 -5
  143. data/test/controllers/{cms_admin → admin/cms}/pages_controller_test.rb +9 -9
  144. data/test/controllers/{cms_admin → admin/cms}/revisions_controller_test.rb +9 -9
  145. data/test/controllers/{cms_admin → admin/cms}/sites_controller_test.rb +5 -5
  146. data/test/controllers/{cms_admin → admin/cms}/snippets_controller_test.rb +5 -5
  147. data/test/controllers/{cms_content_controller_test.rb → cms/content_controller_test.rb} +8 -9
  148. data/test/fixtures/generators/cms/routes.rb +8 -0
  149. data/test/fixtures/generators/scaffold/controller.rb +62 -0
  150. data/test/fixtures/generators/scaffold/migration.rb +10 -0
  151. data/test/fixtures/generators/scaffold/model.rb +21 -0
  152. data/test/fixtures/generators/scaffold/routes.rb +7 -0
  153. data/test/fixtures/generators/scaffold/tests/controller.rb +98 -0
  154. data/test/fixtures/generators/scaffold/tests/fixture +2 -0
  155. data/test/fixtures/generators/scaffold/tests/model.rb +25 -0
  156. data/test/fixtures/generators/scaffold/views/_form.haml +4 -0
  157. data/test/fixtures/generators/scaffold/views/edit.haml +5 -0
  158. data/test/fixtures/generators/scaffold/views/index.haml +19 -0
  159. data/test/fixtures/generators/scaffold/views/new.haml +5 -0
  160. data/test/fixtures/generators/scaffold/views/show.haml +4 -0
  161. data/test/gemfiles/Gemfile.rails.4.0 +2 -0
  162. data/test/generators/cms_generator_test.rb +23 -0
  163. data/test/generators/scaffold_generator_test.rb +31 -0
  164. data/test/integration/authentication_test.rb +6 -6
  165. data/test/integration/fixtures_test.rb +1 -1
  166. data/test/integration/mirrors_test.rb +12 -12
  167. data/test/integration/sites_test.rb +8 -8
  168. data/test/integration/view_hooks_test.rb +7 -7
  169. data/test/{models → lib}/configuration_test.rb +0 -0
  170. data/test/{models → lib}/fixtures/categories_test.rb +0 -0
  171. data/test/{models → lib}/fixtures/files_test.rb +0 -0
  172. data/test/{models → lib}/fixtures/layouts_test.rb +0 -0
  173. data/test/{models → lib}/fixtures/pages_test.rb +0 -0
  174. data/test/{models → lib}/fixtures/snippets_test.rb +0 -0
  175. data/test/{models → lib}/fixtures_test.rb +0 -0
  176. data/test/{models → lib}/mirrors_test.rb +0 -0
  177. data/test/{models → lib}/revisions_test.rb +0 -0
  178. data/test/{models → lib}/tag_test.rb +0 -0
  179. data/test/{models → lib}/tags/asset_test.rb +0 -0
  180. data/test/{models → lib}/tags/collection_test.rb +0 -0
  181. data/test/{models → lib}/tags/field_datetime_test.rb +0 -0
  182. data/test/{models → lib}/tags/field_integer_test.rb +0 -0
  183. data/test/{models → lib}/tags/field_rich_text_test.rb +0 -0
  184. data/test/{models → lib}/tags/field_string_test.rb +0 -0
  185. data/test/{models → lib}/tags/field_text_test.rb +0 -0
  186. data/test/{models → lib}/tags/file_test.rb +0 -0
  187. data/test/{models → lib}/tags/helper_test.rb +0 -0
  188. data/test/{models → lib}/tags/page_datetime_test.rb +0 -0
  189. data/test/{models → lib}/tags/page_file_test.rb +0 -0
  190. data/test/{models → lib}/tags/page_files_test.rb +0 -0
  191. data/test/{models → lib}/tags/page_integer_test.rb +0 -0
  192. data/test/{models → lib}/tags/page_markdown_test.rb +0 -0
  193. data/test/{models → lib}/tags/page_rich_text_test.rb +0 -0
  194. data/test/{models → lib}/tags/page_string_test.rb +0 -0
  195. data/test/{models → lib}/tags/page_text_test.rb +0 -0
  196. data/test/{models → lib}/tags/partial_test.rb +0 -0
  197. data/test/{models → lib}/tags/snippet_test.rb +0 -0
  198. data/test/{models → lib}/tags/template_test.rb +0 -0
  199. data/test/{models → lib}/view_methods_test.rb +0 -0
  200. data/test/models/{cms/block_test.rb → block_test.rb} +1 -1
  201. data/test/models/{cms/categorization_test.rb → categorization_test.rb} +1 -1
  202. data/test/models/{cms/category_test.rb → category_test.rb} +1 -1
  203. data/test/models/{cms/file_test.rb → file_test.rb} +2 -2
  204. data/test/models/{cms/layout_test.rb → layout_test.rb} +4 -4
  205. data/test/models/{cms/page_test.rb → page_test.rb} +1 -1
  206. data/test/models/{cms/site_test.rb → site_test.rb} +1 -1
  207. data/test/models/{cms/snippet_test.rb → snippet_test.rb} +1 -1
  208. data/test/test_helper.rb +30 -1
  209. metadata +204 -139
  210. data/app/assets/javascripts/comfortable_mexican_sofa/lib/codemirror.js +0 -10
  211. data/app/assets/stylesheets/comfortable_mexican_sofa/lib/codemirror.css +0 -240
  212. data/app/views/cms_admin/layouts/index.html.haml +0 -13
  213. data/app/views/cms_admin/pages/index.html.haml +0 -15
  214. data/app/views/cms_admin/partials/_navigation_inner.html.haml +0 -3
  215. data/app/views/cms_admin/sites/_mirrors.html.haml +0 -18
  216. data/app/views/layouts/cms_admin.html.haml +0 -4
  217. data/app/views/layouts/cms_admin/_body.html.haml +0 -17
  218. data/app/views/layouts/cms_admin/_left.html.haml +0 -16
  219. data/app/views/layouts/cms_admin/_right.html.haml +0 -5
@@ -13,5 +13,5 @@ Hey! Everything is almost done. Please don't forget to
13
13
 
14
14
  * run migrations -> `rake db:migrate`
15
15
 
16
- After that go to http://your-awesome-app/cms-admin to start populating content.
16
+ After that go to http://your-awesome-app/admin to start populating content.
17
17
  Default username and password are: username // password
@@ -1,8 +1,9 @@
1
+ require 'rails/generators/active_record'
2
+
1
3
  module Comfy
2
4
  module Generators
3
5
  class CmsGenerator < Rails::Generators::Base
4
6
 
5
- require 'rails/generators/active_record'
6
7
  include Rails::Generators::Migration
7
8
  include Thor::Actions
8
9
 
@@ -26,11 +27,10 @@ module Comfy
26
27
  end
27
28
 
28
29
  def generate_routing
29
- route "
30
- ComfortableMexicanSofa::Routing.admin(:path => '/cms-admin')
31
-
32
- # Make sure this routeset is defined last
33
- ComfortableMexicanSofa::Routing.content(:path => '/', :sitemap => false)"
30
+ route_string = " ComfortableMexicanSofa::Routing.admin :path => '/admin'\n\n"
31
+ route_string << " # Make sure this routeset is defined last\n"
32
+ route_string << " ComfortableMexicanSofa::Routing.content :path => '/', :sitemap => false\n"
33
+ route route_string[2..-1]
34
34
  end
35
35
 
36
36
  def generate_cms_seeds
@@ -0,0 +1,69 @@
1
+ require 'rails/generators/generated_attribute'
2
+ require 'rails/generators/active_record'
3
+
4
+ module Comfy
5
+ module Generators
6
+ class ScaffoldGenerator < Rails::Generators::NamedBase
7
+
8
+ include Rails::Generators::Migration
9
+
10
+ no_tasks do
11
+ attr_accessor :model_attrs
12
+ end
13
+
14
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
15
+
16
+ argument :model_args, :type => :array, :default => [], :banner => 'attribute:type'
17
+
18
+ def initialize(*args, &block)
19
+ super
20
+ @model_attrs = []
21
+ model_args.each do |arg|
22
+ next unless arg.include?(':')
23
+ @model_attrs << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
24
+ end
25
+ end
26
+
27
+ def self.next_migration_number(dirname)
28
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
29
+ end
30
+
31
+ def generate_model
32
+ migration_template 'migration.rb', "db/migrate/create_#{file_name.pluralize}.rb"
33
+ template 'model.rb', "app/models/#{file_name}.rb"
34
+ template 'tests/model.rb', "test/models/#{file_name}_test.rb"
35
+ template 'tests/fixture.yml', "test/fixtures/#{file_name.pluralize}.yml"
36
+ end
37
+
38
+ def generate_controller
39
+ template 'controller.rb', "app/controllers/admin/#{file_name.pluralize}_controller.rb"
40
+ template 'tests/controller.rb', "test/controllers/admin/#{file_name.pluralize}_controller_test.rb"
41
+ end
42
+
43
+ def generate_views
44
+ template 'views/index.haml', "app/views/admin/#{file_name.pluralize}/index.html.haml"
45
+ template 'views/show.haml', "app/views/admin/#{file_name.pluralize}/show.html.haml"
46
+ template 'views/new.haml', "app/views/admin/#{file_name.pluralize}/new.html.haml"
47
+ template 'views/edit.haml', "app/views/admin/#{file_name.pluralize}/edit.html.haml"
48
+ template 'views/_form.haml', "app/views/admin/#{file_name.pluralize}/_form.html.haml"
49
+ end
50
+
51
+ def generate_route
52
+ route_string = " namespace :admin do\n"
53
+ route_string << " resources :#{file_name.pluralize}\n"
54
+ route_string << " end\n"
55
+ route route_string[2..-1]
56
+ end
57
+
58
+ def generate_navigation_link
59
+ partial_path = 'app/views/admin/cms/partials/_navigation_inner.html.haml'
60
+ unless File.exist?(File.join(destination_root, partial_path))
61
+ create_file partial_path
62
+ end
63
+ append_file partial_path do
64
+ "\n%li= active_link_to '#{class_name.pluralize}', admin_#{file_name.pluralize}_path\n"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,62 @@
1
+ class Admin::<%= class_name.pluralize %>Controller < Admin::Cms::BaseController
2
+
3
+ before_action :build_<%= file_name %>, :only => [:new, :create]
4
+ before_action :load_<%= file_name %>, :only => [:show, :edit, :update, :destroy]
5
+
6
+ def index
7
+ @<%= file_name.pluralize %> = <%= class_name %>.page(params[:page])
8
+ end
9
+
10
+ def show
11
+ render
12
+ end
13
+
14
+ def new
15
+ render
16
+ end
17
+
18
+ def edit
19
+ render
20
+ end
21
+
22
+ def create
23
+ @<%= file_name %>.save!
24
+ flash[:success] = '<%= class_name.titleize %> created'
25
+ redirect_to :action => :show, :id => @<%= file_name %>
26
+ rescue ActiveRecord::RecordInvalid
27
+ flash.now[:error] = 'Failed to create <%= class_name.titleize %>'
28
+ render :action => :new
29
+ end
30
+
31
+ def update
32
+ @<%= file_name %>.update_attributes!(<%= file_name %>_params)
33
+ flash[:success] = '<%= class_name.titleize %> updated'
34
+ redirect_to :action => :show, :id => @<%= file_name %>
35
+ rescue ActiveRecord::RecordInvalid
36
+ flash.now[:error] = 'Failed to update <%= class_name.titleize %>'
37
+ render :action => :edit
38
+ end
39
+
40
+ def destroy
41
+ @<%= file_name %>.destroy
42
+ flash[:success] = '<%= class_name.titleize %> deleted'
43
+ redirect_to :action => :index
44
+ end
45
+
46
+ protected
47
+
48
+ def build_<%= file_name %>
49
+ @<%= file_name %> = <%= class_name %>.new(<%= file_name %>_params)
50
+ end
51
+
52
+ def load_<%= file_name %>
53
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
54
+ rescue ActiveRecord::RecordNotFound
55
+ flash[:error] = '<%= class_name.titleize %> not found'
56
+ redirect_to :action => :index
57
+ end
58
+
59
+ def <%= file_name %>_params
60
+ params.fetch(:<%= file_name %>, {}).permit(<%= model_attrs.collect{|attr| ":#{attr.name}"}.join(', ') %>)
61
+ end
62
+ end
@@ -0,0 +1,12 @@
1
+ class Create<%= class_name.pluralize %> < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :<%= file_name.pluralize %> do |t|
5
+ <%- model_attrs.each do |attr| -%>
6
+ t.<%= attr.type %> :<%= attr.name %>
7
+ <%- end -%>
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,21 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+
3
+ # -- Relationships --------------------------------------------------------
4
+
5
+
6
+ # -- Callbacks ------------------------------------------------------------
7
+
8
+
9
+ # -- Validations ----------------------------------------------------------
10
+
11
+
12
+ # -- Scopes ---------------------------------------------------------------
13
+
14
+
15
+ # -- Class Methods --------------------------------------------------------
16
+
17
+
18
+ # -- Instance Methods -----------------------------------------------------
19
+
20
+
21
+ end
@@ -0,0 +1,102 @@
1
+ require_relative '../../test_helper'
2
+
3
+ class Admin::<%= class_name.pluralize %>ControllerTest < ActionController::TestCase
4
+
5
+ def setup
6
+ # TODO: login as admin user
7
+ @<%= file_name %> = <%= file_name.pluralize %>(:default)
8
+ end
9
+
10
+ def test_get_index
11
+ get :index
12
+ assert_response :success
13
+ assert assigns(:<%= file_name.pluralize %>)
14
+ assert_template :index
15
+ end
16
+
17
+ def test_get_show
18
+ get :show, :id => @<%= file_name %>
19
+ assert_response :success
20
+ assert assigns(:<%= file_name %>)
21
+ assert_template :show
22
+ end
23
+
24
+ def test_get_show_failure
25
+ get :show, :id => 'invalid'
26
+ assert_response :redirect
27
+ assert_redirected_to :action => :index
28
+ assert_equal '<%= class_name.titleize %> not found', flash[:error]
29
+ end
30
+
31
+ def test_get_new
32
+ get :new
33
+ assert_response :success
34
+ assert assigns(:<%= file_name %>)
35
+ assert_template :new
36
+ assert_select 'form[action=/admin/<%= file_name.pluralize %>]'
37
+ end
38
+
39
+ def test_get_edit
40
+ get :edit, :id => @<%= file_name %>
41
+ assert_response :success
42
+ assert assigns(:<%= file_name %>)
43
+ assert_template :edit
44
+ assert_select "form[action=/admin/<%= file_name.pluralize %>/#{@<%= file_name %>.id}]"
45
+ end
46
+
47
+ def test_creation
48
+ assert_difference '<%= class_name %>.count' do
49
+ post :create, :<%= file_name %> => {
50
+ <%- model_attrs.each do |attr| -%>
51
+ :<%= attr.name %> => 'test <%= attr.name %>',
52
+ <%- end -%>
53
+ }
54
+ <%= file_name %> = <%= class_name %>.last
55
+ assert_response :redirect
56
+ assert_redirected_to :action => :show, :id => <%= file_name %>
57
+ assert_equal '<%= class_name.titleize %> created', flash[:success]
58
+ end
59
+ end
60
+
61
+ def test_creation_failure
62
+ assert_no_difference '<%= class_name %>.count' do
63
+ post :create, :<%= file_name %> => { }
64
+ assert_response :success
65
+ assert_template :new
66
+ assert_equal 'Failed to create <%= class_name.titleize %>', flash[:error]
67
+ end
68
+ end
69
+
70
+ def test_update
71
+ put :update, :id => @<%= file_name %>, :<%= file_name %> => {
72
+ <%- if attr = model_attrs.first -%>
73
+ :<%= attr.name %> => 'Updated'
74
+ <%- end -%>
75
+ }
76
+ assert_response :redirect
77
+ assert_redirected_to :action => :show, :id => @<%= file_name %>
78
+ assert_equal '<%= class_name.titleize %> updated', flash[:success]
79
+ @<%= file_name %>.reload
80
+ assert_equal 'Updated', @<%= file_name %>.<%= attr.try(:name) || 'attribute' %>
81
+ end
82
+
83
+ def test_update_failure
84
+ put :update, :id => @<%= file_name %>, :<%= file_name %> => {
85
+ :<%= attr.try(:name) || 'attribute' %> => ''
86
+ }
87
+ assert_response :success
88
+ assert_template :edit
89
+ assert_equal 'Failed to update <%= class_name.titleize %>', flash[:error]
90
+ @<%= file_name %>.reload
91
+ refute_equal '', @<%= file_name %>.<%= attr.try(:name) || 'attribute' %>
92
+ end
93
+
94
+ def test_destroy
95
+ assert_difference '<%= class_name %>.count', -1 do
96
+ delete :destroy, :id => @<%= file_name %>
97
+ assert_response :redirect
98
+ assert_redirected_to :action => :index
99
+ assert_equal '<%= class_name.titleize %> deleted', flash[:success]
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,4 @@
1
+ default:
2
+ <%- model_attrs.each do |attr| -%>
3
+ <%= attr.name %>: default <%= attr.name %>
4
+ <%- end -%>
@@ -0,0 +1,27 @@
1
+ require_relative '../test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+
5
+ def test_fixtures_validity
6
+ <%= class_name %>.all.each do |<%= file_name %>|
7
+ assert <%= file_name %>.valid?, <%= file_name %>.errors.inspect
8
+ end
9
+ end
10
+
11
+ def test_validation
12
+ <%= file_name %> = <%= class_name %>.new
13
+ assert <%= file_name %>.invalid?
14
+ assert_errors_on <%= file_name %>, <%= model_attrs.collect{|attr| ":#{attr.name}"}.join(', ') %>
15
+ end
16
+
17
+ def test_creation
18
+ assert_difference '<%= class_name %>.count' do
19
+ <%= class_name %>.create(
20
+ <%- model_attrs.each do |attr| -%>
21
+ :<%= attr.name %> => 'test <%= attr.name %>',
22
+ <%- end -%>
23
+ )
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,6 @@
1
+ <%- model_attrs.each do |attr| -%>
2
+ = form.text_field :<%= attr.name %>
3
+ <%- end -%>
4
+
5
+ .form-actions
6
+ = form.submit :class => 'btn btn-primary'
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ %h2 Edit <%= class_name.titleize %>
3
+
4
+ = comfy_form_for [:admin, @<%= file_name %>] do |form|
5
+ = render form
@@ -0,0 +1,23 @@
1
+ .page-header
2
+ = link_to 'New <%= class_name.titleize %>', new_admin_<%= file_name %>_path, :class => 'btn pull-right'
3
+ %h2= '<%= class_name.pluralize.titleize %>'
4
+
5
+ = paginate @<%= file_name.pluralize %>
6
+
7
+ %table.table.table-hover.table-bordered
8
+ %tr
9
+ <%- model_attrs.each_with_index do |attr, index| -%>
10
+ %th<%= '.main' if index == 0 %> <%= attr.name.titleize %>
11
+ <%- end -%>
12
+ %th
13
+ - @<%= file_name.pluralize %>.each do |<%= file_name %>|
14
+ %tr
15
+ <%- model_attrs.each_with_index do |attr, index| -%>
16
+ %td<%= '.main' if index == 0 %>= <%= file_name%>.<%= attr.name %>
17
+ <%- end -%>
18
+ %td
19
+ .btn-group
20
+ = link_to 'Edit', edit_admin_<%= file_name %>_path(<%= file_name %>), :class => 'btn btn-small'
21
+ = link_to 'Delete', admin_<%= file_name %>_path(<%= file_name %>), :method => :delete, :data => { :confirm => 'Are you sure?' }, :class => 'btn btn-small btn-danger'
22
+
23
+ = paginate @<%= file_name.pluralize %>
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ %h2 New <%= class_name.titleize %>
3
+
4
+ = comfy_form_for [:admin, @<%= file_name %>] do |form|
5
+ = render form
@@ -0,0 +1,4 @@
1
+ .page-header
2
+ %h2 <%= class_name.titleize %>
3
+
4
+ = debug @<%= file_name %>
@@ -1,11 +1,11 @@
1
- require_relative '../../test_helper'
1
+ require_relative '../../../test_helper'
2
2
 
3
- class CmsAdmin::BaseControllerTest < ActionController::TestCase
3
+ class Admin::Cms::BaseControllerTest < ActionController::TestCase
4
4
 
5
5
  def test_get_jump
6
6
  get :jump
7
7
  assert_response :redirect
8
- assert_redirected_to cms_admin_site_pages_path(cms_sites(:default))
8
+ assert_redirected_to admin_cms_site_pages_path(cms_sites(:default))
9
9
  end
10
10
 
11
11
  def test_get_jump_with_redirect_setting
@@ -1,6 +1,6 @@
1
- require_relative '../../test_helper'
1
+ require_relative '../../../test_helper'
2
2
 
3
- class CmsAdmin::CategoriesControllerTest < ActionController::TestCase
3
+ class Admin::Cms::CategoriesControllerTest < ActionController::TestCase
4
4
 
5
5
  def test_get_edit
6
6
  xhr :get, :edit, :site_id => cms_sites(:default), :id => cms_categories(:default)
@@ -1,6 +1,6 @@
1
- require_relative '../../test_helper'
1
+ require_relative '../../../test_helper'
2
2
 
3
- class CmsAdmin::FilesControllerTest < ActionController::TestCase
3
+ class Admin::Cms::FilesControllerTest < ActionController::TestCase
4
4
 
5
5
  def test_get_index
6
6
  get :index, :site_id => cms_sites(:default)
@@ -61,7 +61,7 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase
61
61
  assert_response :success
62
62
  assert assigns(:file)
63
63
  assert_template :new
64
- assert_select "form[action=/cms-admin/sites/#{site.id}/files][enctype=multipart/form-data]"
64
+ assert_select "form[action=/admin/sites/#{site.id}/files][enctype=multipart/form-data]"
65
65
  end
66
66
 
67
67
  def test_get_edit
@@ -70,7 +70,7 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase
70
70
  assert_response :success
71
71
  assert assigns(:file)
72
72
  assert_template :edit
73
- assert_select "form[action=/cms-admin/sites/#{file.site.id}/files/#{file.id}]"
73
+ assert_select "form[action=/admin/sites/#{file.site.id}/files/#{file.id}]"
74
74
  end
75
75
 
76
76
  def test_get_edit_failure