dry_crud 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +126 -87
  4. data/VERSION +1 -1
  5. data/lib/generators/dry_crud/dry_crud_generator.rb +42 -22
  6. data/lib/generators/dry_crud/templates/INSTALL +5 -5
  7. data/lib/generators/dry_crud/templates/app/assets/stylesheets/crud.scss +0 -20
  8. data/lib/generators/dry_crud/templates/app/assets/stylesheets/sample.scss +24 -4
  9. data/lib/generators/dry_crud/templates/app/controllers/crud/generic_model.rb +89 -0
  10. data/lib/generators/dry_crud/templates/app/controllers/crud/nestable.rb +70 -0
  11. data/lib/generators/dry_crud/templates/app/controllers/crud/rememberable.rb +64 -0
  12. data/lib/generators/dry_crud/templates/app/controllers/crud/render_callbacks.rb +46 -0
  13. data/lib/generators/dry_crud/templates/app/controllers/crud/responder.rb +31 -0
  14. data/lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb +55 -0
  15. data/lib/generators/dry_crud/templates/app/controllers/crud/sortable.rb +63 -0
  16. data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +66 -69
  17. data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +23 -326
  18. data/lib/generators/dry_crud/templates/app/helpers/actions_helper.rb +64 -0
  19. data/lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb +331 -0
  20. data/lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb +280 -0
  21. data/lib/generators/dry_crud/templates/app/helpers/form_helper.rb +52 -0
  22. data/lib/generators/dry_crud/templates/app/helpers/format_helper.rb +164 -0
  23. data/lib/generators/dry_crud/templates/app/helpers/i18n_helper.rb +85 -0
  24. data/lib/generators/dry_crud/templates/app/helpers/table_helper.rb +83 -0
  25. data/lib/generators/dry_crud/templates/app/helpers/utility_helper.rb +84 -0
  26. data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.erb +3 -3
  27. data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.haml +3 -3
  28. data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.erb +1 -1
  29. data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.haml +1 -1
  30. data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.erb +3 -3
  31. data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.haml +3 -3
  32. data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.erb +1 -1
  33. data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.haml +1 -1
  34. data/lib/generators/dry_crud/templates/app/views/crud/_form.html.erb +1 -1
  35. data/lib/generators/dry_crud/templates/app/views/crud/_form.html.haml +1 -1
  36. data/lib/generators/dry_crud/templates/app/views/crud/edit.html.erb +1 -1
  37. data/lib/generators/dry_crud/templates/app/views/crud/edit.html.haml +1 -1
  38. data/lib/generators/dry_crud/templates/app/views/crud/new.html.erb +2 -2
  39. data/lib/generators/dry_crud/templates/app/views/crud/new.html.haml +2 -2
  40. data/lib/generators/dry_crud/templates/app/views/crud/show.html.erb +1 -1
  41. data/lib/generators/dry_crud/templates/app/views/crud/show.html.haml +1 -1
  42. data/lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml +1 -1
  43. data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb +1 -1
  44. data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml +1 -1
  45. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +15 -7
  46. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml +18 -8
  47. data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +3 -3
  48. data/lib/generators/dry_crud/templates/app/views/list/_search.html.haml +3 -3
  49. data/lib/generators/dry_crud/templates/app/views/list/index.html.erb +1 -1
  50. data/lib/generators/dry_crud/templates/app/views/list/index.html.haml +1 -1
  51. data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb +1 -1
  52. data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.haml +1 -1
  53. data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb +2 -4
  54. data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml +2 -3
  55. data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +5 -1
  56. data/lib/generators/dry_crud/templates/config/locales/crud.de.yml +64 -0
  57. data/lib/generators/dry_crud/templates/config/locales/{en_crud.yml → crud.en.yml} +2 -2
  58. data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +241 -231
  59. data/lib/generators/dry_crud/templates/spec/helpers/crud/form_builder_spec.rb +226 -0
  60. data/lib/generators/dry_crud/templates/spec/helpers/{standard_table_builder_spec.rb → crud/table_builder_spec.rb} +36 -34
  61. data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +238 -0
  62. data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +244 -0
  63. data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +132 -0
  64. data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +265 -0
  65. data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +74 -0
  66. data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +185 -100
  67. data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +58 -49
  68. data/lib/generators/dry_crud/templates/test/{functional → controllers}/crud_test_models_controller_test.rb +112 -91
  69. data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_form_builder_test.rb → helpers/crud/form_builder_test.rb} +79 -62
  70. data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_table_builder_test.rb → helpers/crud/table_builder_test.rb} +31 -28
  71. data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +85 -0
  72. data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +129 -0
  73. data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +163 -0
  74. data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +79 -0
  75. data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +217 -0
  76. data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +63 -0
  77. data/lib/generators/dry_crud/templates/test/{functional → support}/crud_controller_test_helper.rb +70 -59
  78. data/lib/generators/dry_crud/templates/test/{crud_test_model.rb → support/crud_test_model.rb} +107 -75
  79. data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +83 -0
  80. metadata +83 -146
  81. data/Rakefile +0 -211
  82. data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +0 -168
  83. data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +0 -27
  84. data/lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb +0 -261
  85. data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +0 -304
  86. data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +0 -178
  87. data/lib/generators/dry_crud/templates/spec/helpers/crud_helper_spec.rb +0 -146
  88. data/lib/generators/dry_crud/templates/spec/helpers/list_helper_spec.rb +0 -154
  89. data/lib/generators/dry_crud/templates/spec/helpers/standard_form_builder_spec.rb +0 -215
  90. data/lib/generators/dry_crud/templates/spec/helpers/standard_helper_spec.rb +0 -387
  91. data/lib/generators/dry_crud/templates/test/custom_assertions.rb +0 -78
  92. data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +0 -117
  93. data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +0 -111
  94. data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +0 -123
  95. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +0 -281
  96. data/test/templates/Gemfile +0 -46
  97. data/test/templates/app/controllers/admin/cities_controller.rb +0 -7
  98. data/test/templates/app/controllers/admin/countries_controller.rb +0 -13
  99. data/test/templates/app/controllers/ajax_controller.rb +0 -9
  100. data/test/templates/app/controllers/people_controller.rb +0 -13
  101. data/test/templates/app/controllers/vips_controller.rb +0 -19
  102. data/test/templates/app/helpers/cities_helper.rb +0 -9
  103. data/test/templates/app/helpers/people_helper.rb +0 -8
  104. data/test/templates/app/models/city.rb +0 -28
  105. data/test/templates/app/models/country.rb +0 -16
  106. data/test/templates/app/models/person.rb +0 -12
  107. data/test/templates/app/views/admin/cities/_actions_index.html.erb +0 -2
  108. data/test/templates/app/views/admin/cities/_actions_index.html.haml +0 -2
  109. data/test/templates/app/views/admin/cities/_attrs.html.erb +0 -1
  110. data/test/templates/app/views/admin/cities/_attrs.html.haml +0 -1
  111. data/test/templates/app/views/admin/cities/_form.html.erb +0 -7
  112. data/test/templates/app/views/admin/cities/_form.html.haml +0 -5
  113. data/test/templates/app/views/admin/cities/_hello.html.erb +0 -1
  114. data/test/templates/app/views/admin/cities/_hello.html.haml +0 -1
  115. data/test/templates/app/views/admin/cities/_list.html.erb +0 -3
  116. data/test/templates/app/views/admin/cities/_list.html.haml +0 -3
  117. data/test/templates/app/views/admin/countries/_list.html.erb +0 -4
  118. data/test/templates/app/views/admin/countries/_list.html.haml +0 -3
  119. data/test/templates/app/views/ajax/_actions_index.html.erb +0 -8
  120. data/test/templates/app/views/ajax/_actions_index.html.haml +0 -8
  121. data/test/templates/app/views/ajax/_actions_show.html.erb +0 -4
  122. data/test/templates/app/views/ajax/_actions_show.html.haml +0 -4
  123. data/test/templates/app/views/ajax/_form.html.erb +0 -2
  124. data/test/templates/app/views/ajax/_form.html.haml +0 -2
  125. data/test/templates/app/views/ajax/_hello.html.erb +0 -1
  126. data/test/templates/app/views/ajax/_hello.html.haml +0 -1
  127. data/test/templates/app/views/ajax/ajax.js.erb +0 -1
  128. data/test/templates/app/views/ajax/ajax.js.haml +0 -1
  129. data/test/templates/app/views/ajax/edit.js.erb +0 -1
  130. data/test/templates/app/views/ajax/edit.js.haml +0 -1
  131. data/test/templates/app/views/ajax/show.js.erb +0 -1
  132. data/test/templates/app/views/ajax/show.js.haml +0 -1
  133. data/test/templates/app/views/ajax/update.js.erb +0 -5
  134. data/test/templates/app/views/ajax/update.js.haml +0 -5
  135. data/test/templates/app/views/layouts/_nav.html.erb +0 -6
  136. data/test/templates/app/views/layouts/_nav.html.haml +0 -5
  137. data/test/templates/app/views/layouts/bootstrap.html.erb +0 -68
  138. data/test/templates/app/views/layouts/bootstrap.html.haml +0 -49
  139. data/test/templates/app/views/people/_attrs.html.erb +0 -5
  140. data/test/templates/app/views/people/_attrs.html.haml +0 -4
  141. data/test/templates/app/views/people/_list.html.erb +0 -1
  142. data/test/templates/app/views/people/_list.html.haml +0 -1
  143. data/test/templates/config/database.yml +0 -21
  144. data/test/templates/config/locales/en_cities.yml +0 -56
  145. data/test/templates/config/routes.rb +0 -32
  146. data/test/templates/db/migrate/20100511174904_create_people_and_cities.rb +0 -26
  147. data/test/templates/db/seeds.rb +0 -74
  148. data/test/templates/spec/controllers/admin/cities_controller_spec.rb +0 -74
  149. data/test/templates/spec/controllers/admin/countries_controller_spec.rb +0 -56
  150. data/test/templates/spec/controllers/people_controller_spec.rb +0 -80
  151. data/test/templates/spec/routing/cities_routing_spec.rb +0 -11
  152. data/test/templates/spec/routing/countries_routing_spec.rb +0 -11
  153. data/test/templates/test/fixtures/cities.yml +0 -11
  154. data/test/templates/test/fixtures/countries.yml +0 -11
  155. data/test/templates/test/fixtures/people.yml +0 -14
  156. data/test/templates/test/functional/admin/cities_controller_test.rb +0 -59
  157. data/test/templates/test/functional/admin/countries_controller_test.rb +0 -42
  158. data/test/templates/test/functional/people_controller_test.rb +0 -68
