rails_best_practices 1.19.1 → 1.19.2

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 +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Guardfile +1 -1
  4. data/README.md +1 -0
  5. data/Rakefile +2 -2
  6. data/bin/rails_best_practices +2 -1
  7. data/lib/rails_best_practices.rb +2 -1
  8. data/lib/rails_best_practices/analyzer.rb +13 -12
  9. data/lib/rails_best_practices/colorize.rb +2 -0
  10. data/lib/rails_best_practices/command.rb +6 -5
  11. data/lib/rails_best_practices/core.rb +2 -1
  12. data/lib/rails_best_practices/core/check.rb +19 -17
  13. data/lib/rails_best_practices/core/checks_loader.rb +3 -2
  14. data/lib/rails_best_practices/core/configs.rb +2 -1
  15. data/lib/rails_best_practices/core/controllers.rb +4 -1
  16. data/lib/rails_best_practices/core/error.rb +3 -2
  17. data/lib/rails_best_practices/core/gems.rb +4 -3
  18. data/lib/rails_best_practices/core/helpers.rb +4 -1
  19. data/lib/rails_best_practices/core/klasses.rb +3 -2
  20. data/lib/rails_best_practices/core/mailers.rb +2 -1
  21. data/lib/rails_best_practices/core/methods.rb +9 -10
  22. data/lib/rails_best_practices/core/model_associations.rb +6 -5
  23. data/lib/rails_best_practices/core/model_attributes.rb +2 -1
  24. data/lib/rails_best_practices/core/models.rb +2 -1
  25. data/lib/rails_best_practices/core/modules.rb +2 -1
  26. data/lib/rails_best_practices/core/routes.rb +2 -1
  27. data/lib/rails_best_practices/core/runner.rb +7 -6
  28. data/lib/rails_best_practices/core_ext/erubis.rb +4 -5
  29. data/lib/rails_best_practices/lexicals.rb +2 -1
  30. data/lib/rails_best_practices/lexicals/long_line_check.rb +2 -1
  31. data/lib/rails_best_practices/lexicals/remove_tab_check.rb +2 -1
  32. data/lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb +2 -1
  33. data/lib/rails_best_practices/prepares.rb +2 -1
  34. data/lib/rails_best_practices/prepares/config_prepare.rb +3 -2
  35. data/lib/rails_best_practices/prepares/controller_prepare.rb +9 -8
  36. data/lib/rails_best_practices/prepares/gemfile_prepare.rb +2 -1
  37. data/lib/rails_best_practices/prepares/helper_prepare.rb +4 -3
  38. data/lib/rails_best_practices/prepares/initializer_prepare.rb +2 -1
  39. data/lib/rails_best_practices/prepares/mailer_prepare.rb +3 -2
  40. data/lib/rails_best_practices/prepares/model_prepare.rb +12 -12
  41. data/lib/rails_best_practices/prepares/route_prepare.rb +8 -7
  42. data/lib/rails_best_practices/prepares/schema_prepare.rb +3 -2
  43. data/lib/rails_best_practices/reviews.rb +2 -1
  44. data/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb +7 -4
  45. data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +8 -7
  46. data/lib/rails_best_practices/reviews/check_destroy_return_value_review.rb +4 -3
  47. data/lib/rails_best_practices/reviews/check_save_return_value_review.rb +5 -4
  48. data/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb +2 -1
  49. data/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb +2 -1
  50. data/lib/rails_best_practices/reviews/hash_syntax_review.rb +2 -1
  51. data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +3 -2
  52. data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +3 -2
  53. data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +3 -2
  54. data/lib/rails_best_practices/reviews/move_code_into_controller_review.rb +3 -2
  55. data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +2 -1
  56. data/lib/rails_best_practices/reviews/move_code_into_model_review.rb +3 -2
  57. data/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb +3 -2
  58. data/lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb +3 -2
  59. data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +5 -4
  60. data/lib/rails_best_practices/reviews/not_rescue_exception_review.rb +2 -1
  61. data/lib/rails_best_practices/reviews/not_use_default_route_review.rb +2 -1
  62. data/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb +2 -1
  63. data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +3 -2
  64. data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +4 -3
  65. data/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb +2 -1
  66. data/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb +11 -10
  67. data/lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb +4 -3
  68. data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +6 -5
  69. data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +2 -2
  70. data/lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb +2 -1
  71. data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +8 -8
  72. data/lib/rails_best_practices/reviews/review.rb +4 -3
  73. data/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb +2 -1
  74. data/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb +3 -2
  75. data/lib/rails_best_practices/reviews/use_before_filter_review.rb +5 -4
  76. data/lib/rails_best_practices/reviews/use_model_association_review.rb +2 -2
  77. data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +5 -5
  78. data/lib/rails_best_practices/reviews/use_observer_review.rb +2 -1
  79. data/lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb +2 -1
  80. data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +4 -3
  81. data/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb +4 -3
  82. data/lib/rails_best_practices/reviews/use_scope_access_review.rb +2 -1
  83. data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +2 -1
  84. data/lib/rails_best_practices/version.rb +3 -2
  85. data/rails_best_practices.gemspec +11 -10
  86. data/spec/fixtures/lib/rails_best_practices/plugins/reviews/not_use_rails_root_review.rb +3 -2
  87. data/spec/rails_best_practices/analyzer_spec.rb +6 -8
  88. data/spec/rails_best_practices/core/check_spec.rb +2 -0
  89. data/spec/rails_best_practices/core/checks_loader_spec.rb +2 -0
  90. data/spec/rails_best_practices/core/configs_spec.rb +2 -0
  91. data/spec/rails_best_practices/core/controllers_spec.rb +2 -0
  92. data/spec/rails_best_practices/core/error_spec.rb +2 -0
  93. data/spec/rails_best_practices/core/except_methods_spec.rb +2 -0
  94. data/spec/rails_best_practices/core/gems_spec.rb +2 -0
  95. data/spec/rails_best_practices/core/helpers_spec.rb +2 -0
  96. data/spec/rails_best_practices/core/klasses_spec.rb +2 -0
  97. data/spec/rails_best_practices/core/mailers_spec.rb +2 -0
  98. data/spec/rails_best_practices/core/methods_spec.rb +6 -4
  99. data/spec/rails_best_practices/core/model_associations_spec.rb +4 -2
  100. data/spec/rails_best_practices/core/model_attributes_spec.rb +2 -0
  101. data/spec/rails_best_practices/core/models_spec.rb +2 -0
  102. data/spec/rails_best_practices/core/modules_spec.rb +2 -0
  103. data/spec/rails_best_practices/core/routes_spec.rb +4 -2
  104. data/spec/rails_best_practices/core/runner_spec.rb +2 -0
  105. data/spec/rails_best_practices/core_ext/erubis_spec.rb +3 -1
  106. data/spec/rails_best_practices/lexicals/long_line_check_spec.rb +8 -7
  107. data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +8 -6
  108. data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +9 -7
  109. data/spec/rails_best_practices/prepares/config_prepare_spec.rb +3 -1
  110. data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +23 -21
  111. data/spec/rails_best_practices/prepares/gemfile_prepare_spec.rb +3 -1
  112. data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +7 -5
  113. data/spec/rails_best_practices/prepares/initializer_prepare_spec.rb +4 -2
  114. data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +3 -1
  115. data/spec/rails_best_practices/prepares/model_prepare_spec.rb +56 -54
  116. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +39 -37
  117. data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +3 -1
  118. data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +2 -0
  119. data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +7 -5
  120. data/spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb +12 -10
  121. data/spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb +20 -18
  122. data/spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb +2 -0
  123. data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +2 -0
  124. data/spec/rails_best_practices/reviews/hash_syntax_review_spec.rb +9 -7
  125. data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +2 -0
  126. data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +2 -0
  127. data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +2 -0
  128. data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +2 -0
  129. data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +2 -0
  130. data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +11 -9
  131. data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +2 -0
  132. data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +2 -0
  133. data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +2 -0
  134. data/spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb +9 -7
  135. data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +2 -0
  136. data/spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb +7 -5
  137. data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +2 -0
  138. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +21 -19
  139. data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +6 -4
  140. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +33 -31
  141. data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +13 -11
  142. data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +65 -63
  143. data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +2 -0
  144. data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +2 -0
  145. data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +24 -22
  146. data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +9 -7
  147. data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +13 -11
  148. data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +3 -1
  149. data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +2 -0
  150. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +2 -0
  151. data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +7 -5
  152. data/spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb +2 -0
  153. data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +3 -1
  154. data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +9 -7
  155. data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +2 -0
  156. data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +2 -0
  157. data/spec/spec_helper.rb +2 -0
  158. metadata +26 -26
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module RailsBestPractices
@@ -7,7 +9,7 @@ module RailsBestPractices
7
9
 
