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.
- checksums.yaml +15 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +126 -87
- data/VERSION +1 -1
- data/lib/generators/dry_crud/dry_crud_generator.rb +42 -22
- data/lib/generators/dry_crud/templates/INSTALL +5 -5
- data/lib/generators/dry_crud/templates/app/assets/stylesheets/crud.scss +0 -20
- data/lib/generators/dry_crud/templates/app/assets/stylesheets/sample.scss +24 -4
- data/lib/generators/dry_crud/templates/app/controllers/crud/generic_model.rb +89 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/nestable.rb +70 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/rememberable.rb +64 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/render_callbacks.rb +46 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/responder.rb +31 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb +55 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/sortable.rb +63 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +66 -69
- data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +23 -326
- data/lib/generators/dry_crud/templates/app/helpers/actions_helper.rb +64 -0
- data/lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb +331 -0
- data/lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb +280 -0
- data/lib/generators/dry_crud/templates/app/helpers/form_helper.rb +52 -0
- data/lib/generators/dry_crud/templates/app/helpers/format_helper.rb +164 -0
- data/lib/generators/dry_crud/templates/app/helpers/i18n_helper.rb +85 -0
- data/lib/generators/dry_crud/templates/app/helpers/table_helper.rb +83 -0
- data/lib/generators/dry_crud/templates/app/helpers/utility_helper.rb +84 -0
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_form.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_form.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/edit.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/edit.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/new.html.erb +2 -2
- data/lib/generators/dry_crud/templates/app/views/crud/new.html.haml +2 -2
- data/lib/generators/dry_crud/templates/app/views/crud/show.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/show.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +15 -7
- data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml +18 -8
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/list/index.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/list/index.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb +2 -4
- data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml +2 -3
- data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +5 -1
- data/lib/generators/dry_crud/templates/config/locales/crud.de.yml +64 -0
- data/lib/generators/dry_crud/templates/config/locales/{en_crud.yml → crud.en.yml} +2 -2
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +241 -231
- data/lib/generators/dry_crud/templates/spec/helpers/crud/form_builder_spec.rb +226 -0
- data/lib/generators/dry_crud/templates/spec/helpers/{standard_table_builder_spec.rb → crud/table_builder_spec.rb} +36 -34
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +238 -0
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +244 -0
- data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +132 -0
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +265 -0
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +74 -0
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +185 -100
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +58 -49
- data/lib/generators/dry_crud/templates/test/{functional → controllers}/crud_test_models_controller_test.rb +112 -91
- data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_form_builder_test.rb → helpers/crud/form_builder_test.rb} +79 -62
- data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_table_builder_test.rb → helpers/crud/table_builder_test.rb} +31 -28
- data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +85 -0
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +129 -0
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +163 -0
- data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +79 -0
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +217 -0
- data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +63 -0
- data/lib/generators/dry_crud/templates/test/{functional → support}/crud_controller_test_helper.rb +70 -59
- data/lib/generators/dry_crud/templates/test/{crud_test_model.rb → support/crud_test_model.rb} +107 -75
- data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +83 -0
- metadata +83 -146
- data/Rakefile +0 -211
- data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +0 -168
- data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +0 -27
- data/lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb +0 -261
- data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +0 -304
- data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +0 -178
- data/lib/generators/dry_crud/templates/spec/helpers/crud_helper_spec.rb +0 -146
- data/lib/generators/dry_crud/templates/spec/helpers/list_helper_spec.rb +0 -154
- data/lib/generators/dry_crud/templates/spec/helpers/standard_form_builder_spec.rb +0 -215
- data/lib/generators/dry_crud/templates/spec/helpers/standard_helper_spec.rb +0 -387
- data/lib/generators/dry_crud/templates/test/custom_assertions.rb +0 -78
- data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +0 -117
- data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +0 -111
- data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +0 -123
- data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +0 -281
- data/test/templates/Gemfile +0 -46
- data/test/templates/app/controllers/admin/cities_controller.rb +0 -7
- data/test/templates/app/controllers/admin/countries_controller.rb +0 -13
- data/test/templates/app/controllers/ajax_controller.rb +0 -9
- data/test/templates/app/controllers/people_controller.rb +0 -13
- data/test/templates/app/controllers/vips_controller.rb +0 -19
- data/test/templates/app/helpers/cities_helper.rb +0 -9
- data/test/templates/app/helpers/people_helper.rb +0 -8
- data/test/templates/app/models/city.rb +0 -28
- data/test/templates/app/models/country.rb +0 -16
- data/test/templates/app/models/person.rb +0 -12
- data/test/templates/app/views/admin/cities/_actions_index.html.erb +0 -2
- data/test/templates/app/views/admin/cities/_actions_index.html.haml +0 -2
- data/test/templates/app/views/admin/cities/_attrs.html.erb +0 -1
- data/test/templates/app/views/admin/cities/_attrs.html.haml +0 -1
- data/test/templates/app/views/admin/cities/_form.html.erb +0 -7
- data/test/templates/app/views/admin/cities/_form.html.haml +0 -5
- data/test/templates/app/views/admin/cities/_hello.html.erb +0 -1
- data/test/templates/app/views/admin/cities/_hello.html.haml +0 -1
- data/test/templates/app/views/admin/cities/_list.html.erb +0 -3
- data/test/templates/app/views/admin/cities/_list.html.haml +0 -3
- data/test/templates/app/views/admin/countries/_list.html.erb +0 -4
- data/test/templates/app/views/admin/countries/_list.html.haml +0 -3
- data/test/templates/app/views/ajax/_actions_index.html.erb +0 -8
- data/test/templates/app/views/ajax/_actions_index.html.haml +0 -8
- data/test/templates/app/views/ajax/_actions_show.html.erb +0 -4
- data/test/templates/app/views/ajax/_actions_show.html.haml +0 -4
- data/test/templates/app/views/ajax/_form.html.erb +0 -2
- data/test/templates/app/views/ajax/_form.html.haml +0 -2
- data/test/templates/app/views/ajax/_hello.html.erb +0 -1
- data/test/templates/app/views/ajax/_hello.html.haml +0 -1
- data/test/templates/app/views/ajax/ajax.js.erb +0 -1
- data/test/templates/app/views/ajax/ajax.js.haml +0 -1
- data/test/templates/app/views/ajax/edit.js.erb +0 -1
- data/test/templates/app/views/ajax/edit.js.haml +0 -1
- data/test/templates/app/views/ajax/show.js.erb +0 -1
- data/test/templates/app/views/ajax/show.js.haml +0 -1
- data/test/templates/app/views/ajax/update.js.erb +0 -5
- data/test/templates/app/views/ajax/update.js.haml +0 -5
- data/test/templates/app/views/layouts/_nav.html.erb +0 -6
- data/test/templates/app/views/layouts/_nav.html.haml +0 -5
- data/test/templates/app/views/layouts/bootstrap.html.erb +0 -68
- data/test/templates/app/views/layouts/bootstrap.html.haml +0 -49
- data/test/templates/app/views/people/_attrs.html.erb +0 -5
- data/test/templates/app/views/people/_attrs.html.haml +0 -4
- data/test/templates/app/views/people/_list.html.erb +0 -1
- data/test/templates/app/views/people/_list.html.haml +0 -1
- data/test/templates/config/database.yml +0 -21
- data/test/templates/config/locales/en_cities.yml +0 -56
- data/test/templates/config/routes.rb +0 -32
- data/test/templates/db/migrate/20100511174904_create_people_and_cities.rb +0 -26
- data/test/templates/db/seeds.rb +0 -74
- data/test/templates/spec/controllers/admin/cities_controller_spec.rb +0 -74
- data/test/templates/spec/controllers/admin/countries_controller_spec.rb +0 -56
- data/test/templates/spec/controllers/people_controller_spec.rb +0 -80
- data/test/templates/spec/routing/cities_routing_spec.rb +0 -11
- data/test/templates/spec/routing/countries_routing_spec.rb +0 -11
- data/test/templates/test/fixtures/cities.yml +0 -11
- data/test/templates/test/fixtures/countries.yml +0 -11
- data/test/templates/test/fixtures/people.yml +0 -14
- data/test/templates/test/functional/admin/cities_controller_test.rb +0 -59
- data/test/templates/test/functional/admin/countries_controller_test.rb +0 -42
- data/test/templates/test/functional/people_controller_test.rb +0 -68
@@ -1,3 +1,3 @@
|
|
1
|
-
<%=
|
2
|
-
<%=
|
3
|
-
<%=
|
1
|
+
<%= index_action_link %>
|
2
|
+
<%= show_action_link %>
|
3
|
+
<%= destroy_action_link %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
=
|
2
|
-
=
|
3
|
-
=
|
1
|
+
= index_action_link
|
2
|
+
= show_action_link
|
3
|
+
= destroy_action_link
|
@@ -1 +1 @@
|
|
1
|
-
<%=
|
1
|
+
<%= add_action_link %>
|
@@ -1 +1 @@
|
|
1
|
-
=
|
1
|
+
= add_action_link
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%=
|
2
|
-
<%=
|
3
|
-
<%=
|
1
|
+
<%= index_action_link %>
|
2
|
+
<%= edit_action_link %>
|
3
|
+
<%= destroy_action_link %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
=
|
2
|
-
=
|
3
|
-
=
|
1
|
+
= index_action_link
|
2
|
+
= edit_action_link
|
3
|
+
= destroy_action_link
|
@@ -1 +1 @@
|
|
1
|
-
<%= render_attrs entry, *
|
1
|
+
<%= render_attrs entry, *default_crud_attrs %>
|
@@ -1 +1 @@
|
|
1
|
-
= render_attrs entry, *
|
1
|
+
= render_attrs entry, *default_crud_attrs
|
@@ -1 +1 @@
|
|
1
|
-
<%=
|
1
|
+
<%= crud_form %>
|
@@ -1 +1 @@
|
|
1
|
-
=
|
1
|
+
= crud_form
|
@@ -1,2 +1,2 @@
|
|
1
1
|
- if flash[level].present?
|
2
|
-
%div{:
|
2
|
+
%div{class: "alert alert-#{flash_class(level)}"}= flash[level]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8" />
|
6
|
-
<title><%= strip_tags(@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', :
|
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',
|
19
|
-
|
20
|
-
|
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 :
|
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
|
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',
|
18
|
-
|
19
|
-
|
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 :
|
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
|
© 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, {:
|
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], :
|
5
|
-
<%= submit_tag ti(:"button.search"), :
|
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, {:
|
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], :
|
5
|
-
= submit_tag ti(:"button.search"), :
|
4
|
+
= search_field_tag :q, params[:q], class: 'search-query'
|
5
|
+
= submit_tag ti(:"button.search"), class: 'btn'
|
@@ -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", :
|
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,4 +1,2 @@
|
|
1
|
-
<
|
2
|
-
|
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
|
-
.
|
2
|
-
|
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
|
-
|
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
|
-
{:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
{:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
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
|
49
|
+
|
50
|
+
it 'has models_label' do
|
52
51
|
controller.models_label.should == 'Crud Test Models'
|
53
52
|
end
|
54
|
-
|
55
|
-
it
|
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', :
|
77
|
-
context 'plain', :
|
78
|
-
it
|
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
|
65
|
+
|
66
|
+
it 'session should have empty list_params' do
|
83
67
|
session[:list_params].should == Hash.new
|
84
68
|
end
|
85
|
-
|
86
|
-
it
|
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
|
93
|
-
let(:params) { {:
|
94
|
-
|
95
|
-
context
|
96
|
-
it
|
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
|
101
|
-
session[:list_params]['/crud_test_models.html'].should ==
|
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
|
106
|
-
let(:params) { {:
|
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
|
94
|
+
|
95
|
+
it 'entries should have one item' do
|
111
96
|
entries.should == [CrudTestModel.find_by_name('BBBBB')]
|
112
97
|
end
|
113
|
-
|
114
|
-
it
|
115
|
-
session[:list_params]['/crud_test_models.html'].should ==
|
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
|
121
|
-
context
|
122
|
-
let(:params) { {:
|
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
|
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
|
131
|
-
session[:list_params]['/crud_test_models.html'].should ==
|
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
|
136
|
-
let(:params) { {:
|
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
|
141
|
-
names = entries.
|
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
|
151
|
-
session[:list_params]['/crud_test_models.html'].should ==
|
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
|
156
|
-
let(:params)
|
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
|
161
|
-
entries.
|
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
|
165
|
-
session[:list_params]['/crud_test_models.html'].should ==
|
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
|
171
|
-
let(:params) { {:
|
172
|
-
|
160
|
+
|
161
|
+
context 'with custom options', combine: 'ihsoco' do
|
162
|
+
let(:params) { { filter: true } }
|
163
|
+
|
173
164
|
it_should_respond
|
174
|
-
|
175
|
-
context
|
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
|
172
|
+
|
173
|
+
context 'returning', perform_request: false do
|
183
174
|
before do
|
184
175
|
session[:list_params] = {}
|
185
|
-
session[:list_params]['/crud_test_models'] =
|
186
|
-
|
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
|
192
|
-
entries.
|
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
|
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
|
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
|
212
|
-
it
|
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
|
217
|
-
controller.called_callbacks.should ==
|
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
|
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
|
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
|
239
|
-
controller.called_callbacks.should ==
|
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
|
243
|
-
let(:params)
|
244
|
-
|
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
|
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
|
250
|
+
|
251
|
+
it 'should set entry name' do
|
255
252
|
entry.name.should == 'illegal'
|
256
253
|
end
|
257
|
-
|
258
|
-
it
|
254
|
+
|
255
|
+
it 'should assign companions' do
|
259
256
|
assigns(:companions).should be_present
|
260
257
|
end
|
261
|
-
|
262
|
-
it
|
263
|
-
controller.called_callbacks.should ==
|
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
|
264
|
+
|
265
|
+
context 'redirect', perform_request: false do
|
268
266
|
before { controller.should_redirect = true }
|
269
|
-
|
270
|
-
it
|
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
|
275
|
-
|
276
|
-
|
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
|
284
|
-
let(:params) { {:
|
285
|
-
|
286
|
-
context
|
287
|
-
it
|
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
|
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
|
298
|
+
|
299
|
+
it 'should assign companions' do
|
299
300
|
assigns(:companions).should be_present
|
300
301
|
end
|
301
|
-
|
302
|
-
it
|
303
|
-
controller.called_callbacks.should ==
|
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
|
309
|
-
it
|
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
|
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
|
321
|
+
|
322
|
+
it 'should not assign companions' do
|
320
323
|
assigns(:companions).should be_nil
|
321
324
|
end
|
322
|
-
|
323
|
-
it
|
324
|
-
controller.called_callbacks.should ==
|
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, :
|
335
|
-
it
|
336
|
-
controller.called_callbacks.should ==
|
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, :
|
341
|
-
let(:params) { {model_identifier => edit_entry_attrs} }
|
342
|
-
|
343
|
-
it
|
344
|
-
controller.called_callbacks.should ==
|
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
|
348
|
-
let(:params) { {:
|
349
|
-
|
350
|
-
context
|
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
|
360
|
+
|
361
|
+
it 'should change entry' do
|
356
362
|
entry.should be_changed
|
357
363
|
end
|
358
|
-
|
359
|
-
it
|
364
|
+
|
365
|
+
it 'should set entry rating' do
|
360
366
|
entry.rating.should == 20
|
361
367
|
end
|
362
|
-
|
363
|
-
it
|
364
|
-
controller.called_callbacks.should ==
|
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
|
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
|
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, :
|
383
|
-
it
|
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
|
394
|
+
|
395
|
+
context 'with failure' do
|
388
396
|
let(:test_entry) { crud_test_models(:BBBBB) }
|
389
|
-
context
|
390
|
-
it
|
391
|
-
|
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
|
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
|
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
|
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
|
416
|
-
expect { perform_request }.
|
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
|
428
|
+
|
429
|
+
it 'should redirect to index' do
|
420
430
|
perform_request
|
421
|
-
should redirect_to(crud_test_models_path(:
|
431
|
+
should redirect_to(crud_test_models_path(returning: true))
|
422
432
|
end
|
423
|
-
|
424
|
-
it
|
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
|