@@ -1,3 +1,3 @@
1
- <%= link_action_index %>
2
- <%= link_action_show %>
3
- <%= link_action_destroy %>
1
+ <%= index_action_link %>
2
+ <%= show_action_link %>
3
+ <%= destroy_action_link %>
@@ -1,3 +1,3 @@
1
- = link_action_index
2
- = link_action_show
3
- = link_action_destroy
1
+ = index_action_link
2
+ = show_action_link
3
+ = destroy_action_link
@@ -1 +1 @@
1
- <%= link_action_add %>
1
+ <%= add_action_link %>
@@ -1 +1 @@
1
- = link_action_add
1
+ = add_action_link
@@ -1,3 +1,3 @@
1
- <%= link_action_index %>
2
- <%= link_action_edit %>
3
- <%= link_action_destroy %>
1
+ <%= index_action_link %>
2
+ <%= edit_action_link %>
3
+ <%= destroy_action_link %>
@@ -1,3 +1,3 @@
1
- = link_action_index
2
- = link_action_edit
3
- = link_action_destroy
1
+ = index_action_link
2
+ = edit_action_link
3
+ = destroy_action_link
@@ -1 +1 @@
1
- <%= render_attrs entry, *default_attrs %>
1
+ <%= render_attrs entry, *default_crud_attrs %>
@@ -1 +1 @@
1
- = render_attrs entry, *default_attrs
1
+ = render_attrs entry, *default_crud_attrs
@@ -1 +1 @@
1
- <%= entry_form %>
1
+ <%= crud_form %>
@@ -1 +1 @@
1
- = entry_form
1
+ = crud_form
@@ -1,4 +1,4 @@
1
- <% @title ||= ti(:title, :model => full_entry_label).html_safe -%>
1
+ <% @title ||= ti(:title, model: full_entry_label).html_safe -%>
2
2
 