8
10
  context 'resources' do
9
11
  it 'should add resources route' do
10
- content =<<-EOF
12
+ content = <<-EOF
11
13
  RailsBestPracticesCom::Application.routes.draw do
12
14
  resources :posts
13
15
  end
@@ -19,7 +21,7 @@ module RailsBestPractices
19
21
  end
20
22
 
21
23
  it 'should add multiple resources route' do
22
- content =<<-EOF
24
+ content = <<-EOF
23
25
  RailsBestPracticesCom::Application.routes.draw do
24
26
  resources :posts, :users
25
27
  end
@@ -30,7 +32,7 @@ module RailsBestPractices
30
32
  end
31
33
 
32
34
  it 'should add resources route with explict controller' do
33
- content =<<-EOF
35
+ content = <<-EOF
34
36
  RailsBestPracticesCom::Application.routes.draw do
35
37
  resources :posts, controller: :blog_posts
36
38
  end
@@ -42,7 +44,7 @@ module RailsBestPractices
42
44
  end
43
45
 
44
46
  it 'should add resources route with only option' do
45
- content =<<-EOF
47
+ content = <<-EOF
46
48
  RailsBestPracticesCom::Application.routes.draw do
47
49
  resources :posts, only: [:index, :show, :new, :create]
48
50
  end
