dry_crud 6.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +2 -2
  3. data/README.rdoc +7 -6
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/sample.scss +45 -24
  6. data/app/controllers/crud_controller.rb +24 -26
  7. data/app/controllers/dry_crud/generic_model.rb +6 -12
  8. data/app/controllers/dry_crud/nestable.rb +1 -4
  9. data/app/controllers/dry_crud/rememberable.rb +1 -4
  10. data/app/controllers/dry_crud/render_callbacks.rb +4 -12
  11. data/app/controllers/dry_crud/searchable.rb +3 -10
  12. data/app/controllers/dry_crud/sortable.rb +3 -10
  13. data/app/controllers/list_controller.rb +1 -3
  14. data/app/helpers/actions_helper.rb +13 -15
  15. data/app/helpers/dry_crud/form/builder.rb +56 -62
  16. data/app/helpers/dry_crud/form/control.rb +12 -19
  17. data/app/helpers/dry_crud/table/actions.rb +15 -20
  18. data/app/helpers/dry_crud/table/builder.rb +12 -15
  19. data/app/helpers/dry_crud/table/col.rb +5 -8
  20. data/app/helpers/dry_crud/table/sorting.rb +3 -6
  21. data/app/helpers/form_helper.rb +11 -15
  22. data/app/helpers/format_helper.rb +18 -20
  23. data/app/helpers/i18n_helper.rb +13 -15
  24. data/app/helpers/table_helper.rb +16 -19
  25. data/app/helpers/utility_helper.rb +12 -14
  26. data/app/views/crud/new.html.erb +1 -1
  27. data/app/views/crud/new.html.haml +1 -1
  28. data/app/views/layouts/application.html.erb +8 -6
  29. data/app/views/layouts/application.html.haml +6 -5
  30. data/app/views/list/_search.html.erb +1 -3
  31. data/app/views/list/_search.html.haml +1 -2
  32. data/app/views/shared/_error_messages.html.erb +2 -2
  33. data/lib/dry_crud/engine.rb +1 -3
  34. data/lib/dry_crud.rb +1 -1
  35. data/lib/generators/dry_crud/dry_crud_generator.rb +18 -18
  36. data/lib/generators/dry_crud/dry_crud_generator_base.rb +8 -8
  37. data/lib/generators/dry_crud/file_generator.rb +6 -6
  38. data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +1 -1
  39. data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +122 -122
  40. data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +55 -60
  41. data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb +24 -26
  42. data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +16 -18
  43. data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +90 -94
  44. data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +33 -34
  45. data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +59 -61
  46. data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +20 -23
  47. data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +66 -68
  48. data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +11 -13
  49. data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +63 -65
  50. data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +25 -27
  51. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +74 -74
  52. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb +21 -21
  53. data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +21 -23
  54. data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +68 -70
  55. data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +26 -28
  56. data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +28 -30
  57. data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +17 -19
  58. data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +13 -15
  59. data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +15 -19
  60. data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +9 -14
  61. data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +16 -20
  62. data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +8 -10
  63. metadata +9 -10
@@ -1,31 +1,31 @@
1
- require 'rails/generators'
1
+ require "rails/generators"
2
2
 
3
3
  # Generates all dry crud files
4
4
  class DryCrudGeneratorBase < Rails::Generators::Base
5
5
  def self.template_root
6
- File.join(File.dirname(__FILE__), 'templates')
6
+ File.join(File.dirname(__FILE__), "templates")
7
7
  end
8
8
 
9
9
  def self.gem_root
10
- File.join(File.dirname(__FILE__), '..', '..', '..')
10
+ File.join(File.dirname(__FILE__), "..", "..", "..")
11
11
  end
12
12
 
13
13
  def self.source_paths
14
- [gem_root,
15
- template_root]
14
+ [ gem_root,
15
+ template_root ]
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
  def all_template_files
21
21
  { self.class.gem_root =>
22
- template_files(self.class.gem_root, 'app', 'config'),
22
+ template_files(self.class.gem_root, "app", "config"),
23
23
  self.class.template_root =>
24
24
  template_files(self.class.template_root) }
25
25
  end