3
3
  <% content_for(:actions, render('actions_edit')) %>
4
4
 
@@ -1,4 +1,4 @@
1
- - @title ||= ti(:title, :model => full_entry_label).html_safe
1
+ - @title ||= ti(:title, model: full_entry_label).html_safe
2
2
 
3
3
  - content_for(:actions, render('actions_edit'))
4
4
 
@@ -1,5 +1,5 @@
1
- <% @title ||= ti(:title, :model => models_label.singularize) -%>
1
+ <% @title ||= ti(:title, model: models_label(false)) -%>
2
2
 
3
- <% content_for(:actions, link_action_index) %>
3
+ <% content_for(:actions, index_action_link) %>
4
4
 
5
5
  <%= render 'form' %>
@@ -1,5 +1,5 @@
1
- - @title ||= ti(:title, :model => models_label.singularize)
1
+ - @title ||= ti(:title, model: models_label(false))
2
2
 
3
- - content_for(:actions, link_action_index)
3
+ - content_for(:actions, index_action_link)
4
4
 
5
5
  = render 'form'
@@ -1,4 +1,4 @@
1
- <% @title ||= ti(:title, :model => full_entry_label).html_safe -%>
1
+ <% @title ||= ti(:title, model: full_entry_label).html_safe -%>
2
2
 
3
3
  <% content_for(:actions, render('actions_show')) %>
4
4
 
@@ -1,4 +1,4 @@
1
- - @title ||= ti(:title, :model => full_entry_label).html_safe
1
+ - @title ||= ti(:title, model: full_entry_label).html_safe
2
2
 
3
3
  - content_for(:actions, render('actions_show'))
4
4
 
@@ -1,2 +1,2 @@
1
1
  - if flash[level].present?
2
- %div{:class => "alert alert-#{flash_class(level)}"}= flash[level]
2
+ %div{class: "alert alert-#{flash_class(level)}"}= flash[level]
@@ -1,4 +1,4 @@
1
- <%= link_to 'MyApp', root_path, :class => 'brand' %>
1
+ <%= link_to 'MyApp', root_path, class: 'brand' %>
2
2
  <ul class="nav">
3
3
  <li><%= link_to "Link1", "/path1" %></li>
4
4
  <li><%= link_to "Link2", "/path2" %></li>
@@ -1,4 +1,4 @@
1
- = link_to 'MyApp', root_path, :class => 'brand'
1
+ = link_to 'MyApp', root_path, class: 'brand'
2
2
  %ul.nav
3
3
  %li= link_to "Link1", "/path1"
4
4
  %li= link_to "Link2", "/path2"
@@ -3,7 +3,7 @@
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="utf-8" />
6
- <title><%= strip_tags(@title) %></title>
6
+ <title><%= strip_tags(@title) %> - MyApp</title>
7
7
  <%= csrf_meta_tag %>
8
8
 
9
9
  <!-- HTML5 shim, for IE6-8 support of HTML elements -->
@@ -11,13 +11,22 @@
11
11
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
12
12
  <![endif]-->
13
13
 
14
- <%= stylesheet_link_tag 'application', :media => 'all' %>
14
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
15
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
15
16
 
16
17
  <!-- fav and touch icons -->
17
18
  <%= favicon_link_tag %>
18
- <%= favicon_link_tag '/apple-touch-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>
19
- <%= favicon_link_tag '/apple-touch-icon-72x72.png', :rel => 'apple-touch-icon', :type => 'image/png', :sizes => "72x72" %>
20
- <%= favicon_link_tag '/apple-touch-icon-114x114.png', :rel => 'apple-touch-icon', :type => 'image/png', :sizes => "114x114" %>
19
+ <%= favicon_link_tag '/apple-touch-icon.png',
20
+ rel: 'apple-touch-icon',
21
+ type: 'image/png' %>
22
+ <%= favicon_link_tag '/apple-touch-icon-72x72.png',
23
+ rel: 'apple-touch-icon',
24
+ type: 'image/png',
25
+ sizes: "72x72" %>
26
+ <%= favicon_link_tag '/apple-touch-icon-114x114.png',
27
+ rel: 'apple-touch-icon',
28
+ type: 'image/png',
29
+ sizes: "114x114" %>
21
30
 
22
31
  <%= yield :head %>
23
32
  </head>
@@ -31,7 +40,7 @@
31
40
 
32
41
  <h1><%= @title %></h1>
33
42
 
34
- <%= render :partial => 'layouts/flash', :collection => [:notice, :alert], :as => :level %>
43
+ <%= render partial: 'layouts/flash', collection: [:notice, :alert], as: :level %>
35
44
 
36
45
  <div class="actions btn-toolbar">
37
46
  <div class="pull-right">
@@ -53,7 +62,6 @@
53
62
  </footer>
54
63
 
55
64
  <!-- Javascript placed at the end of the document so the pages load faster -->
56
- <%= javascript_include_tag 'application' %>
57
65
  <%= javascript_tag yield(:javascripts) if content_for?(:javascripts) %>
58
66
 
59
67
  </body>
@@ -3,7 +3,9 @@
3
3
  %html
4
4
  %head
5
5
  %meta{:charset => 'utf-8'}
6
- %title= strip_tags(@title)
6
+ %title
7
+ = strip_tags(@title)
8
+ \- MyApp
7
9
  = csrf_meta_tag
8
10
 
9
11
  <!-- HTML5 shim, for IE6-8 support of HTML elements -->
@@ -11,12 +13,21 @@
11
13
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
12
14
  <![endif]-->
13
15
 
14
- = stylesheet_link_tag 'application', :media => 'all'
15
-
16
+ = stylesheet_link_tag 'application', :media => 'all', 'data-turbolinks-track' => true
17
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
18
+
16
19
  = favicon_link_tag