@@ -54,7 +56,7 @@ module RailsBestPractices
54
56
  end
55
57
 
56
58
  it 'should add resources route with except option' do
57
- content =<<-EOF
59
+ content = <<-EOF
58
60
  RailsBestPracticesCom::Application.routes.draw do
59
61
  resources :posts, except: [:edit, :update, :destroy]
60
62
  end
@@ -66,7 +68,7 @@ module RailsBestPractices
66
68
  end
67
69
 
68
70
  it 'should not add resources routes with only: :none' do
69
- content =<<-EOF
71
+ content = <<-EOF
70
72
  RailsBestPracticesCom::Application.routes.draw do
71
73
  resources :posts, only: :none
72
74
  end
@@ -77,7 +79,7 @@ module RailsBestPractices
77
79
  end
78
80
 
79
81
  it 'should not add resources routes with except: :all' do
80
- content =<<-EOF
82
+ content = <<-EOF
81
83
  RailsBestPracticesCom::Application.routes.draw do
82
84
  resources :posts, except: :all
83
85
  end
@@ -88,7 +90,7 @@ module RailsBestPractices
88
90
  end
89
91
 
90
92
  it 'should add resources routes with members' do
91
- content =<<-EOF
93
+ content = <<-EOF
92
94
  RailsBestPracticesCom::Application.routes.draw do
93
95
  namespace :admin do
94
96
  resources :posts, :only => [:edit, :update] do
@@ -110,7 +112,7 @@ module RailsBestPractices
110
112
  end
111
113
 
112
114
  it 'should add resources routes with members inline' do
113
- content =<<-EOF
115
+ content = <<-EOF
114
116
  RailsBestPracticesCom::Application.routes.draw do