26
26
 
27
27
  def template_files(root, *folders)
28
- pattern = File.join('**', '**')
28
+ pattern = File.join("**", "**")
29
29
  pattern = File.join("{#{folders.join(',')}}", pattern) if folders.present?
30
30
  Dir.chdir(root) do
31
31
  Dir.glob(pattern).sort.reject { |f| File.directory?(f) }
@@ -47,7 +47,7 @@ class DryCrudGeneratorBase < Rails::Generators::Base
47
47
  end
48
48
 
49
49
  def copy_file_source(file_source)
50
- if file_source.end_with?('.erb')
50
+ if file_source.end_with?(".erb")
51
51
  copy_file(file_source)
52
52
  else
53
53
  template(file_source)
@@ -1,16 +1,16 @@
1
- require 'generators/dry_crud/dry_crud_generator_base'
1
+ require "generators/dry_crud/dry_crud_generator_base"
2
2
 
3
3
  module DryCrud
4
4
  # Copies one file of dry_crud to the rails application.
5
5
  class FileGenerator < ::DryCrudGeneratorBase
6
6
  desc "Copy one file from dry_crud to the application.\n" \
7
- 'FILENAME is a part of the name of the file to copy. ' \
8
- 'Must match exactly one file.'
7
+ "FILENAME is a part of the name of the file to copy. " \
8
+ "Must match exactly one file."
9
9
 
10
10
  argument :filename,
11
11
  type: :string,
12
- desc: 'Name or part of the filename to copy. ' \
13
- 'Must match exactly one file.'
12
+ desc: "Name or part of the filename to copy. " \
13
+ "Must match exactly one file."
14
14
 
15
15
  # rubocop:disable Rails/Output
16
16
  def copy_matching_file
@@ -21,7 +21,7 @@ module DryCrud
21
21
  when 0
22
22
  puts "No file containing '#{filename}' found in dry_crud."
23
23
  else
24
- puts 'Please be more specific. ' \
24
+ puts "Please be more specific. " \
25
25
  "All the following files match '#{filename}':"
26
26
  files.each do |f|
27
27
  puts " * #{f}"
@@ -2,4 +2,4 @@
2
2
 
3
3
  # Fields with errors are directly styled in Crud::FormBuilder.
4
4
  # Rails should just output the plain html tag.
5
- ActionView::Base.field_error_proc = proc { |html_tag, instance| html_tag }
5
+ ActionView::Base.field_error_proc = proc { |html_tag, instance| html_tag }
@@ -1,4 +1,4 @@
1
- require 'rails_helper'
1
+ require "rails_helper"
2
2
 
3
3
  # Tests all actions of the CrudController based on a dummy model
4
4
  # (CrudTestModel). This is useful to test the general behavior
@@ -17,201 +17,201 @@ describe CrudTestModelsController do
17
17
 
18
18
  before { special_routing }
19
19
 
20
- include_examples 'crud controller', {}
20
+ include_examples "crud controller", {}
21
21
 
22
22
  let(:test_entry) { crud_test_models(:AAAAA) }
23
23
  let(:new_entry_attrs) do