17
- = favicon_link_tag '/apple-touch-icon.png', :rel => 'apple-touch-icon', :type => 'image/png'
18
- = favicon_link_tag '/apple-touch-icon-72x72.png', :rel => 'apple-touch-icon', :type => 'image/png', :sizes => "72x72"
19
- = favicon_link_tag '/apple-touch-icon-114x114.png', :rel => 'apple-touch-icon', :type => 'image/png', :sizes => "114x114"
20
+ = favicon_link_tag '/apple-touch-icon.png',
21
+ rel: 'apple-touch-icon',
22
+ type: 'image/png'
23
+ = favicon_link_tag '/apple-touch-icon-72x72.png',
24
+ rel: 'apple-touch-icon',
25
+ type: 'image/png',
26
+ sizes: "72x72"
27
+ = favicon_link_tag '/apple-touch-icon-114x114.png',
28
+ rel: 'apple-touch-icon',
29
+ type: 'image/png',
30
+ sizes: "114x114"
20
31
 
21
32
  = yield :head
22
33
 
@@ -26,7 +37,7 @@
26
37
 
27
38
  %h1= @title
28
39
 
29
- = render :partial => 'layouts/flash', :collection => [:notice, :alert], :as => :level
40
+ = render partial: 'layouts/flash', collection: [:notice, :alert], as: :level
30
41
 
31
42
  .actions.btn-toolbar
32
43
  .pull-right= yield :actions
@@ -38,5 +49,4 @@
38
49
  %p
39
50
  &copy; code!z #{Time.zone.now.year}
40
51
 
41
- = javascript_include_tag 'application'
42
52
  = javascript_tag yield(:javascripts) if content_for?(:javascripts)
@@ -1,6 +1,6 @@
1
- <%= form_tag(nil, {:method => :get, :class => 'form-search'}) do %>
1
+ <%= form_tag(nil, { method: :get, class: 'form-search' }) do %>
2
2
  <%= hidden_field_tag :returning, true %>
3
3
  <%= hidden_field_tag :page, 1 %>
4
- <%= search_field_tag :q, params[:q], :class => 'search-query' %>
5
- <%= submit_tag ti(:"button.search"), :class => 'btn' %>
4
+ <%= search_field_tag :q, params[:q], class: 'search-query' %>
5
+ <%= submit_tag ti(:"button.search"), class: 'btn' %>
6
6
  <% end %>
@@ -1,5 +1,5 @@
1
- = form_tag(nil, {:method => :get, :class => 'form-search'}) do
1
+ = form_tag(nil, { method: :get, class: 'form-search' }) do
2
2
  = hidden_field_tag :returning, true
3
3
  = hidden_field_tag :page, 1
4
- = search_field_tag :q, params[:q], :class => 'search-query'
5
- = submit_tag ti(:"button.search"), :class => 'btn'
4
+ = search_field_tag :q, params[:q], class: 'search-query'
5
+ = submit_tag ti(:"button.search"), class: 'btn'
@@ -1,4 +1,4 @@
1
- <% @title ||= ti(:title, :models => models_label) -%>
1
+ <% @title ||= ti(:title, models: models_label) -%>
2
2
 
3
3
  <% content_for(:tools, render('search')) if search_support? %>
4
4
 
@@ -1,4 +1,4 @@
1
- - @title ||= ti(:title, :models => models_label)
1
+ - @title ||= ti(:title, models: models_label)
2
2
 
3
3
  - content_for(:tools, render('search')) if search_support?
4
4
 
@@ -1,7 +1,7 @@
1
1
  <% if errors.any? %>
2
2
  <div id='error_explanation' class='alert alert-error'>
3
3
  <h2>
4
- <%= ti(:"errors.header", :count => errors.count, :model => object.to_s) %>
4
+ <%= ti(:"errors.header", count: errors.count, model: object.to_s) %>
5
5
  </h2>
6
6
  <ul>
7
7
  <% errors.full_messages.each do |msg| %>
@@ -1,6 +1,6 @@
1
1
  - if errors.any?
2
2
  #error_explanation.alert.alert-error
3
- %h2= ti(:"errors.header", :count => errors.count, :model => object.to_s)
3
+ %h2= ti(:"errors.header", count: errors.count, model: object.to_s)
4
4
  %ul
5
5
  - errors.full_messages.each do |msg|
6
6
  %li= msg
@@ -1,4 +1,2 @@
1
- <div class="labeled">
2
- <label><%= label.presence || raw(StandardHelper::EMPTY_STRING) %></label>
3
- <div class="value"><%= content.presence || raw(StandardHelper::EMPTY_STRING) %></div>
4
- </div>
1
+ <dt><%= label.presence || raw(UtilityHelper::EMPTY_STRING) %></dt>
2
+ <dd class="value"><%= content.presence || raw(UtilityHelper::EMPTY_STRING) %></dd>
@@ -1,3 +1,2 @@
1
- .labeled
2
- %label= label.presence || raw(StandardHelper::EMPTY_STRING)
3
- .value= content.presence || raw(StandardHelper::EMPTY_STRING)
1
+ %dt= label.presence || raw(UtilityHelper::EMPTY_STRING)
2
+ %dd.value= content.presence || raw(UtilityHelper::EMPTY_STRING)
@@ -1 +1,5 @@
1
- ActionView::Base.field_error_proc = Proc.new {|html_tag, instance| html_tag }
1
+ # encoding: UTF-8
2
+
3
+ # Fields with errors are directly styled in Crud::FormBuilder.
4
+ # Rails should just output the plain html tag.
5
+ ActionView::Base.field_error_proc = proc { |html_tag, instance| html_tag }
@@ -0,0 +1,64 @@
1
+ # Translations of all crud strings.
2
+ # See also I18nHelper#translate_inheritable and #translate_association.
3
+
4
+ de:
5
+ # global scope
6
+ global:
7
+ "yes": "ja"
8
+ "no": "nein"
9
+ no_list_entries: Keine Einträge gefunden.
10
+ confirm_delete: Wollen Sie diesen Eintrag wirklich löschen?
11
+
12
+ associations:
13
+ # association keys may be customized per model with the prefix
14
+ # 'activerecord.associations.{model}.' or even per actual association with
15
+ # 'activerecord.associations.models.{holder_model}.{assoc_name}.'
16
+ no_entry: (keine)
17
+ none_available: (keine verfügbar)
18
+ please_select: Bitte auswählen
19
+
20
+ button:
21
+ save: Speichern
22
+ cancel: Abbrechen
23
+ search: Suchen
24
+
25
+ link:
26
+ show: Anzeigen
27
+ edit: Bearbeiten
28
+ add: Erstellen
29
+ delete: Löschen
30
+ list: Liste
31
+
32
+ errors:
33
+ header:
34
+ one: "Ein Fehler verhinderte das Speichern dieses Eintrages:"
35
+ other: "%{count} Fehler verhinderten das Speichern dieses Eintrages:"
36
+
37
+ # formats
38
+ time:
39
+ formats:
40
+ time: "%H:%M"
41
+
42
+ # list controller
43
+ list:
44
+ index:
45
+ title: "%{models}"
46
+
47
+ # crud controller
48
+ crud:
49
+ show:
50
+ title: "%{model}"
51
+ new:
52
+ title: "%{model} erstellen"
53
+ edit:
54
+ title: "%{model} bearbeiten"
55
+ create:
56
+ flash:
57
+ success: "%{model} wurde erfolgreich erstellt."
58
+ update:
59
+ flash:
60
+ success: "%{model} wurde erfolgreich aktualisiert."
61
+ destroy:
62
+ flash:
63
+ success: "%{model} wurde erfolgreich gelöscht."
64
+ failure: "%{model} konnte nicht gelöscht werden."
@@ -1,4 +1,4 @@
1
- # Translations of all crud strings.
1
+ # Translations of all crud strings.
2
2
  # See also StandardHelper#translate_inheritable and #translate_association.