115
117
  namespace :admin do
116
118
  resources :posts, :only => [:edit, :update] do
@@ -130,7 +132,7 @@ module RailsBestPractices
130
132
  end
131
133
 
132
134
  it 'should add connect route' do
133
- content =<<-EOF
135
+ content = <<-EOF
134
136
  ActionController::Routing::Routes.draw do |map|
135
137
  map.connect 'vote', controller: "votes", action: "create", method: :post
136
138
  end
@@ -141,7 +143,7 @@ module RailsBestPractices
141
143
  end
142
144
 
143
145
  it 'should add named route' do
144
- content =<<-EOF
146
+ content = <<-EOF
145
147
  ActionController::Routing::Routes.draw do |map|
146
148
  map.login '/player/login', controller: 'sessions', action: 'new', conditions: { method: :get }
147
149
  end
@@ -154,7 +156,7 @@ module RailsBestPractices
154
156
 
155
157
  context 'resource' do
156
158
  it 'should add resource route' do
157
- content =<<-EOF
159
+ content = <<-EOF
158
160
  RailsBestPracticesCom::Application.routes.draw do
159
161
  resource :posts
160
162
  end
@@ -166,7 +168,7 @@ module RailsBestPractices
166
168
  end
167
169
 
168
170
  it 'should add multiple resource route' do
169
- content =<<-EOF
171
+ content = <<-EOF
170
172
  RailsBestPracticesCom::Application.routes.draw do
171
173
  resource :posts, :users
172
174
  end
@@ -177,7 +179,7 @@ module RailsBestPractices
177
179
  end
178
180
 
179
181
  it 'should add resource route with only option' do
180
- content =<<-EOF
182
+ content = <<-EOF
181
183
  RailsBestPracticesCom::Application.routes.draw do
182
184
  resource :posts, only: [:show, :new, :create]
183
185
  end
@@ -189,7 +191,7 @@ module RailsBestPractices
189
191
  end
190
192
 
191
193
  it 'should add resource route with except option' do
192
- content =<<-EOF
194
+ content = <<-EOF
193
195
  RailsBestPracticesCom::Application.routes.draw do
194
196
  resource :posts, except: [:edit, :update, :destroy]
195
197
  end
@@ -201,7 +203,7 @@ module RailsBestPractices
201
203
  end
202
204
 
203
205
  it 'should not add resource routes with only: :none' do
204
- content =<<-EOF
206
+ content = <<-EOF
205
207
  RailsBestPracticesCom::Application.routes.draw do
206
208
  resource :posts, only: :none
207
209
  end
@@ -212,7 +214,7 @@ module RailsBestPractices
212
214
  end
213
215
 
214
216
  it 'should not add resource routes with except: :all' do
215
- content =<<-EOF
217
+ content = <<-EOF
216
218
  RailsBestPracticesCom::Application.routes.draw do
217
219
  resource :posts, except: :all
218
220
  end
@@ -223,7 +225,7 @@ module RailsBestPractices
223
225
  end
224
226
 
225
227
  it 'should add resource routes with get/post/put/patch/delete routes' do
226
- content =<<-EOF
228
+ content = <<-EOF
227
229
  RailsBestPracticesCom::Application.routes.draw do
228
230
  resources :posts, only: [:show] do
229
231
  get :list, on: :collection
@@ -246,7 +248,7 @@ module RailsBestPractices
246
248
  end
247
249
 
248
250
  it 'should add custom resources routes with {}' do
249
- content =<<-EOF
251
+ content = <<-EOF
250
252
  RailsBestPracticesCom::Application.routes.draw do
251
253
  resources :posts, only: [:show] { get :inactive, on: :collection }
252
254
  end
@@ -258,7 +260,7 @@ module RailsBestPractices
258
260
  end
259
261
 
260
262
  it 'should add resources routes with get %w() routes' do