24
- { name: 'foo',
24
+ { name: "foo",
25
25
  children: 42,
26
26
  companion_id: 3,
27
27
  rating: 8.5,
28
28
  income: 2.42,
29
- birthdate: '31-12-1999'.to_date,
29
+ birthdate: "31-12-1999".to_date,
30
30
  human: true,
31
31
  remarks: "some custom\n\tremarks" }
32
32
  end
33
33
  let(:edit_entry_attrs) do
34
- { name: 'foo',
34
+ { name: "foo",
35
35
  children: 42,
36
36
  rating: 8.5,
37
37
  income: 2.42,
38
- birthdate: '31-12-1999'.to_date,
38
+ birthdate: "31-12-1999".to_date,
39
39
  human: true,
40
40
  remarks: "some custom\n\tremarks" }
41
41
  end
42
42
 
43
- describe 'setup' do
44
- it 'model count is correct' do
43
+ describe "setup" do
44
+ it "model count is correct" do
45
45
  expect(CrudTestModel.count).to eq(6)
46
46
  end
47
47
 
48
- it 'has models_label' do
49
- expect(controller.models_label).to eq('Crud Test Models')
48
+ it "has models_label" do
49
+ expect(controller.models_label).to eq("Crud Test Models")
50
50
  end
51
51
 
52
- it 'has models_label singular' do
53
- expect(controller.models_label(false)).to eq('Crud Test Model')
52
+ it "has models_label singular" do
53
+ expect(controller.models_label(plural: false)).to eq("Crud Test Model")
54
54
  end
55
55
  end
56
56
 
57
57
  describe_action :get, :index do
58
- context '.html', format: :html do
59
- context 'plain', combine: 'ihp' do
60
- it 'contains all entries' do
58
+ context ".html", format: :html do
59
+ context "plain", combine: "ihp" do
60
+ it "contains all entries" do
61
61
  expect(entries.size).to eq(6)
62
62
  end
63
63
 
64
- it 'session has empty list_params' do
64
+ it "session has empty list_params" do
65
65
  expect(session[:list_params]).to eq({})
66
66
  end
67
67
 
68
- it 'provides entries helper method' do
68
+ it "provides entries helper method" do
69
69
  expect(entries).to be(controller.send(:entries))
70
70
  end
71
71
  end
72
72
 
73
- context 'search' do
73
+ context "search" do
74
74
  let(:params) { { q: search_value } }
75
75
 
76
- context 'regular', combine: 'ihse' do
77
- it 'entries only contain test_entry' do
78
- expect(entries).to eq([test_entry])
76
+ context "regular", combine: "ihse" do
77
+ it "entries only contain test_entry" do
78
+ expect(entries).to eq([ test_entry ])
79
79
  end
80
80
 
81
- it 'session has query list param' do
82
- expect(session[:list_params]['/crud_test_models.html'])
83
- .to eq('q' => 'AAAA')
81
+ it "session has query list param" do
82
+ expect(session[:list_params]["/crud_test_models.html"])
83
+ .to eq("q" => "AAAA")
84
84
  end
85
85
  end
86
86
 
87
- context 'with custom options', combine: 'ihsec' do
88
- let(:params) { { q: 'DDD', filter: true } }
87
+ context "with custom options", combine: "ihsec" do
88
+ let(:params) { { q: "DDD", filter: true } }
89
89
 
90
90
  it_is_expected_to_respond
91
91
 
92
- it 'entries have one item' do
93
- expect(entries).to eq([CrudTestModel.find_by(name: 'BBBBB')])
92
+ it "entries have one item" do
93
+ expect(entries).to eq([ CrudTestModel.find_by(name: "BBBBB") ])
94
94
  end
95
95
 
96
- it 'session has query list param' do
97
- expect(session[:list_params]['/crud_test_models.html'])
98
- .to eq('q' => 'DDD')
96
+ it "session has query list param" do
97
+ expect(session[:list_params]["/crud_test_models.html"])
98
+ .to eq("q" => "DDD")
99
99
  end
100
100
  end
101
101
  end
102
102
 
103
- context 'sort' do
104
- context 'for given column', combine: 'ihsog' do
105
- let(:params) { { sort: 'children', sort_dir: 'asc' } }
103
+ context "sort" do
104
+ context "for given column", combine: "ihsog" do
105
+ let(:params) { { sort: "children", sort_dir: "asc" } }
106
106
 
107
107
  it_is_expected_to_respond
108
108
 
109
- it 'entries are in correct order' do
109
+ it "entries are in correct order" do
110
110
  expect(entries).to eq(CrudTestModel.all.sort_by(&:children))
111
111
  end
112
112
 
113
- it 'session has sort list param' do
114
- expect(session[:list_params]['/crud_test_models.html']).to eq(
115
- 'sort' => 'children', 'sort_dir' => 'asc'
113
+ it "session has sort list param" do
114
+ expect(session[:list_params]["/crud_test_models.html"]).to eq(
115
+ "sort" => "children", "sort_dir" => "asc"
116
116
  )
117
117
  end
118
118
  end
119
119
 
120
- context 'for virtual column', combine: 'ihsov' do
121
- let(:params) { { sort: 'chatty', sort_dir: 'desc' } }
120
+ context "for virtual column", combine: "ihsov" do
121
+ let(:params) { { sort: "chatty", sort_dir: "desc" } }
122
122
 
123
123
  it_is_expected_to_respond
124
124
 
125
- it 'entries are in correct order' do
125
+ it "entries are in correct order" do
126
126
  names = entries.map(&:name)
127
- assert names.index('BBBBB') < names.index('AAAAA')
128
- assert names.index('BBBBB') < names.index('DDDDD')
129
- assert names.index('EEEEE') < names.index('AAAAA')
130
- assert names.index('EEEEE') < names.index('DDDDD')
131
- assert names.index('AAAAA') < names.index('CCCCC')
132
- assert names.index('DDDDD') < names.index('CCCCC')
127
+ assert names.index("BBBBB") < names.index("AAAAA")
128
+ assert names.index("BBBBB") < names.index("DDDDD")
129
+ assert names.index("EEEEE") < names.index("AAAAA")
130
+ assert names.index("EEEEE") < names.index("DDDDD")
131
+ assert names.index("AAAAA") < names.index("CCCCC")
132
+ assert names.index("DDDDD") < names.index("CCCCC")
133
133
  end
134
134
 
135
- it 'session has sort list param' do
136
- expect(session[:list_params]['/crud_test_models.html']).to eq(
137
- 'sort' => 'chatty', 'sort_dir' => 'desc'
135
+ it "session has sort list param" do
136
+ expect(session[:list_params]["/crud_test_models.html"]).to eq(
137
+ "sort" => "chatty", "sort_dir" => "desc"
138
138
  )
139
139
  end
140
140
  end
141
141
 
142
- context 'with search', combine: 'ihsose' do
142
+ context "with search", combine: "ihsose" do
143
143
  let(:params) do
144
- { q: 'DDD', sort: 'chatty', sort_dir: 'asc' }
144
+ { q: "DDD", sort: "chatty", sort_dir: "asc" }
145
145
  end
146
146
 
147
147
  it_is_expected_to_respond
148
148
 
149
- it 'entries are in correct order' do
149
+ it "entries are in correct order" do
150
150
  expect(entries.map(&:name)).to eq(%w[CCCCC DDDDD BBBBB])
151
151
  end
152
152
 
153
- it 'session has sort list param' do
154
- expect(session[:list_params]['/crud_test_models.html']).to eq(
155
- 'q' => 'DDD', 'sort' => 'chatty', 'sort_dir' => 'asc'
153
+ it "session has sort list param" do
154
+ expect(session[:list_params]["/crud_test_models.html"]).to eq(
155
+ "q" => "DDD", "sort" => "chatty", "sort_dir" => "asc"
156
156
  )
157
157
  end
158
158
  end
159
159
  end
160
160
 
161
- context 'with custom options', combine: 'ihsoco' do
161
+ context "with custom options", combine: "ihsoco" do
162
162
  let(:params) { { filter: true } }
163
163
 
164
164
  it_is_expected_to_respond
165
165
 
166
- context 'entries' do
166
+ context "entries" do
167
167
  subject { entries }
168
168
  it { expect(subject.size).to eq(2) }
169
169
  it { is_expected.to eq(entries.sort_by(&:children).reverse) }
170
170
  end
171
171
  end
172
172
 
173
- context 'returning', perform_request: false do
173
+ context "returning", perform_request: false do
174
174
  before do
175
175
  session[:list_params] = {}
176
- session[:list_params]['/crud_test_models'] =
177
- { 'q' => 'DDD', 'sort' => 'chatty', 'sort_dir' => 'desc' }
176
+ session[:list_params]["/crud_test_models"] =
177
+ { "q" => "DDD", "sort" => "chatty", "sort_dir" => "desc" }
178
178
  get :index, params: { returning: true }
179
179
  end
180
180
 
181
181
  it_is_expected_to_respond
182
182
 
183
- it 'entries are in correct order' do
183
+ it "entries are in correct order" do
184
184
  expect(entries.map(&:name)).to eq(%w[BBBBB DDDDD CCCCC])
185
185
  end
186
186
 
187
- it 'params are set' do
188
- expect(controller.params[:q]).to eq('DDD')
189
- expect(controller.params[:sort]).to eq('chatty')
190
- expect(controller.params[:sort_dir]).to eq('desc')
187
+ it "params are set" do
188
+ expect(controller.params[:q]).to eq("DDD")
189
+ expect(controller.params[:sort]).to eq("chatty")
190
+ expect(controller.params[:sort_dir]).to eq("desc")
191
191
  end
192
192
  end
193
193
  end
194
194
 
195
- context '.js', format: :js, combine: 'ijs' do
195
+ context ".js", format: :js, combine: "ijs" do
196
196
  it_is_expected_to_respond
197
- it { expect(response.body).to eq('index js') }
197
+ it { expect(response.body).to eq("index js") }
198
198
  end
199
199
  end
200
200
 
201
201
  describe_action :get, :new do
202
- context 'plain', combine: 'new' do
203
- it 'assigns companions' do
202
+ context "plain", combine: "new" do
203
+ it "assigns companions" do
204
204
  expect(ivar(:companions)).to be_present
205
205
  end
206
206
 
207
- it 'calls two render callbacks' do
207
+ it "calls two render callbacks" do
208
208
  expect(controller.called_callbacks).to eq(
209
209
  %i[before_render_new before_render_form]
210
210
  )
211
211
  end
212
212
  end
213
213
 
214
- context 'with before_render callback redirect',
214
+ context "with before_render callback redirect",
215
215
  perform_request: false do
216
216
  before do
217
217
  controller.should_redirect = true
@@ -220,7 +220,7 @@ describe CrudTestModelsController do
220
220
 
221
221
  it { is_expected.to redirect_to(crud_test_models_path) }
222
222
 
223
- it 'does not set companions' do
223
+ it "does not set companions" do
224
224
  expect(ivar(:companions)).to be_nil
225
225
  end
226
226
  end
@@ -229,44 +229,44 @@ describe CrudTestModelsController do
229
229
  describe_action :post, :create do
230
230
  let(:params) { { model_identifier => new_entry_attrs } }
231
231
 
232
- it 'calls the correct callbacks' do
232
+ it "calls the correct callbacks" do
233
233
  expect(controller.called_callbacks).to eq(
234
234
  %i[before_create before_save after_save after_create]
235
235
  )
236
236
  end
237
237
 
238
- context 'with before callback' do
238
+ context "with before callback" do
239
239
  let(:params) do
240
- { crud_test_model: { name: 'illegal', children: 2 } }
240
+ { crud_test_model: { name: "illegal", children: 2 } }
241
241
  end
242
- it 'does not create entry', perform_request: false do
242
+ it "does not create entry", perform_request: false do
243
243
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
244
244
  end
245
245
 
246
- context 'plain', combine: 'chcp' do
246
+ context "plain", combine: "chcp" do
247
247
  it_is_expected_to_respond
248
- it_is_expected_to_persist_entry(false)
248
+ it_is_expected_to_persist_entry(persist: false)
249
249
  it_is_expected_to_have_flash(:alert)
250
250
 
251
- it 'sets entry name' do
252
- expect(entry.name).to eq('illegal')
251
+ it "sets entry name" do
252
+ expect(entry.name).to eq("illegal")
253
253
  end
254
254
 
255
- it 'assigns companions' do
255
+ it "assigns companions" do
256
256
  expect(ivar(:companions)).to be_present
257
257
  end
258
258
 
259
- it 'calls the correct callbacks' do
259
+ it "calls the correct callbacks" do
260
260
  expect(controller.called_callbacks).to eq(
261
261
  %i[before_render_new before_render_form]
262
262
  )
263
263
  end
264
264
  end
265
265
 
266
- context 'redirect', perform_request: false do
266
+ context "redirect", perform_request: false do
267
267
  before { controller.should_redirect = true }
268
268
 
269
- it 'does not create entry' do
269
+ it "does not create entry" do
270
270
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
271
271
  end
272
272
 
@@ -275,32 +275,32 @@ describe CrudTestModelsController do
275
275
  is_expected.to redirect_to(crud_test_models_path)
276
276
  end
277
277
 
278
- it 'calls no callbacks' do
278
+ it "calls no callbacks" do
279
279
  perform_request
280
280
  expect(controller.called_callbacks).to be_nil
281
281
  end
282
282
  end
283
283
  end
284
284
 
285
- context 'with invalid params' do
285
+ context "with invalid params" do
286
286
  let(:params) { { crud_test_model: { children: 2 } } }
287
287
 
288
- context '.html' do
289
- it 'does not create entry', perform_request: false do
288
+ context ".html" do
289
+ it "does not create entry", perform_request: false do
290
290
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
291
291
  end
292
292
 
293
- context 'plain', combine: 'chip' do
293
+ context "plain", combine: "chip" do
294
294
  it_is_expected_to_respond
295
- it_is_expected_to_persist_entry(false)
295
+ it_is_expected_to_persist_entry(persist: false)
296
296
  it_is_expected_to_not_have_flash(:notice)
297
297
  it_is_expected_to_not_have_flash(:alert)
298
298
 
299
- it 'assigns companions' do
299
+ it "assigns companions" do
300
300
  expect(ivar(:companions)).to be_present
301
301
  end
302
302
 
303
- it 'calls the correct callbacks' do
303
+ it "calls the correct callbacks" do
304
304
  expect(controller.called_callbacks).to eq(
305
305
  %i[before_create before_save
306
306
  before_render_new before_render_form]
@@ -309,23 +309,23 @@ describe CrudTestModelsController do
309
309
  end
310
310
  end
311
311
 
312
- context '.json', format: :json do
313
- it 'does not create entry', perform_request: false do
312
+ context ".json", format: :json do
313
+ it "does not create entry", perform_request: false do
314
314
  expect { perform_request }.to change { CrudTestModel.count }.by(0)
315
315
  end
316
316
 
317
- context 'plain', combine: 'cjcb' do
317
+ context "plain", combine: "cjcb" do
318
318
  it_is_expected_to_respond(422)
319
- it_is_expected_to_persist_entry(false)
319
+ it_is_expected_to_persist_entry(persist: false)
320
320
  it_is_expected_to_not_have_flash(:notice)
321
321
  it_is_expected_to_not_have_flash(:alert)
322
322
  it_is_expected_to_render_json
323
323
 
324
- it 'does not assign companions' do
324
+ it "does not assign companions" do
325
325
  expect(ivar(:companions)).to be_nil
326
326
  end
327
327
 
328
- it 'calls the correct callbacks' do
328
+ it "calls the correct callbacks" do
329
329
  expect(controller.called_callbacks).to eq(
330
330
  %i[before_create before_save]
331
331
  )
@@ -336,7 +336,7 @@ describe CrudTestModelsController do
336
336
  end
337
337
 
338
338
  describe_action :get, :edit, id: true do
339
- it 'calls the correct callbacks' do
339
+ it "calls the correct callbacks" do
340
340
  expect(controller.called_callbacks).to eq(
341
341
  %i[before_render_edit before_render_form]
342
342
  )
@@ -346,52 +346,52 @@ describe CrudTestModelsController do
346
346
  describe_action :put, :update, id: true do
347
347
  let(:params) { { model_identifier => edit_entry_attrs } }
348
348
 
349
- it 'calls the correct callbacks' do
349
+ it "calls the correct callbacks" do
350
350
  expect(controller.called_callbacks).to eq(
351
351
  %i[before_update before_save after_save after_update]
352
352
  )
353
353
  end
354
354
 
355
- context 'with invalid params' do
355
+ context "with invalid params" do
356
356
  let(:params) do
357
357
  {
358
358
  crud_test_model: {
359
359
  rating: 20,
360
- other_ids: [OtherCrudTestModel.first.id]
360
+ other_ids: [ OtherCrudTestModel.first.id ]
361
361
  }
362
362
  }
363
363
  end
364
364
 
365
- context '.html', combine: 'uhivp' do
365
+ context ".html", combine: "uhivp" do
366
366
  it_is_expected_to_respond
367
367
  it_is_expected_to_not_have_flash(:notice)
368
368
 
369
- it 'changes entry' do
369
+ it "changes entry" do
370
370
  expect(entry).to be_changed
371
371
  end
372
372
 
373
- it 'sets entry rating' do
373
+ it "sets entry rating" do
374
374
  expect(entry.rating).to eq(20)
375
375
  end
376
376
 
377
- it 'calls the correct callbacks' do
377
+ it "calls the correct callbacks" do
378
378
  expect(controller.called_callbacks).to eq(
379
379
  %i[before_update before_save
380
380
  before_render_edit before_render_form]
381
381
  )
382
382
  end
383
383
 
384
- it 'does not update has_many ids' do
384
+ it "does not update has_many ids" do
385
385
  expect(test_entry.reload.other_ids).to eq([])
386
386
  end
387
387
  end
388
388
 
389
- context '.json', format: :json, combine: 'ujivp' do
389
+ context ".json", format: :json, combine: "ujivp" do
390
390
  it_is_expected_to_respond(422)
391
391
  it_is_expected_to_not_have_flash(:notice)
392
392
  it_is_expected_to_render_json
393
393
 
394
- it 'calls the correct callbacks' do
394
+ it "calls the correct callbacks" do
395
395
  expect(controller.called_callbacks).to eq(
396
396
  %i[before_update before_save]
397
397
  )
@@ -401,23 +401,23 @@ describe CrudTestModelsController do
401
401
  end
402
402
 
403
403
  describe_action :delete, :destroy, id: true do
404
- it 'calls the correct callbacks' do
404
+ it "calls the correct callbacks" do
405
405
  expect(controller.called_callbacks).to eq(
406
406
  %i[before_destroy after_destroy]
407
407
  )
408
408
  end
409
409
 
410
- context 'with failure' do
410
+ context "with failure" do
411
411
  let(:test_entry) { crud_test_models(:BBBBB) }
412
- context '.html' do
413
- it 'does not delete entry from database',
412
+ context ".html" do
413
+ it "does not delete entry from database",
414
414
  perform_request: false do
415
415
  expect { perform_request }.not_to(change { CrudTestModel.count })
416
416
  end
417
417
 
418
- it 'redirects to referer',
418
+ it "redirects to referer",
419
419
  perform_request: false do
420
- ref = @request.env['HTTP_REFERER'] = crud_test_model_url(test_entry)
420
+ ref = @request.env["HTTP_REFERER"] = crud_test_model_url(test_entry)
421
421
  perform_request
422
422
  is_expected.to redirect_to(ref)
423
423
  end
@@ -426,29 +426,29 @@ describe CrudTestModelsController do
426
426
  it_is_expected_to_not_have_flash(:notice)
427
427
  end
428
428
 
429
- context '.json', format: :json, combine: 'djf' do
429
+ context ".json", format: :json, combine: "djf" do
430
430
  it_is_expected_to_respond(422)
431
431
  it_is_expected_to_not_have_flash(:notice)
432
432
  it_is_expected_to_render_json
433
433
  end
434
434
 
435
- context 'callback', perform_request: false do
435
+ context "callback", perform_request: false do
436
436
  before do
437
437
  # rubocop:disable Rails/SkipsModelValidations
438
- test_entry.update_attribute(:name, 'illegal')
438
+ test_entry.update_attribute(:name, "illegal")
439
439
  # rubocop:enable Rails/SkipsModelValidations
440
440
  end
441
441
 
442
- it 'does not delete entry from database' do
442
+ it "does not delete entry from database" do
443
443
  expect { perform_request }.not_to(change { CrudTestModel.count })
444
444
  end
445
445
 
446
- it 'redirects to index' do
446
+ it "redirects to index" do
447
447
  perform_request
448
448
  is_expected.to redirect_to(crud_test_models_path(returning: true))
449
449
  end
450
450
 
451
- it 'has flash alert' do
451
+ it "has flash alert" do
452
452
  perform_request
453
453
  expect(flash[:alert]).to match(/illegal name/)
454
454
  end