3
3
 
4
4
  en:
@@ -28,7 +28,7 @@ en:
28
28
  add: Add
29
29
  delete: Delete
30
30
  list: List
31
-
31
+
32
32
  errors:
33
33
  header:
34
34
  one: "1 error prohibited this entry from being saved:"
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'spec_helper'
2
3
 
3
4
  # Tests all actions of the CrudController based on a dummy model
@@ -8,137 +9,123 @@ describe CrudTestModelsController do
8
9
 
9
10
  include CrudTestHelper
10
11
 
11
- before(:all) do
12
+ before(:all) do
12
13
  reset_db
13
14
  setup_db
14
15
  create_test_data
15
16
  end
16
-
17
+
17
18
  after(:all) { reset_db }
18
-
19
+
19
20
  before { special_routing }
20
-
21
-
21
+
22
22
  include_examples 'crud controller', {}
23
23
 
24
- let(:test_entry) { crud_test_models(:AAAAA) }
24
+ let(:test_entry) { crud_test_models(:AAAAA) }
25
25
  let(:new_entry_attrs) do
26
- {:name => 'foo',
27
- :children => 42,
28
- :companion_id => 3,
29
- :rating => 8.5,
30
- :income => 2.42,
31
- :birthdate => '31-12-1999'.to_date,
32
- :human => true,
33
- :remarks => "some custom\n\tremarks"}
26
+ { name: 'foo',
27
+ children: 42,
28
+ companion_id: 3,
29
+ rating: 8.5,
30
+ income: 2.42,
31
+ birthdate: '31-12-1999'.to_date,
32
+ human: true,
33
+ remarks: "some custom\n\tremarks" }
34
34
  end
35
35
  let(:edit_entry_attrs) do
36
- {:name => 'foo',
37
- :children => 42,
38
- :rating => 8.5,
39
- :income => 2.42,
40
- :birthdate => '31-12-1999'.to_date,
41
- :human => true,
42
- :remarks => "some custom\n\tremarks"}
36
+ { name: 'foo',
37
+ children: 42,
38
+ rating: 8.5,
39
+ income: 2.42,
40
+ birthdate: '31-12-1999'.to_date,
41
+ human: true,
42
+ remarks: "some custom\n\tremarks" }
43
43
  end
44
-
45
-
46
- describe "setup" do
47
- it "model count should be correct" do
44
+
45
+ describe 'setup' do
46
+ it 'model count should be correct' do
48
47
  CrudTestModel.count.should == 6
49
48
  end
50
-
51
- it "should have models_label" do
49
+
50
+ it 'has models_label' do
52
51
  controller.models_label.should == 'Crud Test Models'
53
52
  end
54
-
55
- it "should have models_label singular" do
53
+
54
+ it 'has models_label singular' do
56
55
  controller.models_label(false).should == 'Crud Test Model'
57
56
  end
58
-
59
- it "should route index" do
60
- { :get => "/crud_test_models" }.should route_to(
61
- :controller => "crud_test_models",
62
- :action => "index"
63
- )
64
- end
65
-
66
- it "should route show" do
67
- { :get => "/crud_test_models/1" }.should route_to(
68
- :controller => "crud_test_models",
69
- :action => "show",
70
- :id => '1'
71
- )
72
- end
73
57
  end
74
-
58
+
75
59
  describe_action :get, :index do
76
- context '.html', :format => :html do
77
- context 'plain', :combine => 'ihp' do
78
- it "should contain all entries" do
60
+ context '.html', format: :html do
61
+ context 'plain', combine: 'ihp' do
62
+ it 'contains all entries' do
79
63
  entries.size.should == 6
80
64
  end
81
-
82
- it "session should have empty list_params" do
65
+
66
+ it 'session should have empty list_params' do
83
67
  session[:list_params].should == Hash.new
84
68
  end
85
-
86
- it "should provide entries helper method" do
69
+
70
+ it 'provides entries helper method' do
87
71
  should render_template('index')
88
72
  entries.should be(controller.send(:entries))
89
73
  end
90
74
  end
91
-
92
- context "search" do
93
- let(:params) { {:q => search_value} }
94
-
95
- context "regular", :combine => 'ihse' do
96
- it "entries should only contain test_entry" do
75
+
76
+ context 'search' do
77
+ let(:params) { { q: search_value } }
78
+
79
+ context 'regular', combine: 'ihse' do
80
+ it 'entries should only contain test_entry' do
97
81
  entries.should == [test_entry]