261
- content =<<-EOF
263
+ content = <<-EOF
262
264
  RailsBestPracticesCom::Application.routes.draw do
263
265
  resources :posts, only: [:show] do
264
266
  collection do
@@ -274,7 +276,7 @@ module RailsBestPractices
274
276
  end
275
277
 
276
278
  it 'should add route with nested routes' do
277
- content =<<-EOF
279
+ content = <<-EOF
278
280
  RailsBestPracticesCom::Application.routes.draw do
279
281
  resources :posts
280
282
  resources :comments
@@ -287,7 +289,7 @@ module RailsBestPractices
287
289
  end
288
290
 
289
291
  it 'should add route with namespace' do
290
- content =<<-EOF
292
+ content = <<-EOF
291
293
  RailsBestPracticesCom::Application.routes.draw do
292
294
  namespace :admin do
293
295
  namespace :test do
@@ -302,7 +304,7 @@ module RailsBestPractices
302
304
  end
303
305
 
304
306
  it 'should add route with namespace, but without resources' do
305
- content =<<-EOF
307
+ content = <<-EOF
306
308
  RailsBestPracticesCom::Appllication.routes.draw do
307
309
  namespace :something do
308
310
  get *%w(route_one route_two)
@@ -316,7 +318,7 @@ module RailsBestPractices
316
318
  end
317
319
 
318
320
  it 'should add route with scope' do
319
- content =<<-EOF
321
+ content = <<-EOF
320
322
  RailsBestPracticesCom::Application.routes.draw do
321
323
  scope module: "admin" do
322
324
  resources :posts, only: [:index]
@@ -346,7 +348,7 @@ module RailsBestPractices
346
348
  end
347
349
 
348
350
  it 'should add route for direct get/post' do
349
- content =<<-EOF
351
+ content = <<-EOF
350
352
  RailsBestPracticesCom::Application.routes.draw do
351
353
  get 'posts/show'
352
354
  post '/posts' => 'posts#create'
@@ -362,7 +364,7 @@ module RailsBestPractices
362
364
  end
363
365
 
364
366
  it 'should add routes for another get/post' do
365
- content =<<-EOF
367
+ content = <<-EOF
366
368
  RailsBestPracticesCom::Application.routes.draw
367
369
  get "/login", to: 'sessions#new', as: :login
368
370
  end
@@ -374,7 +376,7 @@ module RailsBestPractices
374
376
  end
375
377
 
376
378
  it 'should add match route' do
377
- content =<<-EOF
379
+ content = <<-EOF
378
380
  RailsBestPracticesCom::Application.routes.draw do
379
381
  match '/auth/:provider/callback' => 'authentications#create'
380
382
  end
@@ -385,7 +387,7 @@ module RailsBestPractices
385
387
  end
386
388
 
387
389
  it 'should add match route with all actions' do
388
- content =<<-EOF
390
+ content = <<-EOF
389
391
  RailsBestPracticesCom::Application.routes.draw do
390
392
  match 'internal/:action/*whatever', controller: "internal"
391
393
  end
@@ -396,7 +398,7 @@ module RailsBestPractices
396
398
  end
397
399
 
398
400
  it 'should add root route' do
399
- content =<<-EOF
401
+ content = <<-EOF
400
402
  RailsBestPracticesCom::Application.routes.draw do
401
403
  root to: 'home#index'
402
404
  end
@@ -407,7 +409,7 @@ module RailsBestPractices
407
409
  end
408
410
 
409
411
  it 'should add root shortcut route' do
410
- content =<<-EOF
412
+ content = <<-EOF
411
413
  RailsBestPracticesCom::Application.routes.draw do
412
414
  root 'home#index'
413
415
  end
@@ -418,7 +420,7 @@ module RailsBestPractices
418
420
  end
419
421
 
420
422
  it 'should do nothing for default route' do
421
- content =<<-EOF
423
+ content = <<-EOF
422
424
  RailsBestPracticesCom::Application.routes.draw do
423
425
  match ':controller(/:action(/:id(.:format)))'