98
82
  end
99
-
100
- it "session should have query list param" do
101
- session[:list_params]['/crud_test_models.html'].should == {:q => 'AAAA'}
83
+
84
+ it 'session should have query list param' do
85
+ session[:list_params]['/crud_test_models.html'].should ==
86
+ { q: 'AAAA' }
102
87
  end
103
88
  end
104
-
105
- context "with custom options", :combine => 'ihsec' do
106
- let(:params) { {:q => 'DDD', :filter => true} }
107
-
89
+
90
+ context 'with custom options', combine: 'ihsec' do
91
+ let(:params) { { q: 'DDD', filter: true } }
92
+
108
93
  it_should_respond
109
-
110
- it "entries should have one item" do
94
+
95
+ it 'entries should have one item' do
111
96
  entries.should == [CrudTestModel.find_by_name('BBBBB')]
112
97
  end
113
-
114
- it "session should have query list param" do
115
- session[:list_params]['/crud_test_models.html'].should == {:q => 'DDD'}
98
+
99
+ it 'session should have query list param' do
100
+ session[:list_params]['/crud_test_models.html'].should ==
101
+ { q: 'DDD' }
116
102
  end
117
103
  end
118
104
  end
119
-
120
- context "sort" do
121
- context "for given column", :combine => 'ihsog' do
122
- let(:params) { {:sort => 'children', :sort_dir => 'asc'} }
123
-
105
+
106
+ context 'sort' do
107
+ context 'for given column', combine: 'ihsog' do
108
+ let(:params) { { sort: 'children', sort_dir: 'asc' } }
109
+
124
110
  it_should_respond
125
-
126
- it "entries should be in correct order" do
111
+
112
+ it 'entries should be in correct order' do
127
113
  entries.should == CrudTestModel.all.sort_by(&:children)
128
114
  end
129
-
130
- it "session should have sort list param" do
131
- session[:list_params]['/crud_test_models.html'].should == {:sort => 'children', :sort_dir => 'asc'}
115
+
116
+ it 'session should have sort list param' do
117
+ session[:list_params]['/crud_test_models.html'].should ==
118
+ { sort: 'children', sort_dir: 'asc' }
132
119
  end
133
120
  end
134
-
135
- context "for virtual column", :combine => 'ihsov' do
136
- let(:params) { {:sort => 'chatty', :sort_dir => 'desc'} }
137
-
121
+
122
+ context 'for virtual column', combine: 'ihsov' do
123
+ let(:params) { { sort: 'chatty', sort_dir: 'desc' } }
124
+
138
125
  it_should_respond
139
-
140
- it "entries should be in correct order" do
141
- names = entries.collect(&:name)
126
+
127
+ it 'entries should be in correct order' do
128
+ names = entries.map(&:name)
142
129
  assert names.index('BBBBB') < names.index('AAAAA')
143
130
  assert names.index('BBBBB') < names.index('DDDDD')
144
131
  assert names.index('EEEEE') < names.index('AAAAA')
@@ -146,288 +133,311 @@ describe CrudTestModelsController do
146
133
  assert names.index('AAAAA') < names.index('CCCCC')
147
134
  assert names.index('DDDDD') < names.index('CCCCC')
148
135
  end
149
-
150
- it "session should have sort list param" do
151
- session[:list_params]['/crud_test_models.html'].should == {:sort => 'chatty', :sort_dir => 'desc'}
136
+
137
+ it 'session should have sort list param' do
138
+ session[:list_params]['/crud_test_models.html'].should ==
139
+ { sort: 'chatty', sort_dir: 'desc' }
152
140
  end
153
141
  end
154
-
155
- context "with search", :combine => 'ihsose' do
156
- let(:params) { {:q => 'DDD', :sort => 'chatty', :sort_dir => 'asc'} }
157
-
142
+
143
+ context 'with search', combine: 'ihsose' do
144
+ let(:params) do
145
+ { q: 'DDD', sort: 'chatty', sort_dir: 'asc' }
146
+ end
147
+
158
148
  it_should_respond
159
-
160
- it "entries should be in correct order" do
161
- entries.collect(&:name).should == ['CCCCC', 'DDDDD', 'BBBBB']
149
+
150
+ it 'entries should be in correct order' do
151
+ entries.map(&:name).should == %w(CCCCC DDDDD BBBBB)
162
152
  end
163
-
164
- it "session should have sort list param" do
165
- session[:list_params]['/crud_test_models.html'].should == {:q => 'DDD', :sort => 'chatty', :sort_dir => 'asc'}
153
+
154
+ it 'session should have sort list param' do
155
+ session[:list_params]['/crud_test_models.html'].should ==
156
+ { q: 'DDD', sort: 'chatty', sort_dir: 'asc' }
166
157
  end
167
158
  end
168
159
  end
169
-
170
- context "with custom options", :combine => 'ihsoco' do
171
- let(:params) { {:filter => true} }
172
-
160
+
161
+ context 'with custom options', combine: 'ihsoco' do
162
+ let(:params) { { filter: true } }
163
+
173
164
  it_should_respond
174
-
175
- context "entries" do
165
+
166
+ context 'entries' do
176
167
  subject { entries }
177
168
  it { should have(2).items }
178
169
  it { should == entries.sort_by(&:children).reverse }
179
170
  end
180
171
  end
181
-
182
- context "returning", :perform_request => false do
172
+
173
+ context 'returning', perform_request: false do
183
174
  before do
184
175
  session[:list_params] = {}
185
- session[:list_params]['/crud_test_models'] = {:q => 'DDD', :sort => 'chatty', :sort_dir => 'desc'}
186
- get :index, :returning => true
176
+ session[:list_params]['/crud_test_models'] =
177
+ { q: 'DDD', sort: 'chatty', sort_dir: 'desc' }
178
+ get :index, returning: true
187
179
  end
188
-
180
+
189
181
  it_should_respond
190
-
191
- it "entries should be in correct order" do
192
- entries.collect(&:name).should == ['BBBBB', 'DDDDD', 'CCCCC']
182
+
183
+ it 'entries should be in correct order' do
184
+ entries.map(&:name).should == %w(BBBBB DDDDD CCCCC)
193
185
  end
194
-
195
- it "params should be set" do
186
+
187
+ it 'params should be set' do
196
188
  controller.params[:q].should == 'DDD'
197
189
  controller.params[:sort].should == 'chatty'
198
190
  controller.params[:sort_dir].should == 'desc'
199
191
  end
200
192
  end
201
193
  end
202
-
203
- context ".js", :format => :js, :combine => 'ijs' do
194
+
195
+ context '.js', format: :js, combine: 'ijs' do
204
196
  it_should_respond
205
197
  it_should_assign_entries
206
198
  its(:body) { should == 'index js' }
207
199
  end
208
200
  end
209
-
201
+
210
202
  describe_action :get, :new do
211
- context "plain", :combine => 'new' do
212
- it "should assign companions" do
203
+ context 'plain', combine: 'new' do
204
+ it 'should assign companions' do
213
205
  assigns(:companions).should be_present
214
206
  end
215
-
216
- it "should have called two render callbacks" do
217
- controller.called_callbacks.should == [:before_render_new, :before_render_form]
207
+
208
+ it 'should have called two render callbacks' do
209
+ controller.called_callbacks.should ==
210
+ [:before_render_new, :before_render_form]
218
211
  end
219
212
  end
220
-
221
- context "with before_render callback redirect", :perform_request => false do
213
+
214
+ context 'with before_render callback redirect',
215
+ perform_request: false do
222
216
  before do
223
217
  controller.should_redirect = true
224
218
  get :new
225
219
  end
226
-
220
+
227
221
  it { should redirect_to(crud_test_models_path) }
228
-
229
- it "should not set companions" do
222
+
223
+ it 'should not set companions' do
230
224
  assigns(:companions).should be_nil
231
225
  end
232
226
  end
233
227
  end
234
-
228
+
235
229
  describe_action :post, :create do
236
- let(:params) { {model_identifier => new_entry_attrs} }
237
-
238
- it "should have called the correct callbacks" do
239
- controller.called_callbacks.should == [:before_create, :before_save, :after_save, :after_create]
230
+ let(:params) { { model_identifier => new_entry_attrs } }
231
+
232
+ it 'should have called the correct callbacks' do
233
+ controller.called_callbacks.should ==
234
+ [:before_create, :before_save, :after_save, :after_create]
240
235
  end
241
-
242
- context "with before callback" do
243
- let(:params) { {:crud_test_model => {:name => 'illegal', :children => 2}} }
244
- it "should not create entry", :perform_request => false do
236
+
237
+ context 'with before callback' do
238
+ let(:params) do
239
+ { crud_test_model: { name: 'illegal', children: 2 } }
240
+ end
241
+ it 'should not create entry', perform_request: false do
245
242
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
246
243
  end
247
-
248
- context "plain", :combine => 'chcp' do
244
+
245
+ context 'plain', combine: 'chcp' do
249
246
  it_should_respond
250
247
  it_should_render('new')
251
248
  it_should_persist_entry(false)
252
249
  it_should_have_flash(:alert)
253
-
254
- it "should set entry name" do
250
+
251
+ it 'should set entry name' do
255
252
  entry.name.should == 'illegal'
256
253
  end
257
-
258
- it "should assign companions" do
254
+
255
+ it 'should assign companions' do
259
256
  assigns(:companions).should be_present
260
257
  end
261
-
262
- it "should have called the correct callbacks" do
263
- controller.called_callbacks.should == [:before_render_new, :before_render_form]
258
+
259
+ it 'should have called the correct callbacks' do
260
+ controller.called_callbacks.should ==
261
+ [:before_render_new, :before_render_form]
264
262
  end
265
263
  end
266
-
267
- context "redirect", :perform_request => false do
264
+
265
+ context 'redirect', perform_request: false do
268
266
  before { controller.should_redirect = true }
269
-
270
- it "should not create entry" do
267
+
268
+ it 'should not create entry' do
271
269
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
272
270
  end
273
-
274
- it { perform_request; should redirect_to(crud_test_models_path) }
275
-
276
- it "should have called no callbacks" do
271
+
272
+ it do
273
+ perform_request
274
+ should redirect_to(crud_test_models_path)
275
+ end
276
+
277
+ it 'should have called no callbacks' do
277
278
  perform_request
278
279
  controller.called_callbacks.should be_nil
279
280
  end
280
281
  end
281
282
  end
282
-
283
- context "with invalid params" do
284
- let(:params) { {:crud_test_model => {:children => 2}} }
285
-
286
- context ".html" do
287
- it "should not create entry", :perform_request => false do
283
+
284
+ context 'with invalid params' do
285
+ let(:params) { { crud_test_model: { children: 2 } } }
286
+
287
+ context '.html' do
288
+ it 'should not create entry', perform_request: false do
288
289
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
289
290
  end
290
-
291
- context "plain", :combine => 'chip' do
291
+
292
+ context 'plain', combine: 'chip' do
292
293
  it_should_respond
293
294
  it_should_render('new')
294
295
  it_should_persist_entry(false)
295
296
  it_should_not_have_flash(:notice)
296
297
  it_should_not_have_flash(:alert)
297
-
298
- it "should assign companions" do
298
+
299
+ it 'should assign companions' do
299
300
  assigns(:companions).should be_present
300
301
  end
301
-
302
- it "should have called the correct callbacks" do
303
- controller.called_callbacks.should == [:before_create, :before_save, :before_render_new, :before_render_form]
302
+
303
+ it 'should have called the correct callbacks' do
304
+ controller.called_callbacks.should ==
305
+ [:before_create, :before_save,
306
+ :before_render_new, :before_render_form]
304
307
  end
305
308
  end
306
309
  end
307
-
308
- context ".json", :format => :json do
309
- it "should not create entry", :perform_request => false do
310
+
311
+ context '.json', format: :json do
312
+ it 'should not create entry', perform_request: false do
310
313
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
311
314
  end
312
-
313
- context "plain", :combine => 'cjcb' do
315
+
316
+ context 'plain', combine: 'cjcb' do
314
317
  it_should_respond(422)
315
318
  it_should_persist_entry(false)