424
426
  end
@@ -429,7 +431,7 @@ module RailsBestPractices
429
431
  end
430
432
 
431
433
  it 'should do nothing for redirect' do
432
- content =<<-EOF
434
+ content = <<-EOF
433
435
  RailsBestPracticesCom::Application.routes.draw do
434
436
  match "/stories/:name" => redirect("/posts/%{name}")
435
437
  match "/stories" => redirect {|p, req| "/posts/\#{req.subdomain}" }
@@ -441,7 +443,7 @@ module RailsBestPractices
441
443
  end
442
444
 
443
445
  it 'should parse customize route in nested resources' do
444
- content =<<-EOF
446
+ content = <<-EOF
445
447
  RailsBestPracticesCom::Application.routes.draw do
446
448
  resources :posts do
447
449
  resources :comments
@@ -455,7 +457,7 @@ module RailsBestPractices
455
457
  end
456
458
 
457
459
  it 'should parse custom route for resource with explicit to and different action name' do
458
- content =<<-EOF
460
+ content = <<-EOF
459
461
  RailsBestPracticesCom::Application.routes.draw do
460
462
  resources :posts do
461
463
  get :halt, to: 'posts#stop'
@@ -468,7 +470,7 @@ module RailsBestPractices
468
470
  end
469
471
 
470
472
  it 'should parse custom route for resource with symbol action name' do
471
- content =<<-EOF
473
+ content = <<-EOF
472
474
  RailsBestPracticesCom::Application.routes.draw do
473
475
  resources :posts do
474
476
  get :halt, to: :stop
@@ -481,7 +483,7 @@ module RailsBestPractices
481
483
  end
482
484
 
483
485
  it 'should not take former resources for direct get/post' do
484
- content =<<-EOF
486
+ content = <<-EOF
485
487
  RailsBestPracticesCom::Application.routes.draw do
486
488
  resources :posts
487
489
  post "sprints/stop"
@@ -493,7 +495,7 @@ module RailsBestPractices
493
495
  end
494
496
 
495
497
  it 'should not parse wrong route' do
496
- content =<<-EOF
498
+ content = <<-EOF
497
499
  RailsBestPracticesCom::Application.routes.draw do
498
500
  match ':controller/:action' => '#index', as: :auto_complete
499
501
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module RailsBestPractices
@@ -6,7 +8,7 @@ module RailsBestPractices
6
8
  let(:runner) { Core::Runner.new(prepares: SchemaPrepare.new) }
7
9
 
8
10
  it 'should parse model attributes' do
9
- content =<<-EOF
11
+ content = <<-EOF
10
12
  ActiveRecord::Schema.define(version: 20110319172136) do
11
13
  create_table "posts", force: true do |t|
12
14
  t.string "title"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module RailsBestPractices
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module RailsBestPractices
@@ -219,7 +221,7 @@ module RailsBestPractices
219
221
  end
220
222
 
221
223
  it 'should not always add db index if two indexes for polymorphic association' do
222
- content =<<-EOF
224
+ content = <<-EOF
223
225
  ActiveRecord::Schema.define(version: 20100603080629) do
224
226
  create_table "taggings", force: true do |t|
225
227
  t.integer "tagger_id"
@@ -237,7 +239,7 @@ module RailsBestPractices
237
239
  end
238
240
 
239
241
  it 'should not always add db index if table does not exist' do
240
- content =<<-EOF
242
+ content = <<-EOF
241
243
  ActiveRecord::Schema.define(version: 20100603080629) do
242
244
  create_table "comments", force: true do |t|
243
245
  t.integer "post_id"
@@ -250,18 +252,18 @@ module RailsBestPractices
250
252
  end
251
253
 
252
254
  it 'should always add db index if association_name is different to foreign_key' do
253
- content =<<-EOF
255
+ content = <<-EOF
254
256
  class Comment < ActiveRecord::Base
255
257
  belongs_to :commentor, class_name: "User"
256
258
  end