316
319
  it_should_not_have_flash(:notice)
317
320
  it_should_not_have_flash(:alert)
318
-
319
- it "should not assign companions" do
321
+
322
+ it 'should not assign companions' do
320
323
  assigns(:companions).should be_nil
321
324
  end
322
-
323
- it "should have called the correct callbacks" do
324
- controller.called_callbacks.should == [:before_create, :before_save]
325
+
326
+ it 'should have called the correct callbacks' do
327
+ controller.called_callbacks.should ==
328
+ [:before_create, :before_save]
325
329
  end
326
-
330
+
327
331
  its(:body) { should match(/errors/) }
328
332
  end
329
333
  end
330
334
  end
331
-
335
+
332
336
  end
333
337
 
334
- describe_action :get, :edit, :id => true do
335
- it "should have called the correct callbacks" do
336
- controller.called_callbacks.should == [:before_render_edit, :before_render_form]
338
+ describe_action :get, :edit, id: true do
339
+ it 'should have called the correct callbacks' do
340
+ controller.called_callbacks.should ==
341
+ [:before_render_edit, :before_render_form]
337
342
  end
338
343
  end
339
344
 
340
- describe_action :put, :update, :id => true do
341
- let(:params) { {model_identifier => edit_entry_attrs} }
342
-
343
- it "should have called the correct callbacks" do
344
- controller.called_callbacks.should == [:before_update, :before_save, :after_save, :after_update]
345
+ describe_action :put, :update, id: true do
346
+ let(:params) { { model_identifier => edit_entry_attrs } }
347
+
348
+ it 'should have called the correct callbacks' do
349
+ controller.called_callbacks.should ==
350
+ [:before_update, :before_save, :after_save, :after_update]
345
351
  end
346
-
347
- context "with invalid params" do
348
- let(:params) { {:crud_test_model => {:rating => 20}} }
349
-
350
- context ".html", :combine => 'uhivp' do
352
+
353
+ context 'with invalid params' do
354
+ let(:params) { { crud_test_model: { rating: 20 } } }
355
+
356
+ context '.html', combine: 'uhivp' do
351
357
  it_should_respond
352
358
  it_should_render('edit')
353
359
  it_should_not_have_flash(:notice)
354
-
355
- it "should change entry" do
360
+
361
+ it 'should change entry' do
356
362
  entry.should be_changed
357
363
  end
358
-
359
- it "should set entry rating" do
364
+
365
+ it 'should set entry rating' do
360
366
  entry.rating.should == 20
361
367
  end
362
-
363
- it "should have called the correct callbacks" do
364
- controller.called_callbacks.should == [:before_update, :before_save, :before_render_edit, :before_render_form]
368
+
369
+ it 'should have called the correct callbacks' do
370
+ controller.called_callbacks.should ==
371
+ [:before_update, :before_save,
372
+ :before_render_edit, :before_render_form]
365
373
  end
366
374
  end
367
-
368
- context ".json", :format => :json, :combine => 'ujivp' do
375
+
376
+ context '.json', format: :json, combine: 'ujivp' do
369
377
  it_should_respond(422)
370
378
  it_should_not_have_flash(:notice)
371
-
372
- it "should have called the correct callbacks" do
379
+
380
+ it 'should have called the correct callbacks' do
373
381
  controller.called_callbacks.should == [:before_update, :before_save]
374
382
  end
375
-
383
+
376
384
  its(:body) { should match(/errors/) }
377
385
  end
378
386
  end
379
-
387
+
380
388
  end
381
-
382
- describe_action :delete, :destroy, :id => true do
383
- it "should have called the correct callbacks" do
389
+
390
+ describe_action :delete, :destroy, id: true do
391
+ it 'should have called the correct callbacks' do
384
392
  controller.called_callbacks.should == [:before_destroy, :after_destroy]
385
393
  end
386
-
387
- context "with failure" do
394
+
395
+ context 'with failure' do
388
396
  let(:test_entry) { crud_test_models(:BBBBB) }
389
- context ".html" do
390
- it "should not delete entry from database", :perform_request => false do
391
- expect { perform_request }.to change { CrudTestModel.count }.by(0)
397
+ context '.html' do
398
+ it 'should not delete entry from database',
399
+ perform_request: false do
400
+ expect { perform_request }.not_to change { CrudTestModel.count }
392
401
  end
393
-
394
- it "should redirect to referer", :perform_request => false do
402
+
403
+ it 'should redirect to referer',
404
+ perform_request: false do
395
405
  ref = @request.env['HTTP_REFERER'] = crud_test_model_url(test_entry)
396
406
  perform_request
397
407
  should redirect_to(ref)
398
408
  end
399
-
409
+
400
410
  it_should_have_flash(:alert, /companion/)
401
411
  it_should_not_have_flash(:notice)
402
412
  end
403
-
404
- context ".json", :format => :json, :combine => 'djf' do
413
+
414
+ context '.json', format: :json, combine: 'djf' do
405
415
  it_should_respond(422)
406
416
  it_should_not_have_flash(:notice)
407
417
  its(:body) { should match(/errors/) }
408
418
  end
409
-
410
- context "callback", :perform_request => false do
419
+
420
+ context 'callback', perform_request: false do
411
421
  before do
412
422
  test_entry.update_attribute :name, 'illegal'
413
423
  end
414
-
415
- it "should not delete entry from database" do
416
- expect { perform_request }.to change { CrudTestModel.count }.by(0)
424
+
425
+ it 'should not delete entry from database' do
426
+ expect { perform_request }.not_to change { CrudTestModel.count }
417
427
  end
418
-
419
- it "should redirect to index" do
428
+
429
+ it 'should redirect to index' do
420
430
  perform_request
421
- should redirect_to(crud_test_models_path(:returning => true))
431
+ should redirect_to(crud_test_models_path(returning: true))
422
432
  end
423
-
424
- it "should have flash alert" do
433
+
434
+ it 'should have flash alert' do
425
435
  perform_request
426
436
  flash[:alert].should match(/illegal name/)
427
437
  end
428
438
  end
429
439
  end
430
-
440
+
431
441
  end
432
-
442
+
433
443
  end