257
259
  EOF
258
260
  runner.prepare('app/models/comment.rb', content)
259
- content =<<-EOF
261
+ content = <<-EOF
260
262
  class User < ActiveRecord::Base
261
263
  end
262
264
  EOF
263
265
  runner.prepare('app/models/user.rb', content)
264
- content =<<-EOF
266
+ content = <<-EOF
265
267
  ActiveRecord::Schema.define(version: 20100603080629) do
266
268
  create_table "comments", force: true do |t|
267
269
  t.integer "commentor_id"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module RailsBestPractices
@@ -7,7 +9,7 @@ module RailsBestPractices
7
9
 
8
10
  describe 'check_destroy_return_value' do
9
11
  it 'should warn you if you fail to check the destroy return value' do
10
- content =<<-EOF
12
+ content = <<-EOF
11
13
  def my_method
12
14
  post = Posts.create do |p|
13
15
  p.title = "foo"
@@ -21,7 +23,7 @@ module RailsBestPractices
21
23
  end
22
24
 
23
25
  it 'should allow destroy return value if assigned to a var' do
24
- content =<<-EOF
26
+ content = <<-EOF
25
27
  def my_method
26
28
  post = Posts.create do |p|
27
29
  p.title = "foo"
@@ -34,7 +36,7 @@ module RailsBestPractices
34
36
  end
35
37
 
36
38
  it 'should allow destroy return value used in if' do
37
- content =<<-EOF
39
+ content = <<-EOF
38
40
  def my_method
39
41
  post = Posts.create do |p|
40
42
  p.title = "foo"
@@ -51,7 +53,7 @@ module RailsBestPractices
51
53
  end
52
54
 
53
55
  it 'should allow destroy return value used in elsif' do
54
- content =<<-EOF
56
+ content = <<-EOF
55
57
  def my_method
56
58
  post = Posts.create do |p|
57
59
  p.title = "foo"
@@ -70,7 +72,7 @@ module RailsBestPractices
70
72
  end
71
73
 
72
74
  it 'should allow destroy return value used in unless' do
73
- content =<<-EOF
75
+ content = <<-EOF
74
76
  def my_method
75
77
  unless @post.destroy
76
78
  raise "could not destroy"
@@ -82,7 +84,7 @@ module RailsBestPractices
82
84
  end
83
85
 
84
86
  it 'should allow destroy return value used in if_mod' do
85
- content =<<-EOF
87
+ content = <<-EOF
86
88
  def my_method
87
89
  post = Posts.create do |p|
88
90
  p.title = "foo"
@@ -95,7 +97,7 @@ module RailsBestPractices
95
97
  end
96
98
 
97
99
  it 'should allow destroy return value used in unless_mod' do
98
- content =<<-EOF
100
+ content = <<-EOF
99
101
  def my_method
100
102
  post = Posts.create do |p|
101
103
  p.title = "foo"
@@ -108,7 +110,7 @@ module RailsBestPractices
108
110
  end
109
111
 
110
112
  it 'should allow destroy return value used in unless with &&' do
111
- content =<<-EOF
113
+ content = <<-EOF
112
114
  def my_method
113
115
  unless some_method(1) && other_method(2) && @post.destroy
114
116
  raise "could not destroy"
@@ -120,7 +122,7 @@ module RailsBestPractices
120
122
  end
121
123
 
122
124
  it 'should allow destroy!' do
123
- content =<<-EOF
125
+ content = <<-EOF
124
126
  def my_method
125
127
  post = Posts.create do |p|
126
128
  p.title = "foo"
@@ -135,7 +137,7 @@ module RailsBestPractices
135
137
 
136
138
  it 'should not check ignored files' do
137
139
  runner = Core::Runner.new(reviews: CheckDestroyReturnValueReview.new(ignored_files: /helpers/))
138
- content =<<-EOF
140
+ content = <<-EOF
139
141
  def my_method
140
142
  post = Posts.create do |p|
141
143
  p.title = "foo"