Commit d168395807ea897bd48efcc8ee68fb01789073a3

Authored by Stephen Crosby
2 parents 9d51326c 311c015d
Exists in master and in 1 other branch production

Merge pull request #992 from rud/chore/cleanups

Rubocop cleanups - it's time
Showing 160 changed files with 1388 additions and 1505 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 160 files displayed.

@@ -29,11 +29,20 @@ Style/AccessModifierIndentation: @@ -29,11 +29,20 @@ Style/AccessModifierIndentation:
29 Style/AlignParameters: 29 Style/AlignParameters:
30 EnforcedStyle: with_fixed_indentation 30 EnforcedStyle: with_fixed_indentation
31 31
  32 +Style/DotPosition:
  33 + # Support code copy/paste into console
  34 + EnforcedStyle: trailing
  35 +
32 Style/IndentHash: 36 Style/IndentHash:
33 EnforcedStyle: consistent 37 EnforcedStyle: consistent
34 38
  39 +Style/AlignHash:
  40 + EnforcedHashRocketStyle: table
  41 + EnforcedColonStyle: table
  42 +
35 Style/SpaceAroundOperators: 43 Style/SpaceAroundOperators:
36 MultiSpaceAllowedForOperators: 44 MultiSpaceAllowedForOperators:
37 - '=' 45 - '='
38 - '=>' 46 - '=>'
39 - '||=' 47 - '||='
  48 + - 'then'
.rubocop_todo.yml
@@ -53,29 +53,12 @@ Rails/Validation: @@ -53,29 +53,12 @@ Rails/Validation:
53 - 'app/models/problem.rb' 53 - 'app/models/problem.rb'
54 - 'app/models/user.rb' 54 - 'app/models/user.rb'
55 55
56 -# Offense count: 8  
57 -# Cop supports --auto-correct.  
58 -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.  
59 -Style/AlignHash:  
60 - Exclude:  
61 - - 'app/models/app.rb'  
62 - - 'spec/controllers/apps_controller_spec.rb'  
63 - - 'spec/controllers/comments_controller_spec.rb'  
64 - - 'spec/controllers/problems_controller_spec.rb'  
65 - - 'spec/models/problem_spec.rb'  
66 -  
67 # Offense count: 105 56 # Offense count: 105
68 # Cop supports --auto-correct. 57 # Cop supports --auto-correct.
69 # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. 58 # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
70 Style/BlockDelimiters: 59 Style/BlockDelimiters:
71 Enabled: false 60 Enabled: false
72 61
73 -# Offense count: 49  
74 -# Cop supports --auto-correct.  
75 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
76 -Style/BracesAroundHashParameters:  
77 - Enabled: false  
78 -  
79 # Offense count: 15 62 # Offense count: 15
80 # Configuration parameters: EnforcedStyle, SupportedStyles. 63 # Configuration parameters: EnforcedStyle, SupportedStyles.
81 Style/ClassAndModuleChildren: 64 Style/ClassAndModuleChildren:
@@ -96,31 +79,11 @@ Style/ClassAndModuleChildren: @@ -96,31 +79,11 @@ Style/ClassAndModuleChildren:
96 - 'app/models/notification_services/webhook_service.rb' 79 - 'app/models/notification_services/webhook_service.rb'
97 - 'config/initializers/overrides.rb' 80 - 'config/initializers/overrides.rb'
98 81
99 -# Offense count: 23  
100 -Style/ConstantName:  
101 - Exclude:  
102 - - 'app/models/notification_service.rb'  
103 - - 'app/models/notification_services/campfire_service.rb'  
104 - - 'app/models/notification_services/flowdock_service.rb'  
105 - - 'app/models/notification_services/gtalk_service.rb'  
106 - - 'app/models/notification_services/hipchat_service.rb'  
107 - - 'app/models/notification_services/hoiio_service.rb'  
108 - - 'app/models/notification_services/hubot_service.rb'  
109 - - 'app/models/notification_services/pushover_service.rb'  
110 - - 'app/models/notification_services/slack_service.rb'  
111 - - 'app/models/notification_services/webhook_service.rb'  
112 -  
113 # Offense count: 70 82 # Offense count: 70
114 # Configuration parameters: Exclude. 83 # Configuration parameters: Exclude.
115 Style/Documentation: 84 Style/Documentation:
116 Enabled: false 85 Enabled: false
117 86
118 -# Offense count: 9  
119 -# Cop supports --auto-correct.  
120 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
121 -Style/DotPosition:  
122 - Enabled: false  
123 -  
124 # Offense count: 5 87 # Offense count: 5
125 Style/EachWithObject: 88 Style/EachWithObject:
126 Exclude: 89 Exclude:
@@ -161,12 +124,6 @@ Style/FormatString: @@ -161,12 +124,6 @@ Style/FormatString:
161 Style/GuardClause: 124 Style/GuardClause:
162 Enabled: false 125 Enabled: false
163 126
164 -# Offense count: 1168  
165 -# Cop supports --auto-correct.  
166 -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.  
167 -Style/HashSyntax:  
168 - Enabled: false  
169 -  
170 # Offense count: 6 127 # Offense count: 6
171 # Cop supports --auto-correct. 128 # Cop supports --auto-correct.
172 # Configuration parameters: MaxLineLength. 129 # Configuration parameters: MaxLineLength.
@@ -178,15 +135,6 @@ Style/IfUnlessModifier: @@ -178,15 +135,6 @@ Style/IfUnlessModifier:
178 - 'app/models/notice.rb' 135 - 'app/models/notice.rb'
179 - 'app/models/user.rb' 136 - 'app/models/user.rb'
180 137
181 -# Offense count: 6  
182 -# Cop supports --auto-correct.  
183 -Style/Lambda:  
184 - Exclude:  
185 - - 'app/models/app.rb'  
186 - - 'app/models/problem.rb'  
187 - - 'config/load.rb'  
188 - - 'spec/models/notice_observer_spec.rb'  
189 -  
190 # Offense count: 17 138 # Offense count: 17
191 # Cop supports --auto-correct. 139 # Cop supports --auto-correct.
192 Style/LeadingCommentSpace: 140 Style/LeadingCommentSpace:
@@ -200,17 +148,6 @@ Style/LeadingCommentSpace: @@ -200,17 +148,6 @@ Style/LeadingCommentSpace:
200 - 'spec/models/notification_service/hoiio_service_spec.rb' 148 - 'spec/models/notification_service/hoiio_service_spec.rb'
201 - 'spec/models/notification_service/pushover_service_spec.rb' 149 - 'spec/models/notification_service/pushover_service_spec.rb'
202 150
203 -# Offense count: 7  
204 -# Cop supports --auto-correct.  
205 -Style/MultilineBlockLayout:  
206 - Exclude:  
207 - - 'lib/tasks/errbit/demo.rake'  
208 - - 'spec/fabricators/issue_tracker_fabricator.rb'  
209 - - 'spec/interactors/user_destroy_spec.rb'  
210 - - 'spec/models/app_spec.rb'  
211 - - 'spec/models/error_report_spec.rb'  
212 - - 'spec/views/apps/show.atom.builder_spec.rb'  
213 -  
214 # Offense count: 10 151 # Offense count: 10
215 # Cop supports --auto-correct. 152 # Cop supports --auto-correct.
216 # Configuration parameters: EnforcedStyle, SupportedStyles. 153 # Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -228,71 +165,11 @@ Style/PercentLiteralDelimiters: @@ -228,71 +165,11 @@ Style/PercentLiteralDelimiters:
228 - 'spec/models/notice_spec.rb' 165 - 'spec/models/notice_spec.rb'
229 166
230 # Offense count: 1 167 # Offense count: 1
231 -# Cop supports --auto-correct.  
232 -Style/PerlBackrefs:  
233 - Exclude:  
234 - - 'spec/acceptance/reset_password_token.rb'  
235 -  
236 -# Offense count: 3  
237 -# Cop supports --auto-correct.  
238 -Style/Proc:  
239 - Exclude:  
240 - - 'app/models/notice.rb'  
241 - - 'app/models/problem.rb'  
242 -  
243 -# Offense count: 2  
244 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
245 -Style/RaiseArgs:  
246 - Enabled: false  
247 -  
248 -# Offense count: 3  
249 -# Cop supports --auto-correct.  
250 -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.  
251 -Style/RegexpLiteral:  
252 - Exclude:  
253 - - 'app/models/app.rb'  
254 - - 'config/initializers/ssl_enforcer.rb'  
255 - - 'config/load.rb'  
256 -  
257 -# Offense count: 2  
258 -# Cop supports --auto-correct.  
259 -# Configuration parameters: AllowAsExpressionSeparator.  
260 -Style/Semicolon:  
261 - Exclude:  
262 - - 'app/decorators/issue_tracker_type_decorator.rb'  
263 - - 'app/models/notice_fingerprinter.rb'  
264 -  
265 -# Offense count: 6  
266 -# Cop supports --auto-correct.  
267 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
268 -Style/SignalException:  
269 - Exclude:  
270 - - 'app/controllers/notices_controller.rb'  
271 - - 'app/interactors/problem_merge.rb'  
272 - - 'app/models/problem.rb'  
273 - - 'lib/airbrake_api/v3/notice_parser.rb'  
274 - - 'lib/hoptoad.rb'  
275 -  
276 -# Offense count: 4  
277 # Configuration parameters: Methods. 168 # Configuration parameters: Methods.
278 Style/SingleLineBlockParams: 169 Style/SingleLineBlockParams:
279 Exclude: 170 Exclude:
280 - - 'app/helpers/application_helper.rb'  
281 - - 'app/helpers/form_helper.rb'  
282 - - 'app/models/notice_fingerprinter.rb'  
283 - 'lib/hoptoad/v2.rb' 171 - 'lib/hoptoad/v2.rb'
284 172
285 -# Offense count: 19  
286 -# Cop supports --auto-correct.  
287 -# Configuration parameters: AllowIfMethodIsEmpty.  
288 -Style/SingleLineMethods:  
289 - Exclude:  
290 - - 'app/models/notification_service.rb'  
291 - - 'spec/decorators/issue_tracker_decorator_spec.rb'  
292 - - 'spec/decorators/issue_tracker_type_decorator_spec.rb'  
293 - - 'spec/errbit_plugin/mock_issue_tracker.rb'  
294 - - 'spec/views/problems/show.html.haml_spec.rb'  
295 -  
296 # Offense count: 11 173 # Offense count: 11
297 # Cop supports --auto-correct. 174 # Cop supports --auto-correct.
298 Style/SingleSpaceBeforeFirstArg: 175 Style/SingleSpaceBeforeFirstArg:
@@ -304,90 +181,8 @@ Style/SingleSpaceBeforeFirstArg: @@ -304,90 +181,8 @@ Style/SingleSpaceBeforeFirstArg:
304 - 'spec/fabricators/notice_fabricator.rb' 181 - 'spec/fabricators/notice_fabricator.rb'
305 - 'spec/fabricators/user_fabricator.rb' 182 - 'spec/fabricators/user_fabricator.rb'
306 183
307 -# Offense count: 2  
308 -# Cop supports --auto-correct.  
309 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
310 -Style/SpaceAroundEqualsInParameterDefault:  
311 - Enabled: false  
312 -  
313 -# Offense count: 27  
314 -# Cop supports --auto-correct.  
315 -# Configuration parameters: EnforcedStyle, SupportedStyles.  
316 -Style/SpaceBeforeBlockBraces:  
317 - Enabled: false  
318 -  
319 -# Offense count: 3  
320 -# Cop supports --auto-correct.  
321 -Style/SpaceBeforeComment:  
322 - Exclude:  
323 - - 'spec/controllers/api/v1/problems_controller_spec.rb'  
324 -  
325 -# Offense count: 75  
326 -# Cop supports --auto-correct.  
327 -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.  
328 -Style/SpaceInsideBlockBraces:  
329 - Enabled: false  
330 -  
331 -# Offense count: 26  
332 -# Cop supports --auto-correct.  
333 -Style/SpaceInsideBrackets:  
334 - Exclude:  
335 - - 'app/helpers/apps_helper.rb'  
336 - - 'app/models/issue.rb'  
337 - - 'app/models/notice_fingerprinter.rb'  
338 - - 'app/models/notification_services/gtalk_service.rb'  
339 - - 'config/initializers/devise.rb'  
340 - - 'lib/tasks/errbit/database.rake'  
341 - - 'spec/lib/configurator_spec.rb'  
342 - - 'spec/models/issue_spec.rb'  
343 -  
344 -# Offense count: 189  
345 -# Cop supports --auto-correct.  
346 -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.  
347 -Style/SpaceInsideHashLiteralBraces:  
348 - Enabled: false  
349 -  
350 # Offense count: 873 184 # Offense count: 873
351 # Cop supports --auto-correct. 185 # Cop supports --auto-correct.
352 # Configuration parameters: EnforcedStyle, SupportedStyles. 186 # Configuration parameters: EnforcedStyle, SupportedStyles.
353 Style/StringLiterals: 187 Style/StringLiterals:
354 Enabled: false 188 Enabled: false
355 -  
356 -# Offense count: 3  
357 -# Cop supports --auto-correct.  
358 -# Configuration parameters: IgnoredMethods.  
359 -Style/SymbolProc:  
360 - Exclude:  
361 - - 'app/controllers/users/omniauth_callbacks_controller.rb'  
362 - - 'app/models/deploy.rb'  
363 - - 'spec/models/deploy_spec.rb'  
364 -  
365 -# Offense count: 13  
366 -# Cop supports --auto-correct.  
367 -# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.  
368 -Style/TrailingComma:  
369 - Exclude:  
370 - - 'app/controllers/deploys_controller.rb'  
371 - - 'app/helpers/problems_helper.rb'  
372 - - 'app/models/notification_services/hipchat_service.rb'  
373 - - 'app/models/problem.rb'  
374 - - 'config/deploy.example.rb'  
375 - - 'config/initializers/action_mailer.rb'  
376 - - 'config/load.rb'  
377 - - 'lib/tasks/errbit/demo.rake'  
378 - - 'spec/decorators/issue_tracker_type_decorator_spec.rb'  
379 - - 'spec/initializers/action_mailer_spec.rb'  
380 - - 'spec/initializers/devise_spec.rb'  
381 -  
382 -# Offense count: 9  
383 -# Cop supports --auto-correct.  
384 -Style/TrailingWhitespace:  
385 - Exclude:  
386 - - 'app/models/notification_service.rb'  
387 - - 'app/models/notification_services/gtalk_service.rb'  
388 - - 'config/initializers/cve-2013-0156.rb'  
389 -  
390 -# Offense count: 2  
391 -Style/UnlessElse:  
392 - Exclude:  
393 - - 'app/controllers/problems_searcher.rb'  
@@ -29,8 +29,8 @@ gem 'htmlentities' @@ -29,8 +29,8 @@ gem 'htmlentities'
29 gem 'kaminari', '>= 0.14.1' 29 gem 'kaminari', '>= 0.14.1'
30 gem 'mongoid', '5.0.0' 30 gem 'mongoid', '5.0.0'
31 gem 'mongoid_rails_migrations' 31 gem 'mongoid_rails_migrations'
32 -gem 'rack-ssl', :require => 'rack/ssl' # force SSL  
33 -gem 'rack-ssl-enforcer', :require => false 32 +gem 'rack-ssl', require: 'rack/ssl' # force SSL
  33 +gem 'rack-ssl-enforcer', require: false
34 gem 'rails_autolink' 34 gem 'rails_autolink'
35 gem 'useragent' 35 gem 'useragent'
36 36
@@ -44,7 +44,7 @@ gem 'campy' @@ -44,7 +44,7 @@ gem 'campy'
44 # Hipchat 44 # Hipchat
45 gem 'hipchat' 45 gem 'hipchat'
46 # Google Talk 46 # Google Talk
47 -gem 'xmpp4r', :require => ["xmpp4r", "xmpp4r/muc"] 47 +gem 'xmpp4r', require: ["xmpp4r", "xmpp4r/muc"]
48 # Hoiio (SMS) 48 # Hoiio (SMS)
49 gem 'hoi' 49 gem 'hoi'
50 # Pushover (iOS Push notifications) 50 # Pushover (iOS Push notifications)
@@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby' @@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby'
64 gem 'json', platform: 'jruby' 64 gem 'json', platform: 'jruby'
65 65
66 group :development, :test do 66 group :development, :test do
67 - gem 'airbrake', :require => false 67 + gem 'airbrake', require: false
68 gem 'pry-rails' 68 gem 'pry-rails'
69 gem 'pry-byebug', platforms: [:mri] 69 gem 'pry-byebug', platforms: [:mri]
70 gem 'quiet_assets' 70 gem 'quiet_assets'
@@ -103,7 +103,7 @@ group :heroku, :production do @@ -103,7 +103,7 @@ group :heroku, :production do
103 gem 'unicorn', require: false, platform: 'ruby' 103 gem 'unicorn', require: false, platform: 'ruby'
104 end 104 end
105 105
106 -gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows 106 +gem 'therubyracer', platform: :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
107 gem 'sass-rails' 107 gem 'sass-rails'
108 gem 'uglifier' 108 gem 'uglifier'
109 # We can't upgrade because not compatible to jquery >= 1.9. 109 # We can't upgrade because not compatible to jquery >= 1.9.
@@ -8,7 +8,7 @@ Rails.application.load_tasks @@ -8,7 +8,7 @@ Rails.application.load_tasks
8 begin 8 begin
9 require 'rspec/core/rake_task' 9 require 'rspec/core/rake_task'
10 RSpec::Core::RakeTask.new(:spec) 10 RSpec::Core::RakeTask.new(:spec)
11 - task :default => :spec 11 + task default: :spec
12 rescue LoadError 12 rescue LoadError
13 warn "Notice: no rspec tasks available in this environment" 13 warn "Notice: no rspec tasks available in this environment"
14 end 14 end
app/controllers/api/v1/notices_controller.rb
@@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController @@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController
8 if params.key?(:start_date) && params.key?(:end_date) 8 if params.key?(:start_date) && params.key?(:end_date)
9 start_date = Time.zone.parse(params[:start_date]).utc 9 start_date = Time.zone.parse(params[:start_date]).utc
10 end_date = Time.zone.parse(params[:end_date]).utc 10 end_date = Time.zone.parse(params[:end_date]).utc
11 - query = {:created_at => {"$lte" => end_date, "$gte" => start_date}} 11 + query = { created_at: { "$lte" => end_date, "$gte" => start_date } }
12 end 12 end
13 13
14 results = benchmark("[api/v1/notices_controller] query time") do 14 results = benchmark("[api/v1/notices_controller] query time") do
15 - Notice.where(query).with(:consistency => :strong).only(fields).to_a 15 + Notice.where(query).with(consistency: :strong).only(fields).to_a
16 end 16 end
17 17
18 respond_to do |format| 18 respond_to do |format|
19 - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path  
20 - format.xml { render :xml => results } 19 + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path
  20 + format.xml { render xml: results }
21 end 21 end
22 end 22 end
23 end 23 end
app/controllers/api/v1/problems_controller.rb
@@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController @@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController
13 end 13 end
14 14
15 respond_to do |format| 15 respond_to do |format|
16 - format.any(:html, :json) { render :json => result } # render JSON if no extension specified on path  
17 - format.xml { render :xml => result } 16 + format.any(:html, :json) { render json: result } # render JSON if no extension specified on path
  17 + format.xml { render xml: result }
18 end 18 end
19 end 19 end
20 20
@@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController @@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController
24 if params.key?(:start_date) && params.key?(:end_date) 24 if params.key?(:start_date) && params.key?(:end_date)
25 start_date = Time.parse(params[:start_date]).utc 25 start_date = Time.parse(params[:start_date]).utc
26 end_date = Time.parse(params[:end_date]).utc 26 end_date = Time.parse(params[:end_date]).utc
27 - query = {:first_notice_at => {"$lte" => end_date}, "$or" => [{:resolved_at => nil}, {:resolved_at => {"$gte" => start_date}}]} 27 + query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ resolved_at: nil }, { resolved_at: { "$gte" => start_date } }] }
28 end 28 end
29 29
30 results = benchmark("[api/v1/problems_controller/index] query time") do 30 results = benchmark("[api/v1/problems_controller/index] query time") do
31 - Problem.where(query).with(:consistency => :strong).only(FIELDS).to_a 31 + Problem.where(query).with(consistency: :strong).only(FIELDS).to_a
32 end 32 end
33 33
34 respond_to do |format| 34 respond_to do |format|
35 - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path  
36 - format.xml { render :xml => results } 35 + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path
  36 + format.xml { render xml: results }
37 end 37 end
38 end 38 end
39 end 39 end
app/controllers/api/v1/stats_controller.rb
@@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController @@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController
11 end 11 end
12 12
13 stats = { 13 stats = {
14 - :name => @app.name,  
15 - :id => @app.id,  
16 - :last_error_time => @last_error_time,  
17 - :unresolved_errors => @app.unresolved_count 14 + name: @app.name,
  15 + id: @app.id,
  16 + last_error_time: @last_error_time,
  17 + unresolved_errors: @app.unresolved_count
18 } 18 }
19 19
20 respond_to do |format| 20 respond_to do |format|
21 - format.any(:html, :json) { render :json => JSON.dump(stats) } # render JSON if no extension specified on path  
22 - format.xml { render :xml => stats } 21 + format.any(:html, :json) { render json: JSON.dump(stats) } # render JSON if no extension specified on path
  22 + format.xml { render xml: stats }
23 end 23 end
24 end 24 end
25 25
26 protected def require_api_key_or_authenticate_user! 26 protected def require_api_key_or_authenticate_user!
27 if params[:api_key].present? 27 if params[:api_key].present?
28 - if (@app = App.where(:api_key => params[:api_key]).first) 28 + if (@app = App.where(api_key: params[:api_key]).first)
29 return true 29 return true
30 end 30 end
31 end 31 end
app/controllers/api/v3/notices_controller.rb
@@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController @@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController
15 if report.should_keep? 15 if report.should_keep?
16 report.generate_notice! 16 report.generate_notice!
17 render json: { 17 render json: {
18 - id: report.notice.id, 18 + id: report.notice.id,
19 url: app_problem_url( 19 url: app_problem_url(
20 report.app, 20 report.app,
21 report.error.problem_id) 21 report.error.problem_id)
app/controllers/application_controller.rb
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
5 before_action :authenticate_user! 5 before_action :authenticate_user!
6 before_action :set_time_zone 6 before_action :set_time_zone
7 7
8 - rescue_from ActionController::RedirectBackError, :with => :redirect_to_root 8 + rescue_from ActionController::RedirectBackError, with: :redirect_to_root
9 9
10 class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy 10 class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy
11 def assign_attributes? 11 def assign_attributes?
app/controllers/apps_controller.rb
1 class AppsController < ApplicationController 1 class AppsController < ApplicationController
2 include ProblemsSearcher 2 include ProblemsSearcher
3 3
4 - before_action :require_admin!, :except => [:index, :show]  
5 - before_action :parse_email_at_notices_or_set_default, :only => [:create, :update]  
6 - before_action :parse_notice_at_notices_or_set_default, :only => [:create, :update] 4 + before_action :require_admin!, except: [:index, :show]
  5 + before_action :parse_email_at_notices_or_set_default, only: [:create, :update]
  6 + before_action :parse_notice_at_notices_or_set_default, only: [:create, :update]
7 respond_to :html 7 respond_to :html
8 8
9 expose(:app_scope) { App } 9 expose(:app_scope) { App }
@@ -39,7 +39,7 @@ class AppsController &lt; ApplicationController @@ -39,7 +39,7 @@ class AppsController &lt; ApplicationController
39 } 39 }
40 40
41 expose(:users) { 41 expose(:users) {
42 - User.all.sort_by {|u| u.name.downcase } 42 + User.all.sort_by { |u| u.name.downcase }
43 } 43 }
44 44
45 def index; end 45 def index; end
@@ -55,7 +55,7 @@ class AppsController &lt; ApplicationController @@ -55,7 +55,7 @@ class AppsController &lt; ApplicationController
55 def create 55 def create
56 initialize_subclassed_notification_service 56 initialize_subclassed_notification_service
57 if app.save 57 if app.save
58 - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.create.success') } 58 + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.create.success') }
59 else 59 else
60 flash[:error] = I18n.t('controllers.apps.flash.create.error') 60 flash[:error] = I18n.t('controllers.apps.flash.create.error')
61 render :new 61 render :new
@@ -65,7 +65,7 @@ class AppsController &lt; ApplicationController @@ -65,7 +65,7 @@ class AppsController &lt; ApplicationController
65 def update 65 def update
66 initialize_subclassed_notification_service 66 initialize_subclassed_notification_service
67 if app.save 67 if app.save
68 - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.update.success') } 68 + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.update.success') }
69 else 69 else
70 flash[:error] = I18n.t('controllers.apps.flash.update.error') 70 flash[:error] = I18n.t('controllers.apps.flash.update.error')
71 render :edit 71 render :edit
@@ -78,7 +78,7 @@ class AppsController &lt; ApplicationController @@ -78,7 +78,7 @@ class AppsController &lt; ApplicationController
78 78
79 def destroy 79 def destroy
80 if app.destroy 80 if app.destroy
81 - redirect_to apps_url, :flash => { :success => I18n.t('controllers.apps.flash.destroy.success') } 81 + redirect_to apps_url, flash: { success: I18n.t('controllers.apps.flash.destroy.success') }
82 else 82 else
83 flash[:error] = I18n.t('controllers.apps.flash.destroy.error') 83 flash[:error] = I18n.t('controllers.apps.flash.destroy.error')
84 render :show 84 render :show
@@ -96,7 +96,7 @@ protected @@ -96,7 +96,7 @@ protected
96 # set the app's notification service 96 # set the app's notification service
97 if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) 97 if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type])
98 available_notification_classes = [NotificationService] + NotificationService.subclasses 98 available_notification_classes = [NotificationService] + NotificationService.subclasses
99 - notification_class = available_notification_classes.detect{|c| c.name == notification_type} 99 + notification_class = available_notification_classes.detect { |c| c.name == notification_type }
100 if notification_class.present? 100 if notification_class.present?
101 app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) 101 app.notification_service = notification_class.new(params[:app][:notification_service_attributes])
102 end 102 end
@@ -116,7 +116,7 @@ protected @@ -116,7 +116,7 @@ protected
116 # Sanitize negative values, split on comma, 116 # Sanitize negative values, split on comma,
117 # strip, parse as integer, remove all '0's. 117 # strip, parse as integer, remove all '0's.
118 # If empty, set as default and show an error message. 118 # If empty, set as default and show an error message.
119 - email_at_notices = val.gsub(/-\d+/, "").split(",").map{|v| v.strip.to_i }.reject{|v| v == 0} 119 + email_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i }.reject { |v| v == 0 }
120 if email_at_notices.any? 120 if email_at_notices.any?
121 params[:app][:email_at_notices] = email_at_notices 121 params[:app][:email_at_notices] = email_at_notices
122 else 122 else
@@ -131,7 +131,7 @@ protected @@ -131,7 +131,7 @@ protected
131 # Sanitize negative values, split on comma, 131 # Sanitize negative values, split on comma,
132 # strip, parse as integer, remove all '0's. 132 # strip, parse as integer, remove all '0's.
133 # If empty, set as default and show an error message. 133 # If empty, set as default and show an error message.
134 - notify_at_notices = val.gsub(/-\d+/, "").split(",").map{|v| v.strip.to_i } 134 + notify_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i }
135 if notify_at_notices.any? 135 if notify_at_notices.any?
136 params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices 136 params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices
137 else 137 else
app/controllers/comments_controller.rb
@@ -3,7 +3,7 @@ class CommentsController &lt; ApplicationController @@ -3,7 +3,7 @@ class CommentsController &lt; ApplicationController
3 before_action :find_problem 3 before_action :find_problem
4 4
5 def create 5 def create
6 - @comment = Comment.new(comment_params.merge(:user_id => current_user.id)) 6 + @comment = Comment.new(comment_params.merge(user_id: current_user.id))
7 if @comment.valid? 7 if @comment.valid?
8 @problem.comments << @comment 8 @problem.comments << @comment
9 @problem.save 9 @problem.save
app/controllers/deploys_controller.rb
1 class DeploysController < ApplicationController 1 class DeploysController < ApplicationController
2 - protect_from_forgery :except => :create 2 + protect_from_forgery except: :create
3 3
4 - skip_before_action :verify_authenticity_token, :only => :create  
5 - skip_before_action :authenticate_user!, :only => :create 4 + skip_before_action :verify_authenticity_token, only: :create
  5 + skip_before_action :authenticate_user!, only: :create
6 6
7 def create 7 def create
8 @app = App.find_by_api_key!(params[:api_key]) 8 @app = App.find_by_api_key!(params[:api_key])
9 @deploy = @app.deploys.create!(default_deploy || heroku_deploy) 9 @deploy = @app.deploys.create!(default_deploy || heroku_deploy)
10 - render :xml => @deploy 10 + render xml: @deploy
11 end 11 end
12 12
13 def index 13 def index
@@ -21,11 +21,11 @@ private @@ -21,11 +21,11 @@ private
21 def default_deploy 21 def default_deploy
22 if params[:deploy] 22 if params[:deploy]
23 { 23 {
24 - :username => params[:deploy][:local_username],  
25 - :environment => params[:deploy][:rails_env],  
26 - :repository => params[:deploy][:scm_repository],  
27 - :revision => params[:deploy][:scm_revision],  
28 - :message => params[:deploy][:message] 24 + username: params[:deploy][:local_username],
  25 + environment: params[:deploy][:rails_env],
  26 + repository: params[:deploy][:scm_repository],
  27 + revision: params[:deploy][:scm_revision],
  28 + message: params[:deploy][:message]
29 } 29 }
30 end 30 end
31 end 31 end
@@ -33,10 +33,10 @@ private @@ -33,10 +33,10 @@ private
33 # handle Heroku's HTTP post deployhook format 33 # handle Heroku's HTTP post deployhook format
34 def heroku_deploy 34 def heroku_deploy
35 { 35 {
36 - :username => params[:user],  
37 - :environment => params[:rack_env].try(:downcase) || params[:app],  
38 - :repository => "git@heroku.com:#{params[:app]}.git",  
39 - :revision => params[:head], 36 + username: params[:user],
  37 + environment: params[:rack_env].try(:downcase) || params[:app],
  38 + repository: "git@heroku.com:#{params[:app]}.git",
  39 + revision: params[:head]
40 } 40 }
41 end 41 end
42 end 42 end
app/controllers/notices_controller.rb
@@ -4,7 +4,7 @@ class NoticesController &lt; ApplicationController @@ -4,7 +4,7 @@ class NoticesController &lt; ApplicationController
4 skip_before_action :authenticate_user!, only: :create 4 skip_before_action :authenticate_user!, only: :create
5 skip_before_action :verify_authenticity_token, only: :create 5 skip_before_action :verify_authenticity_token, only: :create
6 6
7 - rescue_from ParamsError, :with => :bad_params 7 + rescue_from ParamsError, with: :bad_params
8 8
9 def create 9 def create
10 # params[:data] if the notice came from a GET request, raw_post if it came via POST 10 # params[:data] if the notice came from a GET request, raw_post if it came via POST
@@ -13,18 +13,18 @@ class NoticesController &lt; ApplicationController @@ -13,18 +13,18 @@ class NoticesController &lt; ApplicationController
13 if report.valid? 13 if report.valid?
14 if report.should_keep? 14 if report.should_keep?
15 report.generate_notice! 15 report.generate_notice!
16 - api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml|  
17 - xml.url locate_url(report.notice.id, :host => Errbit::Config.host) 16 + api_xml = report.notice.to_xml(only: false, methods: [:id]) do |xml|
  17 + xml.url locate_url(report.notice.id, host: Errbit::Config.host)
18 end 18 end
19 - render :xml => api_xml 19 + render xml: api_xml
20 else 20 else
21 - render :text => "Notice for old app version ignored" 21 + render text: "Notice for old app version ignored"
22 end 22 end
23 else 23 else
24 - render :text => "Your API key is unknown", :status => 422 24 + render text: "Your API key is unknown", status: 422
25 end 25 end
26 rescue Nokogiri::XML::SyntaxError 26 rescue Nokogiri::XML::SyntaxError
27 - render :text => 'The provided XML was not well-formed', :status => 422 27 + render text: 'The provided XML was not well-formed', status: 422
28 end 28 end
29 29
30 # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem. 30 # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem.
@@ -39,12 +39,12 @@ private @@ -39,12 +39,12 @@ private
39 return @notice_params if @notice_params 39 return @notice_params if @notice_params
40 @notice_params = params[:data] || request.raw_post 40 @notice_params = params[:data] || request.raw_post
41 if @notice_params.blank? 41 if @notice_params.blank?
42 - raise ParamsError.new('Need a data params in GET or raw post data') 42 + fail ParamsError, 'Need a data params in GET or raw post data'
43 end 43 end
44 @notice_params 44 @notice_params
45 end 45 end
46 46
47 def bad_params(exception) 47 def bad_params(exception)
48 - render :text => exception.message, :status => :bad_request 48 + render text: exception.message, status: :bad_request
49 end 49 end
50 end 50 end
app/controllers/problems_controller.rb
@@ -7,12 +7,12 @@ @@ -7,12 +7,12 @@
7 class ProblemsController < ApplicationController 7 class ProblemsController < ApplicationController
8 include ProblemsSearcher 8 include ProblemsSearcher
9 9
10 - before_action :need_selected_problem, :only => [ 10 + before_action :need_selected_problem, only: [
11 :resolve_several, :unresolve_several, :unmerge_several 11 :resolve_several, :unresolve_several, :unmerge_several
12 ] 12 ]
13 13
14 expose(:app_scope) { 14 expose(:app_scope) {
15 - params[:app_id] ? App.where(:_id => params[:app_id]) : App.all 15 + params[:app_id] ? App.where(_id: params[:app_id]) : App.all
16 } 16 }
17 17
18 expose(:app) { 18 expose(:app) {
@@ -32,11 +32,11 @@ class ProblemsController &lt; ApplicationController @@ -32,11 +32,11 @@ class ProblemsController &lt; ApplicationController
32 } 32 }
33 33
34 expose(:problems) { 34 expose(:problems) {
35 - pro = Problem  
36 - .for_apps(app_scope)  
37 - .in_env(params_environement)  
38 - .all_else_unresolved(all_errs)  
39 - .ordered_by(params_sort, params_order) 35 + pro = Problem.
  36 + for_apps(app_scope).
  37 + in_env(params_environement).
  38 + all_else_unresolved(all_errs).
  39 + ordered_by(params_sort, params_order)
40 40
41 if request.format == :html 41 if request.format == :html
42 pro.page(params[:page]).per(current_user.per_page) 42 pro.page(params[:page]).per(current_user.per_page)
@@ -48,8 +48,8 @@ class ProblemsController &lt; ApplicationController @@ -48,8 +48,8 @@ class ProblemsController &lt; ApplicationController
48 def index; end 48 def index; end
49 49
50 def show 50 def show
51 - @notices = problem.object.notices.reverse_ordered  
52 - .page(params[:notice]).per(1) 51 + @notices = problem.object.notices.reverse_ordered.
  52 + page(params[:notice]).per(1)
53 @notice = NoticeDecorator.new @notices.first 53 @notice = NoticeDecorator.new @notices.first
54 @comment = Comment.new 54 @comment = Comment.new
55 end 55 end
@@ -80,13 +80,13 @@ class ProblemsController &lt; ApplicationController @@ -80,13 +80,13 @@ class ProblemsController &lt; ApplicationController
80 80
81 def resolve_several 81 def resolve_several
82 selected_problems.each(&:resolve!) 82 selected_problems.each(&:resolve!)
83 - flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, :count => selected_problems.count)} been resolved." 83 + flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, count: selected_problems.count)} been resolved."
84 redirect_to :back 84 redirect_to :back
85 end 85 end
86 86
87 def unresolve_several 87 def unresolve_several
88 selected_problems.each(&:unresolve!) 88 selected_problems.each(&:unresolve!)
89 - flash[:success] = "#{I18n.t(:n_errs_have, :count => selected_problems.count)} been unresolved." 89 + flash[:success] = "#{I18n.t(:n_errs_have, count: selected_problems.count)} been unresolved."
90 redirect_to :back 90 redirect_to :back
91 end 91 end
92 92
@@ -100,26 +100,26 @@ class ProblemsController &lt; ApplicationController @@ -100,26 +100,26 @@ class ProblemsController &lt; ApplicationController
100 flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge') 100 flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge')
101 else 101 else
102 ProblemMerge.new(selected_problems).merge 102 ProblemMerge.new(selected_problems).merge
103 - flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', :nb => selected_problems.count) 103 + flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', nb: selected_problems.count)
104 end 104 end
105 redirect_to :back 105 redirect_to :back
106 end 106 end
107 107
108 def unmerge_several 108 def unmerge_several
109 all = selected_problems.map(&:unmerge!).flatten 109 all = selected_problems.map(&:unmerge!).flatten
110 - flash[:success] = "#{I18n.t(:n_errs_have, :count => all.length)} been unmerged." 110 + flash[:success] = "#{I18n.t(:n_errs_have, count: all.length)} been unmerged."
111 redirect_to :back 111 redirect_to :back
112 end 112 end
113 113
114 def destroy_several 114 def destroy_several
115 nb_problem_destroy = ProblemDestroy.execute(selected_problems) 115 nb_problem_destroy = ProblemDestroy.execute(selected_problems)
116 - flash[:notice] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." 116 + flash[:notice] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted."
117 redirect_to :back 117 redirect_to :back
118 end 118 end
119 119
120 def destroy_all 120 def destroy_all
121 nb_problem_destroy = ProblemDestroy.execute(app.problems) 121 nb_problem_destroy = ProblemDestroy.execute(app.problems)
122 - flash[:success] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." 122 + flash[:success] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted."
123 redirect_to :back 123 redirect_to :back
124 rescue ActionController::RedirectBackError 124 rescue ActionController::RedirectBackError
125 redirect_to app_path(app) 125 redirect_to app_path(app)
app/controllers/problems_searcher.rb
@@ -6,18 +6,18 @@ module ProblemsSearcher @@ -6,18 +6,18 @@ module ProblemsSearcher
6 6
7 included do 7 included do
8 expose(:params_sort) { 8 expose(:params_sort) {
9 - unless %w{app message last_notice_at last_deploy_at count}.member?(params[:sort])  
10 - "last_notice_at"  
11 - else 9 + if %w{app message last_notice_at last_deploy_at count}.member?(params[:sort])
12 params[:sort] 10 params[:sort]
  11 + else
  12 + "last_notice_at"
13 end 13 end
14 } 14 }
15 15
16 - expose(:params_order){  
17 - unless %w{asc desc}.member?(params[:order])  
18 - 'desc'  
19 - else 16 + expose(:params_order) {
  17 + if %w{asc desc}.member?(params[:order])
20 params[:order] 18 params[:order]
  19 + else
  20 + 'desc'
21 end 21 end
22 } 22 }
23 23
app/controllers/site_config_controller.rb
@@ -13,10 +13,10 @@ class SiteConfigController &lt; ApplicationController @@ -13,10 +13,10 @@ class SiteConfigController &lt; ApplicationController
13 end 13 end
14 14
15 private def filtered_update_params 15 private def filtered_update_params
16 - params  
17 - .require(:site_config)  
18 - .require(:notice_fingerprinter_attributes)  
19 - .permit( 16 + params.
  17 + require(:site_config).
  18 + require(:notice_fingerprinter_attributes).
  19 + permit(
20 :error_class, 20 :error_class,
21 :message, 21 :message,
22 :backtrace_lines, 22 :backtrace_lines,
app/controllers/users/omniauth_callbacks_controller.rb
@@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController @@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
2 def github 2 def github
3 github_login = env["omniauth.auth"].extra.raw_info.login 3 github_login = env["omniauth.auth"].extra.raw_info.login
4 github_token = env["omniauth.auth"].credentials.token 4 github_token = env["omniauth.auth"].credentials.token
5 - github_user = User.where(:github_login => github_login).first 5 + github_user = User.where(github_login: github_login).first
6 github_site_title = Errbit::Config.github_site_title 6 github_site_title = Errbit::Config.github_site_title
7 7
8 if github_user.nil? && (github_org_id = Errbit::Config.github_org_id) 8 if github_user.nil? && (github_org_id = Errbit::Config.github_org_id)
@@ -10,7 +10,7 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController @@ -10,7 +10,7 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
10 # If they are, automatically create an account 10 # If they are, automatically create an account
11 client = Octokit::Client.new(access_token: github_token) 11 client = Octokit::Client.new(access_token: github_token)
12 client.api_endpoint = Errbit::Config.github_api_url 12 client.api_endpoint = Errbit::Config.github_api_url
13 - org_ids = client.organizations.map { |org| org.id } 13 + org_ids = client.organizations.map(&:id)
14 if org_ids.include?(github_org_id) 14 if org_ids.include?(github_org_id)
15 github_user = User.create(name: env["omniauth.auth"].extra.raw_info.name, email: env["omniauth.auth"].extra.raw_info.email) 15 github_user = User.create(name: env["omniauth.auth"].extra.raw_info.name, email: env["omniauth.auth"].extra.raw_info.email)
16 end 16 end
@@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController @@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
31 elsif github_user 31 elsif github_user
32 # Store OAuth token 32 # Store OAuth token
33 update_user_with_github_attributes(github_user, github_login, github_token) 33 update_user_with_github_attributes(github_user, github_login, github_token)
34 - flash[:success] = I18n.t "devise.omniauth_callbacks.success", :kind => github_site_title  
35 - sign_in_and_redirect github_user, :event => :authentication 34 + flash[:success] = I18n.t "devise.omniauth_callbacks.success", kind: github_site_title
  35 + sign_in_and_redirect github_user, event: :authentication
36 else 36 else
37 flash[:error] = "There are no authorized users with #{github_site_title} login '#{github_login}'. Please ask an administrator to register your user account." 37 flash[:error] = "There are no authorized users with #{github_site_title} login '#{github_login}'. Please ask an administrator to register your user account."
38 redirect_to new_user_session_path 38 redirect_to new_user_session_path
@@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController @@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
41 41
42 private def update_user_with_github_attributes(user, login, token) 42 private def update_user_with_github_attributes(user, login, token)
43 user.update_attributes( 43 user.update_attributes(
44 - :github_login => login,  
45 - :github_oauth_token => token 44 + github_login: login,
  45 + github_oauth_token: token
46 ) 46 )
47 end 47 end
48 end 48 end
app/controllers/users_controller.rb
1 class UsersController < ApplicationController 1 class UsersController < ApplicationController
2 respond_to :html 2 respond_to :html
3 3
4 - before_action :require_admin!, :except => [:edit, :update]  
5 - before_action :require_user_edit_priviledges, :only => [:edit, :update] 4 + before_action :require_admin!, except: [:edit, :update]
  5 + before_action :require_user_edit_priviledges, only: [:edit, :update]
6 6
7 - expose(:user, :attributes => :user_params) 7 + expose(:user, attributes: :user_params)
8 expose(:users) { 8 expose(:users) {
9 User.all.page(params[:page]).per(current_user.per_page) 9 User.all.page(params[:page]).per(current_user.per_page)
10 } 10 }
@@ -24,7 +24,7 @@ class UsersController &lt; ApplicationController @@ -24,7 +24,7 @@ class UsersController &lt; ApplicationController
24 24
25 def update 25 def update
26 if user.update_attributes(user_params) 26 if user.update_attributes(user_params)
27 - flash[:success] = I18n.t('controllers.users.flash.update.success', :name => user.name) 27 + flash[:success] = I18n.t('controllers.users.flash.update.success', name: user.name)
28 redirect_to user_path(user) 28 redirect_to user_path(user)
29 else 29 else
30 render :edit 30 render :edit
@@ -41,13 +41,13 @@ class UsersController &lt; ApplicationController @@ -41,13 +41,13 @@ class UsersController &lt; ApplicationController
41 flash[:error] = I18n.t('controllers.users.flash.destroy.error') 41 flash[:error] = I18n.t('controllers.users.flash.destroy.error')
42 else 42 else
43 UserDestroy.new(user).destroy 43 UserDestroy.new(user).destroy
44 - flash[:success] = I18n.t('controllers.users.flash.destroy.success', :name => user.name) 44 + flash[:success] = I18n.t('controllers.users.flash.destroy.success', name: user.name)
45 end 45 end
46 redirect_to users_path 46 redirect_to users_path
47 end 47 end
48 48
49 def unlink_github 49 def unlink_github
50 - user.update_attributes :github_login => nil, :github_oauth_token => nil 50 + user.update_attributes github_login: nil, github_oauth_token: nil
51 redirect_to user_path(user) 51 redirect_to user_path(user)
52 end 52 end
53 53
@@ -65,7 +65,7 @@ protected @@ -65,7 +65,7 @@ protected
65 def user_permit_params 65 def user_permit_params
66 @user_permit_params ||= [:name, :username, :email, :github_login, :per_page, :time_zone] 66 @user_permit_params ||= [:name, :username, :email, :github_login, :per_page, :time_zone]
67 @user_permit_params << :admin if current_user.admin? && current_user.id != params[:id] 67 @user_permit_params << :admin if current_user.admin? && current_user.id != params[:id]
68 - @user_permit_params |= [:password, :password_confirmation] if user_password_params.values.all?{|pa| !pa.blank? } 68 + @user_permit_params |= [:password, :password_confirmation] if user_password_params.values.all? { |pa| !pa.blank? }
69 @user_permit_params 69 @user_permit_params
70 end 70 end
71 71
app/controllers/watchers_controller.rb
@@ -6,7 +6,7 @@ class WatchersController &lt; ApplicationController @@ -6,7 +6,7 @@ class WatchersController &lt; ApplicationController
6 end 6 end
7 7
8 def destroy 8 def destroy
9 - watcher = app.watchers.where(:user_id => params[:id]).first 9 + watcher = app.watchers.where(user_id: params[:id]).first
10 app.watchers.delete(watcher) 10 app.watchers.delete(watcher)
11 flash[:success] = t('.success', app: app.name) 11 flash[:success] = t('.success', app: app.name)
12 redirect_to app_path(app) 12 redirect_to app_path(app)
app/decorators/app_decorator.rb
1 class AppDecorator < Draper::Decorator 1 class AppDecorator < Draper::Decorator
2 decorates_association :watchers 2 decorates_association :watchers
3 - decorates_association :issue_tracker, :with => IssueTrackerDecorator 3 + decorates_association :issue_tracker, with: IssueTrackerDecorator
4 delegate_all 4 delegate_all
5 5
6 def email_at_notices 6 def email_at_notices
app/decorators/backtrace_line_decorator.rb
@@ -44,9 +44,9 @@ class BacktraceLineDecorator &lt; Draper::Decorator @@ -44,9 +44,9 @@ class BacktraceLineDecorator &lt; Draper::Decorator
44 end 44 end
45 45
46 def decorated_path 46 def decorated_path
47 - path  
48 - .sub(Backtrace::IN_APP_PATH, '')  
49 - .sub(Backtrace::GEMS_PATH, "<strong>\\1</strong>") 47 + path.
  48 + sub(Backtrace::IN_APP_PATH, '').
  49 + sub(Backtrace::GEMS_PATH, "<strong>\\1</strong>")
50 end 50 end
51 51
52 private 52 private
@@ -67,25 +67,25 @@ private @@ -67,25 +67,25 @@ private
67 67
68 def link_to_hosted_javascript(app, text) 68 def link_to_hosted_javascript(app, text)
69 if app.asset_host? 69 if app.asset_host?
70 - h.link_to(text, "#{app.asset_host}/#{file_relative}", :target => '_blank') 70 + h.link_to(text, "#{app.asset_host}/#{file_relative}", target: '_blank')
71 end 71 end
72 end 72 end
73 73
74 def link_to_github(app, text = nil) 74 def link_to_github(app, text = nil)
75 return unless app.github_repo? 75 return unless app.github_repo?
76 href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] 76 href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number]
77 - h.link_to(text || file_name, href, :target => '_blank') 77 + h.link_to(text || file_name, href, target: '_blank')
78 end 78 end
79 79
80 def link_to_bitbucket(app, text = nil) 80 def link_to_bitbucket(app, text = nil)
81 return unless app.bitbucket_repo? 81 return unless app.bitbucket_repo?
82 href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] 82 href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number]
83 - h.link_to(text || file_name, href, :target => '_blank') 83 + h.link_to(text || file_name, href, target: '_blank')
84 end 84 end
85 85
86 def link_to_issue_tracker_file(app, text = nil) 86 def link_to_issue_tracker_file(app, text = nil)
87 return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file) 87 return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file)
88 href = app.issue_tracker.url_to_file(file_relative, number) 88 href = app.issue_tracker.url_to_file(file_relative, number)
89 - h.link_to(text || file_name, href, :target => '_blank') 89 + h.link_to(text || file_name, href, target: '_blank')
90 end 90 end
91 end 91 end
app/decorators/issue_tracker_field_decorator.rb
@@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator &lt; Draper::Decorator @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator &lt; Draper::Decorator
13 13
14 def input(form, issue_tracker) 14 def input(form, issue_tracker)
15 form.send(input_field, key.to_s, 15 form.send(input_field, key.to_s,
16 - :placeholder => field_info[:placeholder],  
17 - :value => issue_tracker.options[key.to_s]) 16 + placeholder: field_info[:placeholder],
  17 + value: issue_tracker.options[key.to_s])
18 end 18 end
19 19
20 private def input_field 20 private def input_field
app/decorators/issue_tracker_type_decorator.rb
@@ -7,7 +7,8 @@ class IssueTrackerTypeDecorator &lt; Draper::Decorator @@ -7,7 +7,8 @@ class IssueTrackerTypeDecorator &lt; Draper::Decorator
7 return unless object.icons 7 return unless object.icons
8 8
9 object.icons.reduce({}) do |c, (k, v)| 9 object.icons.reduce({}) do |c, (k, v)|
10 - c[k] = "data:#{v[0]};base64,#{Base64.encode64(v[1])}"; c 10 + c[k] = "data:#{v[0]};base64,#{Base64.encode64(v[1])}"
  11 + c
11 end 12 end
12 end 13 end
13 14
app/helpers/application_helper.rb
@@ -13,7 +13,7 @@ module ApplicationHelper @@ -13,7 +13,7 @@ module ApplicationHelper
13 event.dtend = notice.created_at.utc + 60.minutes 13 event.dtend = notice.created_at.utc + 60.minutes
14 event.organizer = notice.server_environment && notice.server_environment["hostname"] 14 event.organizer = notice.server_environment && notice.server_environment["hostname"]
15 event.location = notice.project_root 15 event.location = notice.project_root
16 - event.url = app_problem_url(:app_id => notice.problem.app.id, :id => notice.problem) 16 + event.url = app_problem_url(app_id: notice.problem.app.id, id: notice.problem)
17 end 17 end
18 end 18 end
19 end.to_s 19 end.to_s
@@ -53,12 +53,12 @@ module ApplicationHelper @@ -53,12 +53,12 @@ module ApplicationHelper
53 end 53 end
54 end 54 end
55 55
56 - def create_percentage_table_from_tallies(tallies, options={}) 56 + def create_percentage_table_from_tallies(tallies, options = {})
57 total = (options[:total] || total_from_tallies(tallies)) 57 total = (options[:total] || total_from_tallies(tallies))
58 percent = 100.0 / total.to_f 58 percent = 100.0 / total.to_f
59 - rows = tallies.map {|value, count| [(count.to_f * percent), value]} \  
60 - .sort {|a, b| b[0] <=> a[0]}  
61 - render "problems/tally_table", :rows => rows 59 + rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \
  60 + sort { |a, b| b[0] <=> a[0] }
  61 + render "problems/tally_table", rows: rows
62 end 62 end
63 63
64 def head(collection) 64 def head(collection)
@@ -78,7 +78,7 @@ module ApplicationHelper @@ -78,7 +78,7 @@ module ApplicationHelper
78 private 78 private
79 79
80 def total_from_tallies(tallies) 80 def total_from_tallies(tallies)
81 - tallies.values.inject(0) {|sum, n| sum + n} 81 + tallies.values.sum
82 end 82 end
83 83
84 def head_size 84 def head_size
app/helpers/apps_helper.rb
@@ -2,11 +2,11 @@ module AppsHelper @@ -2,11 +2,11 @@ module AppsHelper
2 def link_to_copy_attributes_from_other_app 2 def link_to_copy_attributes_from_other_app
3 if App.count > 1 3 if App.count > 1
4 html = link_to('copy settings from another app', '#', 4 html = link_to('copy settings from another app', '#',
5 - :class => 'button copy_config') 5 + class: 'button copy_config')
6 html << select("duplicate", "app", 6 html << select("duplicate", "app",
7 - App.all.asc(:name).reject{|a| a == @app }.  
8 - collect{|p| [ p.name, p.id ] }, {:include_blank => "[choose app]"},  
9 - {:class => "choose_other_app", :style => "display: none;"}) 7 + App.all.asc(:name).reject { |a| a == @app }.
  8 + collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" },
  9 + class: "choose_other_app", style: "display: none;")
10 return html 10 return html
11 end 11 end
12 end 12 end
app/helpers/form_helper.rb
@@ -2,10 +2,12 @@ module FormHelper @@ -2,10 +2,12 @@ module FormHelper
2 def errors_for(document) 2 def errors_for(document)
3 return unless document.errors.any? 3 return unless document.errors.any?
4 4
5 - content_tag(:div, :class => 'error-messages') do 5 + content_tag(:div, class: 'error-messages') do
6 body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.') 6 body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.')
7 body + content_tag(:ul) do 7 body + content_tag(:ul) do
8 - document.errors.full_messages.inject('') {|errs, msg| errs + content_tag(:li, h(msg)) }.html_safe 8 + document.errors.full_messages.inject('') do |errs, msg|
  9 + errs + content_tag(:li, h(msg))
  10 + end.html_safe
9 end 11 end
10 end 12 end
11 end 13 end
app/helpers/navigation_helper.rb
@@ -19,10 +19,10 @@ module NavigationHelper @@ -19,10 +19,10 @@ module NavigationHelper
19 matches 19 matches
20 when Array 20 when Array
21 s = {} 21 s = {}
22 - matches.each {|c| s[c] = :all} 22 + matches.each { |c| s[c] = :all }
23 s 23 s
24 else 24 else
25 - {matches => :all} 25 + { matches => :all }
26 end 26 end
27 27
28 active = nil 28 active = nil
app/helpers/notices_helper.rb
1 # encoding: utf-8 1 # encoding: utf-8
2 module NoticesHelper 2 module NoticesHelper
3 def notice_atom_summary(notice) 3 def notice_atom_summary(notice)
4 - render "notices/atom_entry", :notice => notice 4 + render "notices/atom_entry", notice: notice
5 end 5 end
6 end 6 end
app/helpers/problems_helper.rb
@@ -6,21 +6,21 @@ module ProblemsHelper @@ -6,21 +6,21 @@ module ProblemsHelper
6 def truncated_problem_message(problem) 6 def truncated_problem_message(problem)
7 unless (msg = problem.message).blank? 7 unless (msg = problem.message).blank?
8 # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule 8 # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule
9 - truncate(msg, :length => 300, :escape => false).scan(/.{1,5}/).map { |s| h(s) }.join("&#8203;").html_safe 9 + truncate(msg, length: 300, escape: false).scan(/.{1,5}/).map { |s| h(s) }.join("&#8203;").html_safe
10 end 10 end
11 end 11 end
12 12
13 def gravatar_tag(email, options = {}) 13 def gravatar_tag(email, options = {})
14 return nil unless email.present? 14 return nil unless email.present?
15 15
16 - image_tag gravatar_url(email, options), :alt => email, :class => 'gravatar' 16 + image_tag gravatar_url(email, options), alt: email, class: 'gravatar'
17 end 17 end
18 18
19 def gravatar_url(email, options = {}) 19 def gravatar_url(email, options = {})
20 return nil unless email.present? 20 return nil unless email.present?
21 21
22 default_options = { 22 default_options = {
23 - :d => Errbit::Config.gravatar_default, 23 + d: Errbit::Config.gravatar_default
24 } 24 }
25 options.reverse_merge! default_options 25 options.reverse_merge! default_options
26 params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? } 26 params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? }
app/helpers/sort_helper.rb
1 # encoding: utf-8 1 # encoding: utf-8
2 module SortHelper 2 module SortHelper
3 - def link_for_sort(name, field=nil) 3 + def link_for_sort(name, field = nil)
4 field ||= name.underscore 4 field ||= name.underscore
5 current = (params_sort == field) 5 current = (params_sort == field)
6 order = (current && (params_order == "asc")) ? "desc" : "asc" 6 order = (current && (params_order == "asc")) ? "desc" : "asc"
7 url = request.path + "?sort=#{field}&order=#{order}" 7 url = request.path + "?sort=#{field}&order=#{order}"
8 options = {} 8 options = {}
9 - options.merge!(:class => "current #{order}") if current 9 + options.merge!(class: "current #{order}") if current
10 link_to(name, url, options) 10 link_to(name, url, options)
11 end 11 end
12 end 12 end
app/interactors/problem_destroy.rb
@@ -20,7 +20,7 @@ class ProblemDestroy @@ -20,7 +20,7 @@ class ProblemDestroy
20 # the number of problem destroy 20 # the number of problem destroy
21 # 21 #
22 def self.execute(problems) 22 def self.execute(problems)
23 - Array(problems).each{ |problem| 23 + Array(problems).each { |problem|
24 ProblemDestroy.new(problem).execute 24 ProblemDestroy.new(problem).execute
25 }.count 25 }.count
26 end 26 end
@@ -36,11 +36,11 @@ private @@ -36,11 +36,11 @@ private
36 end 36 end
37 37
38 def delete_errs 38 def delete_errs
39 - Notice.delete_all(:err_id => { '$in' => errs_id })  
40 - Err.delete_all(:_id => { '$in' => errs_id }) 39 + Notice.delete_all(err_id: { '$in' => errs_id })
  40 + Err.delete_all(_id: { '$in' => errs_id })
41 end 41 end
42 42
43 def delete_comments 43 def delete_comments
44 - Comment.delete_all(:_id => { '$in' => comments_id }) 44 + Comment.delete_all(_id: { '$in' => comments_id })
45 end 45 end
46 end 46 end
app/interactors/problem_merge.rb
@@ -5,7 +5,7 @@ class ProblemMerge @@ -5,7 +5,7 @@ class ProblemMerge
5 problems = problems.flatten.uniq 5 problems = problems.flatten.uniq
6 @merged_problem = problems[0] 6 @merged_problem = problems[0]
7 @child_problems = problems[1..-1] 7 @child_problems = problems[1..-1]
8 - raise ArgumentError.new("need almost 2 uniq different problems") if @child_problems.empty? 8 + fail ArgumentError, "need almost 2 uniq different problems" if @child_problems.empty?
9 end 9 end
10 attr_reader :merged_problem, :child_problems 10 attr_reader :merged_problem, :child_problems
11 11
app/interactors/resolved_problem_clearer.rb
@@ -26,6 +26,6 @@ private @@ -26,6 +26,6 @@ private
26 end 26 end
27 27
28 def repair_database 28 def repair_database
29 - Mongoid.default_client.command :repairDatabase => 1 29 + Mongoid.default_client.command repairDatabase: 1
30 end 30 end
31 end 31 end
app/mailers/mailer.rb
@@ -5,12 +5,12 @@ require Rails.root.join(&#39;config/routes.rb&#39;) @@ -5,12 +5,12 @@ require Rails.root.join(&#39;config/routes.rb&#39;)
5 class Mailer < ActionMailer::Base 5 class Mailer < ActionMailer::Base
6 helper ApplicationHelper 6 helper ApplicationHelper
7 7
8 - default :from => Errbit::Config.email_from,  
9 - 'X-Errbit-Host' => Errbit::Config.host,  
10 - 'X-Mailer' => 'Errbit', 8 + default :from => Errbit::Config.email_from,
  9 + 'X-Errbit-Host' => Errbit::Config.host,
  10 + 'X-Mailer' => 'Errbit',
11 'X-Auto-Response-Suppress' => 'OOF, AutoReply', 11 'X-Auto-Response-Suppress' => 'OOF, AutoReply',
12 - 'Precedence' => 'bulk',  
13 - 'Auto-Submitted' => 'auto-generated' 12 + 'Precedence' => 'bulk',
  13 + 'Auto-Submitted' => 'auto-generated'
14 14
15 def err_notification(error_report) 15 def err_notification(error_report)
16 @notice = NoticeDecorator.new error_report.notice 16 @notice = NoticeDecorator.new error_report.notice
@@ -19,25 +19,25 @@ class Mailer &lt; ActionMailer::Base @@ -19,25 +19,25 @@ class Mailer &lt; ActionMailer::Base
19 count = error_report.problem.notices_count 19 count = error_report.problem.notices_count
20 count = count > 1 ? "(#{count}) " : "" 20 count = count > 1 ? "(#{count}) " : ""
21 21
22 - errbit_headers 'App' => @app.name, 22 + errbit_headers 'App' => @app.name,
23 'Environment' => @notice.environment_name, 23 'Environment' => @notice.environment_name,
24 - 'Error-Id' => @notice.err_id 24 + 'Error-Id' => @notice.err_id
25 25
26 - mail :to => @app.notification_recipients,  
27 - :subject => "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" 26 + mail to: @app.notification_recipients,
  27 + subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}"
28 end 28 end
29 29
30 def deploy_notification(deploy) 30 def deploy_notification(deploy)
31 @deploy = deploy 31 @deploy = deploy
32 @app = AppDecorator.new deploy.app 32 @app = AppDecorator.new deploy.app
33 33
34 - errbit_headers 'App' => @app.name,  
35 - 'Environment' => @deploy.environment, 34 + errbit_headers 'App' => @app.name,
  35 + 'Environment' => @deploy.environment,
36 'Deploy-Revision' => @deploy.revision, 36 'Deploy-Revision' => @deploy.revision,
37 - 'Deploy-User' => @deploy.username 37 + 'Deploy-User' => @deploy.username
38 38
39 - mail :to => @app.notification_recipients,  
40 - :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" 39 + mail to: @app.notification_recipients,
  40 + subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}"
41 end 41 end
42 42
43 def comment_notification(comment) 43 def comment_notification(comment)
@@ -49,13 +49,13 @@ class Mailer &lt; ActionMailer::Base @@ -49,13 +49,13 @@ class Mailer &lt; ActionMailer::Base
49 49
50 recipients = @comment.notification_recipients 50 recipients = @comment.notification_recipients
51 51
52 - errbit_headers 'App' => @app.name,  
53 - 'Environment' => @notice.environment_name,  
54 - 'Problem-Id' => @problem.id, 52 + errbit_headers 'App' => @app.name,
  53 + 'Environment' => @notice.environment_name,
  54 + 'Problem-Id' => @problem.id,
55 'Comment-Author' => @user.name 55 'Comment-Author' => @user.name
56 56
57 - mail :to => recipients,  
58 - :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" 57 + mail to: recipients,
  58 + subject: "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}"
59 end 59 end
60 60
61 private def errbit_headers(header) 61 private def errbit_headers(header)
app/models/app.rb
@@ -3,56 +3,59 @@ class App @@ -3,56 +3,59 @@ class App
3 include Mongoid::Document 3 include Mongoid::Document
4 include Mongoid::Timestamps 4 include Mongoid::Timestamps
5 5
6 - field :name, :type => String 6 + field :name, type: String
7 field :api_key 7 field :api_key
8 field :github_repo 8 field :github_repo
9 field :bitbucket_repo 9 field :bitbucket_repo
10 field :asset_host 10 field :asset_host
11 field :repository_branch 11 field :repository_branch
12 field :current_app_version 12 field :current_app_version
13 - field :resolve_errs_on_deploy, :type => Boolean, :default => false  
14 - field :notify_all_users, :type => Boolean, :default => false  
15 - field :notify_on_errs, :type => Boolean, :default => true  
16 - field :notify_on_deploys, :type => Boolean, :default => false  
17 - field :email_at_notices, :type => Array, :default => Errbit::Config.email_at_notices 13 + field :resolve_errs_on_deploy, type: Boolean, default: false
  14 + field :notify_all_users, type: Boolean, default: false
  15 + field :notify_on_errs, type: Boolean, default: true
  16 + field :notify_on_deploys, type: Boolean, default: false
  17 + field :email_at_notices, type: Array, default: Errbit::Config.email_at_notices
18 18
19 # Some legacy apps may have string as key instead of BSON::ObjectID 19 # Some legacy apps may have string as key instead of BSON::ObjectID
20 # identity :type => String 20 # identity :type => String
21 field :_id, 21 field :_id,
22 - type: String, 22 + type: String,
23 pre_processed: true, 23 pre_processed: true,
24 - default: ->{ BSON::ObjectId.new.to_s } 24 + default: -> { BSON::ObjectId.new.to_s }
25 25
26 embeds_many :watchers 26 embeds_many :watchers
27 embeds_many :deploys 27 embeds_many :deploys
28 - embeds_one :issue_tracker, :class_name => 'IssueTracker' 28 + embeds_one :issue_tracker, class_name: 'IssueTracker'
29 embeds_one :notification_service 29 embeds_one :notification_service
30 embeds_one :notice_fingerprinter, autobuild: true 30 embeds_one :notice_fingerprinter, autobuild: true
31 31
32 - has_many :problems, :inverse_of => :app, :dependent => :destroy 32 + has_many :problems, inverse_of: :app, dependent: :destroy
33 33
34 - before_validation :generate_api_key, :on => :create 34 + before_validation :generate_api_key, on: :create
35 before_save :normalize_github_repo 35 before_save :normalize_github_repo
36 after_update :store_cached_attributes_on_problems 36 after_update :store_cached_attributes_on_problems
37 37
38 validates_presence_of :name, :api_key 38 validates_presence_of :name, :api_key
39 - validates_uniqueness_of :name, :allow_blank => true  
40 - validates_uniqueness_of :api_key, :allow_blank => true 39 + validates_uniqueness_of :name, allow_blank: true
  40 + validates_uniqueness_of :api_key, allow_blank: true
41 validates_associated :watchers 41 validates_associated :watchers
42 validates_associated :notice_fingerprinter 42 validates_associated :notice_fingerprinter
43 validate :check_issue_tracker 43 validate :check_issue_tracker
44 44
45 - accepts_nested_attributes_for :watchers, :allow_destroy => true,  
46 - :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? }  
47 - accepts_nested_attributes_for :issue_tracker, :allow_destroy => true,  
48 - :reject_if => proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) }  
49 - accepts_nested_attributes_for :notification_service, :allow_destroy => true,  
50 - :reject_if => proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } 45 + accepts_nested_attributes_for :watchers,
  46 + allow_destroy: true,
  47 + reject_if: proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? }
  48 + accepts_nested_attributes_for :issue_tracker,
  49 + allow_destroy: true,
  50 + reject_if: proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) }
  51 + accepts_nested_attributes_for :notification_service,
  52 + allow_destroy: true,
  53 + reject_if: proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) }
51 accepts_nested_attributes_for :notice_fingerprinter 54 accepts_nested_attributes_for :notice_fingerprinter
52 55
53 - scope :watched_by, ->(user) do 56 + scope :watched_by, lambda { |user|
54 where watchers: { "$elemMatch" => { "user_id" => user.id } } 57 where watchers: { "$elemMatch" => { "user_id" => user.id } }
55 - end 58 + }
56 59
57 def watched_by?(user) 60 def watched_by?(user)
58 watchers.pluck("user_id").include? user.id 61 watchers.pluck("user_id").include? user.id
@@ -71,7 +74,7 @@ class App @@ -71,7 +74,7 @@ class App
71 problem = problems.create!( 74 problem = problems.create!(
72 error_class: attrs[:error_class], 75 error_class: attrs[:error_class],
73 environment: attrs[:environment], 76 environment: attrs[:environment],
74 - app_name: name 77 + app_name: name
75 ) 78 )
76 problem.errs.create!(attrs.slice(:fingerprint, :problem_id)) 79 problem.errs.create!(attrs.slice(:fingerprint, :problem_id))
77 end 80 end
@@ -82,7 +85,7 @@ class App @@ -82,7 +85,7 @@ class App
82 end 85 end
83 86
84 def self.find_by_api_key!(key) 87 def self.find_by_api_key!(key)
85 - find_by(:api_key => key) 88 + find_by(api_key: key)
86 end 89 end
87 90
88 def last_deploy_at 91 def last_deploy_at
@@ -151,7 +154,7 @@ class App @@ -151,7 +154,7 @@ class App
151 154
152 # Copy app attributes from another app. 155 # Copy app attributes from another app.
153 def copy_attributes_from(app_id) 156 def copy_attributes_from(app_id)
154 - if (copy_app = App.where(:_id => app_id).first) 157 + if (copy_app = App.where(_id: app_id).first)
155 # Copy fields 158 # Copy fields
156 (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| 159 (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k|
157 send("#{k}=", copy_app.send(k)) 160 send("#{k}=", copy_app.send(k))
@@ -191,7 +194,7 @@ class App @@ -191,7 +194,7 @@ class App
191 protected 194 protected
192 195
193 def store_cached_attributes_on_problems 196 def store_cached_attributes_on_problems
194 - Problem.where(:app_id => id).update_all( 197 + Problem.where(app_id: id).update_all(
195 app_name: name 198 app_name: name
196 ) 199 )
197 end 200 end
@@ -214,7 +217,7 @@ protected @@ -214,7 +217,7 @@ protected
214 github_host = URI.parse(Errbit::Config.github_url).host 217 github_host = URI.parse(Errbit::Config.github_url).host
215 github_host = Regexp.escape(github_host) 218 github_host = Regexp.escape(github_host)
216 github_repo.strip! 219 github_repo.strip!
217 - github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') 220 + github_repo.sub!(%r{(git@|https?://)#{github_host}(/|:)}, '')
218 github_repo.sub!(/\.git$/, '') 221 github_repo.sub!(/\.git$/, '')
219 end 222 end
220 end 223 end
app/models/backtrace.rb
@@ -8,14 +8,14 @@ class Backtrace @@ -8,14 +8,14 @@ class Backtrace
8 field :fingerprint 8 field :fingerprint
9 field :lines 9 field :lines
10 10
11 - index :fingerprint => 1 11 + index fingerprint: 1
12 12
13 def self.find_or_create(lines) 13 def self.find_or_create(lines)
14 fingerprint = generate_fingerprint(lines) 14 fingerprint = generate_fingerprint(lines)
15 15
16 where(fingerprint: fingerprint).find_one_and_update( 16 where(fingerprint: fingerprint).find_one_and_update(
17 { '$setOnInsert' => { fingerprint: fingerprint, lines: lines } }, 17 { '$setOnInsert' => { fingerprint: fingerprint, lines: lines } },
18 - { return_document: :after, upsert: true }) 18 + return_document: :after, upsert: true)
19 end 19 end
20 20
21 def self.generate_fingerprint(lines) 21 def self.generate_fingerprint(lines)
app/models/comment.rb
@@ -5,14 +5,14 @@ class Comment @@ -5,14 +5,14 @@ class Comment
5 after_create :increase_counter_cache 5 after_create :increase_counter_cache
6 before_destroy :decrease_counter_cache 6 before_destroy :decrease_counter_cache
7 7
8 - after_create :deliver_email, :if => :emailable? 8 + after_create :deliver_email, if: :emailable?
9 9
10 - field :body, :type => String  
11 - index(:user_id => 1) 10 + field :body, type: String
  11 + index(user_id: 1)
12 12
13 - belongs_to :err, :class_name => "Problem" 13 + belongs_to :err, class_name: "Problem"
14 belongs_to :user 14 belongs_to :user
15 - delegate :app, :to => :err 15 + delegate :app, to: :err
16 16
17 validates_presence_of :body 17 validates_presence_of :body
18 18
app/models/deploy.rb
@@ -8,18 +8,18 @@ class Deploy @@ -8,18 +8,18 @@ class Deploy
8 field :revision 8 field :revision
9 field :message 9 field :message
10 10
11 - index(:created_at => -1) 11 + index(created_at: -1)
12 12
13 - embedded_in :app, :inverse_of => :deploys 13 + embedded_in :app, inverse_of: :deploys
14 14
15 - after_create :resolve_app_errs, :if => :should_resolve_app_errs? 15 + after_create :resolve_app_errs, if: :should_resolve_app_errs?
16 after_create :store_cached_attributes_on_problems 16 after_create :store_cached_attributes_on_problems
17 after_create :deliver_email 17 after_create :deliver_email
18 18
19 validates_presence_of :username, :environment 19 validates_presence_of :username, :environment
20 20
21 def resolve_app_errs 21 def resolve_app_errs
22 - app.problems.unresolved.in_env(environment).each {|problem| problem.resolve!} 22 + app.problems.unresolved.in_env(environment).each(&:resolve!)
23 end 23 end
24 24
25 def short_revision 25 def short_revision
@@ -33,7 +33,7 @@ protected @@ -33,7 +33,7 @@ protected
33 end 33 end
34 34
35 def store_cached_attributes_on_problems 35 def store_cached_attributes_on_problems
36 - Problem.where(:app_id => app.id).update_all( 36 + Problem.where(app_id: app.id).update_all(
37 last_deploy_at: created_at 37 last_deploy_at: created_at
38 ) 38 )
39 end 39 end
app/models/err.rb
@@ -12,9 +12,9 @@ class Err @@ -12,9 +12,9 @@ class Err
12 index fingerprint: 1 12 index fingerprint: 1
13 13
14 belongs_to :problem 14 belongs_to :problem
15 - has_many :notices, :inverse_of => :err, :dependent => :destroy 15 + has_many :notices, inverse_of: :err, dependent: :destroy
16 16
17 validates_presence_of :problem_id, :fingerprint 17 validates_presence_of :problem_id, :fingerprint
18 18
19 - delegate :app, :resolved?, :to => :problem 19 + delegate :app, :resolved?, to: :problem
20 end 20 end
app/models/error_report.rb
@@ -61,15 +61,15 @@ class ErrorReport @@ -61,15 +61,15 @@ class ErrorReport
61 61
62 def make_notice 62 def make_notice
63 @notice = Notice.new( 63 @notice = Notice.new(
64 - app: app,  
65 - message: message,  
66 - error_class: error_class,  
67 - backtrace: backtrace,  
68 - request: request, 64 + app: app,
  65 + message: message,
  66 + error_class: error_class,
  67 + backtrace: backtrace,
  68 + request: request,
69 server_environment: server_environment, 69 server_environment: server_environment,
70 - notifier: notifier,  
71 - user_attributes: user_attributes,  
72 - framework: framework 70 + notifier: notifier,
  71 + user_attributes: user_attributes,
  72 + framework: framework
73 ) 73 )
74 end 74 end
75 75
app/models/issue.rb
@@ -14,7 +14,7 @@ class Issue @@ -14,7 +14,7 @@ class Issue
14 if tracker.respond_to?(:render_body_args) 14 if tracker.respond_to?(:render_body_args)
15 tracker.render_body_args 15 tracker.render_body_args
16 else 16 else
17 - [ 'issue_trackers/issue', formats: [:md] ] 17 + ['issue_trackers/issue', formats: [:md]]
18 end 18 end
19 end 19 end
20 20
app/models/issue_tracker.rb
@@ -2,10 +2,10 @@ class IssueTracker @@ -2,10 +2,10 @@ class IssueTracker
2 include Mongoid::Document 2 include Mongoid::Document
3 include Mongoid::Timestamps 3 include Mongoid::Timestamps
4 4
5 - embedded_in :app, :inverse_of => :issue_tracker 5 + embedded_in :app, inverse_of: :issue_tracker
6 6
7 - field :type_tracker, :type => String  
8 - field :options, :type => Hash, :default => {} 7 + field :type_tracker, type: String
  8 + field :options, type: Hash, default: {}
9 9
10 validate :validate_tracker 10 validate :validate_tracker
11 11
@@ -15,7 +15,7 @@ class IssueTracker @@ -15,7 +15,7 @@ class IssueTracker
15 klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker 15 klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker
16 # TODO: we need to find out a better way to pass those config to the issue tracker 16 # TODO: we need to find out a better way to pass those config to the issue tracker
17 klass.new(options.merge( 17 klass.new(options.merge(
18 - github_repo: app.try(:github_repo), 18 + github_repo: app.try(:github_repo),
19 bitbucket_repo: app.try(:bitbucket_repo) 19 bitbucket_repo: app.try(:bitbucket_repo)
20 )) 20 ))
21 end 21 end
@@ -32,7 +32,7 @@ class IssueTracker @@ -32,7 +32,7 @@ class IssueTracker
32 end 32 end
33 end 33 end
34 34
35 - delegate :configured?, :to => :tracker  
36 - delegate :create_issue, :to => :tracker  
37 - delegate :url, :to => :tracker 35 + delegate :configured?, to: :tracker
  36 + delegate :create_issue, to: :tracker
  37 + delegate :url, to: :tracker
38 end 38 end
app/models/notice.rb
@@ -5,30 +5,30 @@ class Notice @@ -5,30 +5,30 @@ class Notice
5 include Mongoid::Timestamps 5 include Mongoid::Timestamps
6 6
7 field :message 7 field :message
8 - field :server_environment, :type => Hash  
9 - field :request, :type => Hash  
10 - field :notifier, :type => Hash  
11 - field :user_attributes, :type => Hash 8 + field :server_environment, type: Hash
  9 + field :request, type: Hash
  10 + field :notifier, type: Hash
  11 + field :user_attributes, type: Hash
12 field :framework 12 field :framework
13 field :error_class 13 field :error_class
14 - delegate :lines, :to => :backtrace, :prefix => true  
15 - delegate :problem, :to => :err 14 + delegate :lines, to: :backtrace, prefix: true
  15 + delegate :problem, to: :err
16 16
17 belongs_to :app 17 belongs_to :app
18 belongs_to :err 18 belongs_to :err
19 - belongs_to :backtrace, :index => true 19 + belongs_to :backtrace, index: true
20 20
21 - index(:created_at => 1)  
22 - index(:err_id => 1, :created_at => 1, :_id => 1) 21 + index(created_at: 1)
  22 + index(err_id: 1, created_at: 1, _id: 1)
23 23
24 before_save :sanitize 24 before_save :sanitize
25 before_destroy :problem_recache 25 before_destroy :problem_recache
26 26
27 validates_presence_of :backtrace_id, :server_environment, :notifier 27 validates_presence_of :backtrace_id, :server_environment, :notifier
28 28
29 - scope :ordered, ->{ order_by(:created_at.asc) }  
30 - scope :reverse_ordered, ->{ order_by(:created_at.desc) }  
31 - scope :for_errs, Proc.new { |errs| 29 + scope :ordered, -> { order_by(:created_at.asc) }
  30 + scope :reverse_ordered, -> { order_by(:created_at.desc) }
  31 + scope :for_errs, lambda { |errs|
32 where(:err_id.in => errs.all.map(&:id)) 32 where(:err_id.in => errs.all.map(&:id))
33 } 33 }
34 34
app/models/notice_fingerprinter.rb
@@ -14,7 +14,7 @@ class NoticeFingerprinter @@ -14,7 +14,7 @@ class NoticeFingerprinter
14 embedded_in :site_config 14 embedded_in :site_config
15 15
16 def generate(api_key, notice, backtrace) 16 def generate(api_key, notice, backtrace)
17 - material = [ api_key ] 17 + material = [api_key]
18 material << notice.error_class if error_class 18 material << notice.error_class if error_class
19 material << notice.filtered_message if message 19 material << notice.filtered_message if message
20 material << notice.component if component 20 material << notice.component if component
@@ -27,6 +27,6 @@ class NoticeFingerprinter @@ -27,6 +27,6 @@ class NoticeFingerprinter
27 material << backtrace.lines.slice(0, backtrace_lines) 27 material << backtrace.lines.slice(0, backtrace_lines)
28 end 28 end
29 29
30 - Digest::MD5.hexdigest(material.reduce('') { |c, m| c << m.to_s; c }) 30 + Digest::MD5.hexdigest(material.map(&:to_s).join)
31 end 31 end
32 end 32 end
app/models/notification_service.rb
@@ -5,26 +5,26 @@ class NotificationService @@ -5,26 +5,26 @@ class NotificationService
5 default_url_options[:host] = ActionMailer::Base.default_url_options[:host] 5 default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
6 default_url_options[:port] = ActionMailer::Base.default_url_options[:port] 6 default_url_options[:port] = ActionMailer::Base.default_url_options[:port]
7 7
8 - field :room_id, :type => String  
9 - field :user_id, :type => String  
10 - field :service_url, :type => String  
11 - field :service, :type => String  
12 - field :api_token, :type => String  
13 - field :subdomain, :type => String  
14 - field :sender_name, :type => String  
15 - field :notify_at_notices, :type => Array, :default => Errbit::Config.notify_at_notices  
16 - embedded_in :app, :inverse_of => :notification_service 8 + field :room_id, type: String
  9 + field :user_id, type: String
  10 + field :service_url, type: String
  11 + field :service, type: String
  12 + field :api_token, type: String
  13 + field :subdomain, type: String
  14 + field :sender_name, type: String
  15 + field :notify_at_notices, type: Array, default: Errbit::Config.notify_at_notices
  16 + embedded_in :app, inverse_of: :notification_service
17 17
18 validate :check_params 18 validate :check_params
19 19
20 if Errbit::Config.per_app_notify_at_notices 20 if Errbit::Config.per_app_notify_at_notices
21 - Fields = [[:notify_at_notices,  
22 - { :placeholder => 'comma separated numbers or simply 0 for every notice',  
23 - :label => 'notify on errors (0 for all errors)' 21 + FIELDS = [[:notify_at_notices,
  22 + { placeholder: 'comma separated numbers or simply 0 for every notice',
  23 + label: 'notify on errors (0 for all errors)'
24 } 24 }
25 ]] 25 ]]
26 else 26 else
27 - Fields = [] 27 + FIELDS = []
28 end 28 end
29 29
30 def notify_at_notices 30 def notify_at_notices
@@ -32,22 +32,36 @@ class NotificationService @@ -32,22 +32,36 @@ class NotificationService
32 end 32 end
33 33
34 # Subclasses are responsible for overwriting this method. 34 # Subclasses are responsible for overwriting this method.
35 - def check_params; true; end 35 + def check_params
  36 + true
  37 + end
36 38
37 def notification_description(problem) 39 def notification_description(problem)
38 "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" 40 "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}"
39 end 41 end
40 42
41 # Allows us to set the issue tracker class from a single form. 43 # Allows us to set the issue tracker class from a single form.
42 - def type; _type; end  
43 - def type=(t); self._type = t; end 44 + def type
  45 + _type
  46 + end
  47 +
  48 + def type=(t)
  49 + self._type = t
  50 + end
44 51
45 - def url; nil; end 52 + def url
  53 + nil
  54 + end
46 55
47 # Retrieve tracker label from either class or instance. 56 # Retrieve tracker label from either class or instance.
48 - Label = ''  
49 - def self.label; self::Label; end  
50 - def label; self.class.label; end 57 + LABEL = ''
  58 + def self.label
  59 + self::LABEL
  60 + end
  61 +
  62 + def label
  63 + self.class.label
  64 + end
51 65
52 def configured? 66 def configured?
53 api_token.present? 67 api_token.present?
app/models/notification_services/campfire_service.rb
1 if defined? Campy 1 if defined? Campy
2 class NotificationServices::CampfireService < NotificationService 2 class NotificationServices::CampfireService < NotificationService
3 - Label = "campfire"  
4 - Fields += [ 3 + LABEL = "campfire"
  4 + FIELDS += [
5 [:subdomain, { 5 [:subdomain, {
6 - :label => "Subdomain",  
7 - :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" 6 + label: "Subdomain",
  7 + placeholder: "subdomain from http://{{subdomain}}.campfirenow.com"
8 }], 8 }],
9 [:api_token, { 9 [:api_token, {
10 - :label => "API Token",  
11 - :placeholder => "123456789abcdef123456789abcdef" 10 + label: "API Token",
  11 + placeholder: "123456789abcdef123456789abcdef"
12 }], 12 }],
13 [:room_id, { 13 [:room_id, {
14 - :label => "Room ID",  
15 - :placeholder => "123456" 14 + label: "Room ID",
  15 + placeholder: "123456"
16 }] 16 }]
17 ] 17 ]
18 18
19 def check_params 19 def check_params
20 - if Fields.detect {|f| self[f[0]].blank? } 20 + if FIELDS.detect { |f| self[f[0]].blank? }
21 errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' 21 errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID'
22 end 22 end
23 end 23 end
@@ -28,7 +28,7 @@ if defined? Campy @@ -28,7 +28,7 @@ if defined? Campy
28 28
29 def create_notification(problem) 29 def create_notification(problem)
30 # build the campfire client 30 # build the campfire client
31 - campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id) 31 + campy = Campy::Room.new(account: subdomain, token: api_token, room_id: room_id)
32 # post the issue to the campfire room 32 # post the issue to the campfire room
33 campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" 33 campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}"
34 end 34 end
app/models/notification_services/flowdock_service.rb
1 if defined? Flowdock 1 if defined? Flowdock
2 class NotificationServices::FlowdockService < NotificationService 2 class NotificationServices::FlowdockService < NotificationService
3 - Label = 'flowdock'  
4 - Fields += [ 3 + LABEL = 'flowdock'
  4 + FIELDS += [
5 [ 5 [
6 :api_token, { 6 :api_token, {
7 - :label => 'Flow API Token',  
8 - :placeholder => '123456789abcdef123456789abcdefgh' 7 + label: 'Flow API Token',
  8 + placeholder: '123456789abcdef123456789abcdefgh'
9 } 9 }
10 ] 10 ]
11 ] 11 ]
12 12
13 def check_params 13 def check_params
14 - if Fields.any? { |f, _| self[f].blank? } 14 + if FIELDS.any? { |f, _| self[f].blank? }
15 errors.add :base, 'You must specify your Flowdock(Flow) API token' 15 errors.add :base, 'You must specify your Flowdock(Flow) API token'
16 end 16 end
17 end 17 end
@@ -21,10 +21,22 @@ if defined? Flowdock @@ -21,10 +21,22 @@ if defined? Flowdock
21 end 21 end
22 22
23 def create_notification(problem) 23 def create_notification(problem)
24 - flow = Flowdock::Flow.new(:api_token => api_token, :source => "Errbit", :from => {:name => "Errbit", :address => ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com'}) 24 + flow = Flowdock::Flow.new(
  25 + api_token: api_token,
  26 + source: "Errbit",
  27 + from: {
  28 + name: "Errbit",
  29 + address: ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com'
  30 + }
  31 + )
25 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}" 32 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}"
26 url = app_problem_url problem.app, problem 33 url = app_problem_url problem.app, problem
27 - flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) 34 + flow.push_to_team_inbox(
  35 + subject: subject,
  36 + content: content(problem, url),
  37 + project: project_name(problem),
  38 + link: url
  39 + )
28 end 40 end
29 41
30 private 42 private
app/models/notification_services/gtalk_service.rb
1 class NotificationServices::GtalkService < NotificationService 1 class NotificationServices::GtalkService < NotificationService
2 - Label = "gtalk"  
3 - Fields += [ 2 + LABEL = "gtalk"
  3 + FIELDS += [
4 [:subdomain, { 4 [:subdomain, {
5 - :placeholder => "username@example.com",  
6 - :label => "Username" 5 + placeholder: "username@example.com",
  6 + label: "Username"
7 }], 7 }],
8 [:api_token, { 8 [:api_token, {
9 - :placeholder => "password",  
10 - :label => "Password" 9 + placeholder: "password",
  10 + label: "Password"
11 }], 11 }],
12 [:user_id, { 12 [:user_id, {
13 - :placeholder => "touser@example.com, anotheruser@example.com",  
14 - :label => "Send To User(s)" 13 + placeholder: "touser@example.com, anotheruser@example.com",
  14 + label: "Send To User(s)"
15 }, :room_id], 15 }, :room_id],
16 [:room_id, { 16 [:room_id, {
17 - :placeholder => "toroom@conference.example.com",  
18 - :label => "Send To Room (one only)" 17 + placeholder: "toroom@conference.example.com",
  18 + label: "Send To Room (one only)"
19 }, :user_id], 19 }, :user_id],
20 - [ :service, {  
21 - :placeholder => "talk.google.com",  
22 - :label => "Jabber Service" 20 + [:service, {
  21 + placeholder: "talk.google.com",
  22 + label: "Jabber Service"
23 }], 23 }],
24 - [ :service_url, {  
25 - :placeholder => "http://www.google.com/talk/",  
26 - :label => "Link To Jabber Service" 24 + [:service_url, {
  25 + placeholder: "http://www.google.com/talk/",
  26 + label: "Link To Jabber Service"
27 }] 27 }]
28 ] 28 ]
29 29
30 def check_params 30 def check_params
31 - if Fields.detect { |f| self[f[0]].blank? && self[f[2]].blank? }  
32 - errors.add :base,  
33 - """You must specify your Username, Password, service, service_url 31 + if FIELDS.detect { |f| self[f[0]].blank? && self[f[2]].blank? }
  32 + errors.add :base,
  33 + """You must specify your Username, Password, service, service_url
34 and either rooms or users to send to or both""" 34 and either rooms or users to send to or both"""
35 end 35 end
36 end 36 end
@@ -58,7 +58,7 @@ class NotificationServices::GtalkService &lt; NotificationService @@ -58,7 +58,7 @@ class NotificationServices::GtalkService &lt; NotificationService
58 end 58 end
59 59
60 private 60 private
61 - 61 +
62 def send_to_users(client, message) 62 def send_to_users(client, message)
63 user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user| 63 user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user|
64 client.send(Jabber::Message.new(user, message)) 64 client.send(Jabber::Message.new(user, message))
@@ -66,9 +66,9 @@ private @@ -66,9 +66,9 @@ private
66 end 66 end
67 67
68 def send_to_muc(client, message) 68 def send_to_muc(client, message)
69 - #TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment 69 + #TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment
70 muc = Jabber::MUC::SimpleMUCClient.new(client) 70 muc = Jabber::MUC::SimpleMUCClient.new(client)
71 - muc.join(room_id + "/errbit") 71 + muc.join(room_id + "/errbit")
72 muc.send(Jabber::Message.new(room_id, message)) 72 muc.send(Jabber::Message.new(room_id, message))
73 end 73 end
74 end 74 end
app/models/notification_services/hipchat_service.rb
1 if defined? HipChat 1 if defined? HipChat
2 class NotificationServices::HipchatService < NotificationService 2 class NotificationServices::HipchatService < NotificationService
3 - Label = 'hipchat'  
4 - Fields += [ 3 + LABEL = 'hipchat'
  4 + FIELDS += [
5 [:service, { 5 [:service, {
6 - :placeholder => "'v1' (admin API token) or 'v2' (account API token)",  
7 - :label => "HipChat API version" 6 + placeholder: "'v1' (admin API token) or 'v2' (account API token)",
  7 + label: "HipChat API version"
8 }], 8 }],
9 [:service_url, { 9 [:service_url, {
10 - :placeholder => "Optional, leave empty for HipChat.com",  
11 - :label => "Custom HipChat Server URL" 10 + placeholder: "Optional, leave empty for HipChat.com",
  11 + label: "Custom HipChat Server URL"
12 }], 12 }],
13 [:api_token, { 13 [:api_token, {
14 - :placeholder => "API token",  
15 - :label => "API token" 14 + placeholder: "API token",
  15 + label: "API token"
16 }], 16 }],
17 [:room_id, { 17 [:room_id, {
18 - :placeholder => "Room name",  
19 - :label => "Room name"  
20 - }], 18 + placeholder: "Room name",
  19 + label: "Room name"
  20 + }]
21 ] 21 ]
22 - Mandatory_fields = [:service, :api_token, :room_id]  
23 - API_versions = %w(v1 v2) 22 + MANDATORY_FIELDS = [:service, :api_token, :room_id]
  23 + API_VERSIONS = %w(v1 v2)
24 24
25 def check_params 25 def check_params
26 - Fields.each do |field, hash|  
27 - if Mandatory_fields.include?(field) && self[field].blank? 26 + FIELDS.each do |field, hash|
  27 + if MANDATORY_FIELDS.include?(field) && self[field].blank?
28 errors.add field, "You must specify #{hash[:label]}" 28 errors.add field, "You must specify #{hash[:label]}"
29 end 29 end
30 end 30 end
31 - unless API_versions.include?(self[:service])  
32 - errors.add :service, "API version must be #{API_versions.join(' or ')}" 31 + unless API_VERSIONS.include?(self[:service])
  32 + errors.add :service, "API version must be #{API_VERSIONS.join(' or ')}"
33 end 33 end
34 end 34 end
35 35
@@ -45,11 +45,11 @@ if defined? HipChat @@ -45,11 +45,11 @@ if defined? HipChat
45 &nbsp;&nbsp;Times occurred: #{problem.notices_count} 45 &nbsp;&nbsp;Times occurred: #{problem.notices_count}
46 MSG 46 MSG
47 47
48 - options = { :api_version => self[:service] } 48 + options = { api_version: self[:service] }
49 options[:server_url] = self[:service_url] if service_url.present? 49 options[:server_url] = self[:service_url] if service_url.present?
50 50
51 client = HipChat::Client.new(api_token, options) 51 client = HipChat::Client.new(api_token, options)
52 - client[room_id].send('Errbit', message, :color => 'red', :notify => true) 52 + client[room_id].send('Errbit', message, color: 'red', notify: true)
53 end 53 end
54 end 54 end
55 end 55 end
app/models/notification_services/hoiio_service.rb
1 class NotificationServices::HoiioService < NotificationService 1 class NotificationServices::HoiioService < NotificationService
2 - Label = "hoiio"  
3 - Fields += [ 2 + LABEL = "hoiio"
  3 + FIELDS += [
4 [:api_token, { 4 [:api_token, {
5 - :placeholder => "App ID",  
6 - :label => "App ID" 5 + placeholder: "App ID",
  6 + label: "App ID"
7 }], 7 }],
8 [:subdomain, { 8 [:subdomain, {
9 - :placeholder => "Access Token",  
10 - :label => "Access Token" 9 + placeholder: "Access Token",
  10 + label: "Access Token"
11 }], 11 }],
12 [:room_id, { 12 [:room_id, {
13 - :placeholder => "+6511111111, +6511111111",  
14 - :label => "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code." 13 + placeholder: "+6511111111, +6511111111",
  14 + label: "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code."
15 }] 15 }]
16 ] 16 ]
17 17
18 def check_params 18 def check_params
19 - if Fields.detect {|f| self[f[0]].blank? } 19 + if FIELDS.detect { |f| self[f[0]].blank? }
20 errors.add :base, 'You must specify your App ID, Access Token and Recipient\'s phone numbers' 20 errors.add :base, 'You must specify your App ID, Access Token and Recipient\'s phone numbers'
21 end 21 end
22 end 22 end
@@ -35,7 +35,7 @@ class NotificationServices::HoiioService &lt; NotificationService @@ -35,7 +35,7 @@ class NotificationServices::HoiioService &lt; NotificationService
35 35
36 # send sms 36 # send sms
37 room_id.split(',').each do |number| 37 room_id.split(',').each do |number|
38 - sms.send :dest => number, :msg => "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}" 38 + sms.send dest: number, msg: "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}"
39 end 39 end
40 end 40 end
41 end 41 end
app/models/notification_services/hubot_service.rb
1 class NotificationServices::HubotService < NotificationService 1 class NotificationServices::HubotService < NotificationService
2 - Label = "hubot"  
3 - Fields += [ 2 + LABEL = "hubot"
  3 + FIELDS += [
4 [:api_token, { 4 [:api_token, {
5 - :placeholder => 'http://hubot.example.org:8080/hubot/say',  
6 - :label => 'Hubot URL' 5 + placeholder: 'http://hubot.example.org:8080/hubot/say',
  6 + label: 'Hubot URL'
7 }], 7 }],
8 [:room_id, { 8 [:room_id, {
9 - :placeholder => '#dev',  
10 - :label => 'Room where Hubot should notify' 9 + placeholder: '#dev',
  10 + label: 'Room where Hubot should notify'
11 }] 11 }]
12 ] 12 ]
13 13
14 def check_params 14 def check_params
15 - if Fields.detect {|f| self[f[0]].blank? } 15 + if FIELDS.detect { |f| self[f[0]].blank? }
16 errors.add :base, 'You must specify the URL of your hubot' 16 errors.add :base, 'You must specify the URL of your hubot'
17 end 17 end
18 end 18 end
@@ -26,6 +26,6 @@ class NotificationServices::HubotService &lt; NotificationService @@ -26,6 +26,6 @@ class NotificationServices::HubotService &lt; NotificationService
26 end 26 end
27 27
28 def create_notification(problem) 28 def create_notification(problem)
29 - HTTParty.post(url, :body => {:message => message_for_hubot(problem), :room => room_id}) 29 + HTTParty.post(url, body: { message: message_for_hubot(problem), room: room_id })
30 end 30 end
31 end 31 end
app/models/notification_services/pushover_service.rb
1 class NotificationServices::PushoverService < NotificationService 1 class NotificationServices::PushoverService < NotificationService
2 - Label = "pushover"  
3 - Fields += [ 2 + LABEL = "pushover"
  3 + FIELDS += [
4 [:api_token, { 4 [:api_token, {
5 - :placeholder => "User Key",  
6 - :label => "User Key" 5 + placeholder: "User Key",
  6 + label: "User Key"
7 }], 7 }],
8 [:subdomain, { 8 [:subdomain, {
9 - :placeholder => "Application API Token",  
10 - :label => "Application API Token" 9 + placeholder: "Application API Token",
  10 + label: "Application API Token"
11 }] 11 }]
12 ] 12 ]
13 13
14 def check_params 14 def check_params
15 - if Fields.detect {|f| self[f[0]].blank? } 15 + if FIELDS.detect { |f| self[f[0]].blank? }
16 errors.add :base, 'You must specify your User Key and Application API Token.' 16 errors.add :base, 'You must specify your User Key and Application API Token.'
17 end 17 end
18 end 18 end
@@ -26,6 +26,6 @@ class NotificationServices::PushoverService &lt; NotificationService @@ -26,6 +26,6 @@ class NotificationServices::PushoverService &lt; NotificationService
26 notification = Rushover::Client.new(subdomain) 26 notification = Rushover::Client.new(subdomain)
27 27
28 # send push notification to pushover 28 # send push notification to pushover
29 - notification.notify(api_token, "#{notification_description problem}", :priority => 1, :title => "Errbit Notification", :url => "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}", :url_title => "Link to error") 29 + notification.notify(api_token, "#{notification_description problem}", priority: 1, title: "Errbit Notification", url: "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}", url_title: "Link to error")
30 end 30 end
31 end 31 end
app/models/notification_services/slack_service.rb
1 class NotificationServices::SlackService < NotificationService 1 class NotificationServices::SlackService < NotificationService
2 - Label = "slack"  
3 - Fields += [ 2 + LABEL = "slack"
  3 + FIELDS += [
4 [:service_url, { 4 [:service_url, {
5 - :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)',  
6 - :label => 'Hook URL' 5 + placeholder: 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)',
  6 + label: 'Hook URL'
7 }] 7 }]
8 ] 8 ]
9 9
10 def check_params 10 def check_params
11 - if Fields.detect {|f| self[f[0]].blank? } 11 + if FIELDS.detect { |f| self[f[0]].blank? }
12 errors.add :base, "You must specify your Slack Hook url." 12 errors.add :base, "You must specify your Slack Hook url."
13 end 13 end
14 end 14 end
@@ -19,41 +19,41 @@ class NotificationServices::SlackService &lt; NotificationService @@ -19,41 +19,41 @@ class NotificationServices::SlackService &lt; NotificationService
19 19
20 def post_payload(problem) 20 def post_payload(problem)
21 { 21 {
22 - :attachments => [ 22 + attachments: [
23 { 23 {
24 - :fallback => message_for_slack(problem),  
25 - :pretext => "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>",  
26 - :color => "#D00000",  
27 - :fields => [ 24 + fallback: message_for_slack(problem),
  25 + pretext: "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>",
  26 + color: "#D00000",
  27 + fields: [
28 { 28 {
29 - :title => "Environment",  
30 - :value => problem.environment,  
31 - :short => false 29 + title: "Environment",
  30 + value: problem.environment,
  31 + short: false
32 }, 32 },
33 { 33 {
34 - :title => "Location",  
35 - :value => problem.where,  
36 - :short => false 34 + title: "Location",
  35 + value: problem.where,
  36 + short: false
37 }, 37 },
38 { 38 {
39 - :title => "Message",  
40 - :value => problem.message.to_s,  
41 - :short => false 39 + title: "Message",
  40 + value: problem.message.to_s,
  41 + short: false
42 }, 42 },
43 { 43 {
44 - :title => "First Noticed",  
45 - :value => problem.first_notice_at,  
46 - :short => false 44 + title: "First Noticed",
  45 + value: problem.first_notice_at,
  46 + short: false
47 }, 47 },
48 { 48 {
49 - :title => "Last Noticed",  
50 - :value => problem.last_notice_at,  
51 - :short => false 49 + title: "Last Noticed",
  50 + value: problem.last_notice_at,
  51 + short: false
52 }, 52 },
53 { 53 {
54 - :title => "Times Occurred",  
55 - :value => problem.notices_count,  
56 - :short => false 54 + title: "Times Occurred",
  55 + value: problem.notices_count,
  56 + short: false
57 } 57 }
58 ] 58 ]
59 } 59 }
@@ -62,7 +62,13 @@ class NotificationServices::SlackService &lt; NotificationService @@ -62,7 +62,13 @@ class NotificationServices::SlackService &lt; NotificationService
62 end 62 end
63 63
64 def create_notification(problem) 64 def create_notification(problem)
65 - HTTParty.post(service_url, :body => post_payload(problem), :headers => { 'Content-Type' => 'application/json' }) 65 + HTTParty.post(
  66 + service_url,
  67 + body: post_payload(problem),
  68 + headers: {
  69 + 'Content-Type' => 'application/json'
  70 + }
  71 + )
66 end 72 end
67 73
68 def configured? 74 def configured?
app/models/notification_services/webhook_service.rb
1 class NotificationServices::WebhookService < NotificationService 1 class NotificationServices::WebhookService < NotificationService
2 - Label = "webhook"  
3 - Fields = [ 2 + LABEL = "webhook"
  3 + FIELDS = [
4 [:api_token, { 4 [:api_token, {
5 - :placeholder => 'URL to receive a POST request when an error occurs',  
6 - :label => 'URL' 5 + placeholder: 'URL to receive a POST request when an error occurs',
  6 + label: 'URL'
7 }] 7 }]
8 ] 8 ]
9 9
10 def check_params 10 def check_params
11 - if Fields.detect {|f| self[f[0]].blank? } 11 + if FIELDS.detect { |f| self[f[0]].blank? }
12 errors.add :base, 'You must specify the URL' 12 errors.add :base, 'You must specify the URL'
13 end 13 end
14 end 14 end
15 15
16 def message_for_webhook(problem) 16 def message_for_webhook(problem)
17 - {:problem => {:url => problem_url(problem)}.merge(problem.as_json).to_json} 17 + {
  18 + problem: {
  19 + url: problem_url(problem)
  20 + }.merge(problem.as_json).to_json
  21 + }
18 end 22 end
19 23
20 def create_notification(problem) 24 def create_notification(problem)
21 - HTTParty.post(api_token, :body => message_for_webhook(problem)) 25 + HTTParty.post(api_token, body: message_for_webhook(problem))
22 end 26 end
23 end 27 end
app/models/problem.rb
@@ -7,61 +7,61 @@ class Problem @@ -7,61 +7,61 @@ class Problem
7 include Mongoid::Timestamps 7 include Mongoid::Timestamps
8 8
9 CACHED_NOTICE_ATTRIBUTES = { 9 CACHED_NOTICE_ATTRIBUTES = {
10 - messages: :message,  
11 - hosts: :host, 10 + messages: :message,
  11 + hosts: :host,
12 user_agents: :user_agent_string 12 user_agents: :user_agent_string
13 }.freeze 13 }.freeze
14 14
15 - field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now }  
16 - field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now }  
17 - field :last_deploy_at, :type => Time  
18 - field :resolved, :type => Boolean, :default => false  
19 - field :resolved_at, :type => Time  
20 - field :issue_link, :type => String  
21 - field :issue_type, :type => String 15 + field :last_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now }
  16 + field :first_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now }
  17 + field :last_deploy_at, type: Time
  18 + field :resolved, type: Boolean, default: false
  19 + field :resolved_at, type: Time
  20 + field :issue_link, type: String
  21 + field :issue_type, type: String
22 22
23 # Cached fields 23 # Cached fields
24 - field :app_name, :type => String  
25 - field :notices_count, :type => Integer, :default => 0 24 + field :app_name, type: String
  25 + field :notices_count, type: Integer, default: 0
26 field :message 26 field :message
27 field :environment 27 field :environment
28 field :error_class 28 field :error_class
29 field :where 29 field :where
30 - field :user_agents, :type => Hash, :default => {}  
31 - field :messages, :type => Hash, :default => {}  
32 - field :hosts, :type => Hash, :default => {}  
33 - field :comments_count, :type => Integer, :default => 0  
34 -  
35 - index :app_id => 1  
36 - index :app_name => 1  
37 - index :message => 1  
38 - index :last_notice_at => 1  
39 - index :first_notice_at => 1  
40 - index :last_deploy_at => 1  
41 - index :resolved_at => 1  
42 - index :notices_count => 1 30 + field :user_agents, type: Hash, default: {}
  31 + field :messages, type: Hash, default: {}
  32 + field :hosts, type: Hash, default: {}
  33 + field :comments_count, type: Integer, default: 0
  34 +
  35 + index app_id: 1
  36 + index app_name: 1
  37 + index message: 1
  38 + index last_notice_at: 1
  39 + index first_notice_at: 1
  40 + index last_deploy_at: 1
  41 + index resolved_at: 1
  42 + index notices_count: 1
43 43
44 index({ 44 index({
45 error_class: "text", 45 error_class: "text",
46 - where: "text",  
47 - message: "text",  
48 - app_name: "text", 46 + where: "text",
  47 + message: "text",
  48 + app_name: "text",
49 environment: "text" 49 environment: "text"
50 }, default_language: "english") 50 }, default_language: "english")
51 51
52 belongs_to :app 52 belongs_to :app
53 - has_many :errs, :inverse_of => :problem, :dependent => :destroy  
54 - has_many :comments, :inverse_of => :err, :dependent => :destroy 53 + has_many :errs, inverse_of: :problem, dependent: :destroy
  54 + has_many :comments, inverse_of: :err, dependent: :destroy
55 55
56 validates_presence_of :environment 56 validates_presence_of :environment
57 57
58 before_create :cache_app_attributes 58 before_create :cache_app_attributes
59 before_save :truncate_message 59 before_save :truncate_message
60 60
61 - scope :resolved, ->{ where(:resolved => true) }  
62 - scope :unresolved, ->{ where(:resolved => false) }  
63 - scope :ordered, ->{ order_by(:last_notice_at.desc) }  
64 - scope :for_apps, lambda {|apps| where(:app_id.in => apps.all.map(&:id))} 61 + scope :resolved, -> { where(resolved: true) }
  62 + scope :unresolved, -> { where(resolved: false) }
  63 + scope :ordered, -> { order_by(:last_notice_at.desc) }
  64 + scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) }
65 65
66 validates_presence_of :last_notice_at, :first_notice_at 66 validates_presence_of :last_notice_at, :first_notice_at
67 67
@@ -69,12 +69,12 @@ class Problem @@ -69,12 +69,12 @@ class Problem
69 if fetch_all 69 if fetch_all
70 all 70 all
71 else 71 else
72 - where(:resolved => false) 72 + where(resolved: false)
73 end 73 end
74 end 74 end
75 75
76 def self.in_env(env) 76 def self.in_env(env)
77 - env.present? ? where(:environment => env) : scoped 77 + env.present? ? where(environment: env) : scoped
78 end 78 end
79 79
80 def self.cache_notice(id, notice) 80 def self.cache_notice(id, notice)
@@ -85,22 +85,22 @@ class Problem @@ -85,22 +85,22 @@ class Problem
85 85
86 Problem.where('_id' => id).find_one_and_update({ 86 Problem.where('_id' => id).find_one_and_update({
87 '$set' => { 87 '$set' => {
88 - 'environment' => notice.environment_name,  
89 - 'error_class' => notice.error_class,  
90 - 'last_notice_at' => notice.created_at.utc,  
91 - 'message' => notice.message,  
92 - 'resolved' => false,  
93 - 'resolved_at' => nil,  
94 - 'where' => notice.where,  
95 - "messages.#{message_digest}.value" => notice.message,  
96 - "hosts.#{host_digest}.value" => notice.host,  
97 - "user_agents.#{user_agent_digest}.value" => notice.user_agent_string, 88 + 'environment' => notice.environment_name,
  89 + 'error_class' => notice.error_class,
  90 + 'last_notice_at' => notice.created_at.utc,
  91 + 'message' => notice.message,
  92 + 'resolved' => false,
  93 + 'resolved_at' => nil,
  94 + 'where' => notice.where,
  95 + "messages.#{message_digest}.value" => notice.message,
  96 + "hosts.#{host_digest}.value" => notice.host,
  97 + "user_agents.#{user_agent_digest}.value" => notice.user_agent_string
98 }, 98 },
99 '$inc' => { 99 '$inc' => {
100 - 'notices_count' => 1,  
101 - "messages.#{message_digest}.count" => 1,  
102 - "hosts.#{host_digest}.count" => 1,  
103 - "user_agents.#{user_agent_digest}.count" => 1, 100 + 'notices_count' => 1,
  101 + "messages.#{message_digest}.count" => 1,
  102 + "hosts.#{host_digest}.count" => 1,
  103 + "user_agents.#{user_agent_digest}.count" => 1
104 } 104 }
105 }, return_document: :after) 105 }, return_document: :after)
106 end 106 end
@@ -110,12 +110,12 @@ class Problem @@ -110,12 +110,12 @@ class Problem
110 110
111 atomically do |doc| 111 atomically do |doc|
112 doc.set( 112 doc.set(
113 - 'environment' => last_notice.environment_name,  
114 - 'error_class' => last_notice.error_class, 113 + 'environment' => last_notice.environment_name,
  114 + 'error_class' => last_notice.error_class,
115 'last_notice_at' => last_notice.created_at, 115 'last_notice_at' => last_notice.created_at,
116 - 'message' => last_notice.message,  
117 - 'where' => last_notice.where,  
118 - 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0 116 + 'message' => last_notice.message,
  117 + 'where' => last_notice.where,
  118 + 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0
119 ) 119 )
120 120
121 CACHED_NOTICE_ATTRIBUTES.each do |k, v| 121 CACHED_NOTICE_ATTRIBUTES.each do |k, v|
@@ -139,7 +139,7 @@ class Problem @@ -139,7 +139,7 @@ class Problem
139 # find only notices related to this problem 139 # find only notices related to this problem
140 Notice.collection.find.aggregate([ 140 Notice.collection.find.aggregate([
141 { "$match" => { err_id: { "$in" => err_ids } } }, 141 { "$match" => { err_id: { "$in" => err_ids } } },
142 - { "$group" => { _id: "$#{v}", count: {"$sum" => 1} } } 142 + { "$group" => { _id: "$#{v}", count: { "$sum" => 1 } } }
143 ]).each do |agg| 143 ]).each do |agg|
144 send(k)[Digest::MD5.hexdigest(agg[:_id] || 'N/A')] = { 144 send(k)[Digest::MD5.hexdigest(agg[:_id] || 'N/A')] = {
145 'value' => agg[:_id] || 'N/A', 145 'value' => agg[:_id] || 'N/A',
@@ -164,8 +164,8 @@ class Problem @@ -164,8 +164,8 @@ class Problem
164 Rails.application.routes.url_helpers.app_problem_url( 164 Rails.application.routes.url_helpers.app_problem_url(
165 app, 165 app,
166 self, 166 self,
167 - :host => Errbit::Config.host,  
168 - :port => Errbit::Config.port 167 + host: Errbit::Config.host,
  168 + port: Errbit::Config.port
169 ) 169 )
170 end 170 end
171 171
@@ -174,11 +174,11 @@ class Problem @@ -174,11 +174,11 @@ class Problem
174 end 174 end
175 175
176 def resolve! 176 def resolve!
177 - self.update_attributes!(:resolved => true, :resolved_at => Time.zone.now) 177 + self.update_attributes!(resolved: true, resolved_at: Time.zone.now)
178 end 178 end
179 179
180 def unresolve! 180 def unresolve!
181 - self.update_attributes!(:resolved => false, :resolved_at => nil) 181 + self.update_attributes!(resolved: false, resolved_at: nil)
182 end 182 end
183 183
184 def unresolved? 184 def unresolved?
@@ -194,7 +194,7 @@ class Problem @@ -194,7 +194,7 @@ class Problem
194 end 194 end
195 195
196 def unmerge! 196 def unmerge!
197 - attrs = {:error_class => error_class, :environment => environment} 197 + attrs = { error_class: error_class, environment: environment }
198 problem_errs = errs.to_a 198 problem_errs = errs.to_a
199 199
200 # associate and return all the problems 200 # associate and return all the problems
@@ -214,12 +214,12 @@ class Problem @@ -214,12 +214,12 @@ class Problem
214 214
215 def self.ordered_by(sort, order) 215 def self.ordered_by(sort, order)
216 case sort 216 case sort
217 - when "app" then order_by(["app_name", order])  
218 - when "message" then order_by(["message", order]) 217 + when "app" then order_by(["app_name", order])
  218 + when "message" then order_by(["message", order])
219 when "last_notice_at" then order_by(["last_notice_at", order]) 219 when "last_notice_at" then order_by(["last_notice_at", order])
220 when "last_deploy_at" then order_by(["last_deploy_at", order]) 220 when "last_deploy_at" then order_by(["last_deploy_at", order])
221 - when "count" then order_by(["notices_count", order])  
222 - else raise("\"#{sort}\" is not a recognized sort") 221 + when "count" then order_by(["notices_count", order])
  222 + else fail("\"#{sort}\" is not a recognized sort")
223 end 223 end
224 end 224 end
225 225
@@ -241,7 +241,7 @@ class Problem @@ -241,7 +241,7 @@ class Problem
241 end 241 end
242 242
243 def self.search(value) 243 def self.search(value)
244 - Problem.where({'$text' => {'$search' => value}}) 244 + Problem.where('$text' => { '$search' => value })
245 end 245 end
246 246
247 private 247 private
app/models/user.rb
@@ -9,37 +9,37 @@ class User @@ -9,37 +9,37 @@ class User
9 field :github_login 9 field :github_login
10 field :github_oauth_token 10 field :github_oauth_token
11 field :name 11 field :name
12 - field :admin, :type => Boolean, :default => false  
13 - field :per_page, :type => Fixnum, :default => PER_PAGE  
14 - field :time_zone, :default => "UTC" 12 + field :admin, type: Boolean, default: false
  13 + field :per_page, type: Fixnum, default: PER_PAGE
  14 + field :time_zone, default: "UTC"
15 15
16 ## Devise field 16 ## Devise field
17 ### Database Authenticatable 17 ### Database Authenticatable
18 - field :encrypted_password, :type => String 18 + field :encrypted_password, type: String
19 19
20 ### Recoverable 20 ### Recoverable
21 - field :reset_password_token, :type => String  
22 - field :reset_password_sent_at, :type => Time 21 + field :reset_password_token, type: String
  22 + field :reset_password_sent_at, type: Time
23 23
24 ### Rememberable 24 ### Rememberable
25 - field :remember_created_at, :type => Time 25 + field :remember_created_at, type: Time
26 26
27 ### Trackable 27 ### Trackable
28 - field :sign_in_count, :type => Integer  
29 - field :current_sign_in_at, :type => Time  
30 - field :last_sign_in_at, :type => Time  
31 - field :current_sign_in_ip, :type => String  
32 - field :last_sign_in_ip, :type => String 28 + field :sign_in_count, type: Integer
  29 + field :current_sign_in_at, type: Time
  30 + field :last_sign_in_at, type: Time
  31 + field :current_sign_in_ip, type: String
  32 + field :last_sign_in_ip, type: String
33 33
34 ### Token_authenticatable 34 ### Token_authenticatable
35 - field :authentication_token, :type => String 35 + field :authentication_token, type: String
36 36
37 - index :authentication_token => 1 37 + index authentication_token: 1
38 38
39 before_save :ensure_authentication_token 39 before_save :ensure_authentication_token
40 40
41 validates_presence_of :name 41 validates_presence_of :name
42 - validates_uniqueness_of :github_login, :allow_nil => true 42 + validates_uniqueness_of :github_login, allow_nil: true
43 43
44 if Errbit::Config.user_has_username 44 if Errbit::Config.user_has_username
45 field :username 45 field :username
app/models/watcher.rb
@@ -4,7 +4,7 @@ class Watcher @@ -4,7 +4,7 @@ class Watcher
4 4
5 field :email 5 field :email
6 6
7 - embedded_in :app, :inverse_of => :watchers 7 + embedded_in :app, inverse_of: :watchers
8 belongs_to :user 8 belongs_to :user
9 9
10 validate :ensure_user_or_email 10 validate :ensure_user_or_email
app/views/apps/_service_notification_fields.html.haml
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil} 14 %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil}
15 - NotificationService.subclasses.each do |notification_service| 15 - NotificationService.subclasses.each do |notification_service|
16 %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label} 16 %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label}
17 - - notification_service::Fields.each do |field, field_info| 17 + - notification_service::FIELDS.each do |field, field_info|
18 = w.label field, field_info[:label] || field.to_s.titleize 18 = w.label field, field_info[:label] || field.to_s.titleize
19 - field_type = field == :password ? :password_field : :text_field 19 - field_type = field == :password ? :password_field : :text_field
20 - value = field == :notify_at_notices ? w.object.notify_at_notices.join(", ") : w.object.send(field) 20 - value = field == :notify_at_notices ? w.object.notify_at_notices.join(", ") : w.object.send(field)
config/application.rb
@@ -39,7 +39,7 @@ module Errbit @@ -39,7 +39,7 @@ module Errbit
39 config.generators do |g| 39 config.generators do |g|
40 g.orm :mongoid 40 g.orm :mongoid
41 g.template_engine :haml 41 g.template_engine :haml
42 - g.test_framework :rspec, :fixture => false 42 + g.test_framework :rspec, fixture: false
43 g.fixture_replacement :fabrication 43 g.fixture_replacement :fabrication
44 end 44 end
45 45
config/deploy.example.rb
@@ -46,7 +46,7 @@ namespace :errbit do @@ -46,7 +46,7 @@ namespace :errbit do
46 46
47 { 47 {
48 'config/newrelic.example.yml' => 'config/newrelic.yml', 48 'config/newrelic.example.yml' => 'config/newrelic.yml',
49 - 'config/unicorn.default.rb' => 'config/unicorn.rb', 49 + 'config/unicorn.default.rb' => 'config/unicorn.rb'
50 }.each do |src, target| 50 }.each do |src, target|
51 unless test("[ -f #{shared_path}/#{target} ]") 51 unless test("[ -f #{shared_path}/#{target} ]")
52 upload! src, "#{shared_path}/#{target}" 52 upload! src, "#{shared_path}/#{target}"
config/initializers/action_mailer.rb
@@ -2,12 +2,12 @@ @@ -2,12 +2,12 @@
2 if Errbit::Config.email_delivery_method == :smtp 2 if Errbit::Config.email_delivery_method == :smtp
3 ActionMailer::Base.delivery_method = :smtp 3 ActionMailer::Base.delivery_method = :smtp
4 ActionMailer::Base.smtp_settings = { 4 ActionMailer::Base.smtp_settings = {
5 - :address => Errbit::Config.smtp_address,  
6 - :port => Errbit::Config.smtp_port,  
7 - :authentication => Errbit::Config.smtp_authentication,  
8 - :user_name => Errbit::Config.smtp_user_name,  
9 - :password => Errbit::Config.smtp_password,  
10 - :domain => Errbit::Config.smtp_domain, 5 + address: Errbit::Config.smtp_address,
  6 + port: Errbit::Config.smtp_port,
  7 + authentication: Errbit::Config.smtp_authentication,
  8 + user_name: Errbit::Config.smtp_user_name,
  9 + password: Errbit::Config.smtp_password,
  10 + domain: Errbit::Config.smtp_domain
11 } 11 }
12 end 12 end
13 13
@@ -23,8 +23,8 @@ end @@ -23,8 +23,8 @@ end
23 # Set config specific values 23 # Set config specific values
24 (ActionMailer::Base.default_url_options ||= {}).tap do |default| 24 (ActionMailer::Base.default_url_options ||= {}).tap do |default|
25 options_from_config = { 25 options_from_config = {
26 - host: Errbit::Config.host,  
27 - port: Errbit::Config.port, 26 + host: Errbit::Config.host,
  27 + port: Errbit::Config.port,
28 protocol: Errbit::Config.protocol 28 protocol: Errbit::Config.protocol
29 }.select { |_k, v| v } 29 }.select { |_k, v| v }
30 30
config/initializers/cve-2013-0156.rb
1 ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::YAML) 1 ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::YAML)
2 -ActiveSupport::XmlMini::PARSING.delete("symbol")  
3 -ActiveSupport::XmlMini::PARSING.delete("yaml") 2 +ActiveSupport::XmlMini::PARSING.delete("symbol")
  3 +ActiveSupport::XmlMini::PARSING.delete("yaml")
config/initializers/devise.rb
@@ -29,7 +29,7 @@ Devise.setup do |config| @@ -29,7 +29,7 @@ Devise.setup do |config|
29 # session. If you need permissions, you should implement that in a before filter. 29 # session. If you need permissions, you should implement that in a before filter.
30 # You can also supply a hash where the value is a boolean determining whether 30 # You can also supply a hash where the value is a boolean determining whether
31 # or not authentication should be aborted when the value is not present. 31 # or not authentication should be aborted when the value is not present.
32 - config.authentication_keys = [ Errbit::Config.user_has_username ? :username : :email ] 32 + config.authentication_keys = [Errbit::Config.user_has_username ? :username : :email]
33 33
34 # Configure parameters from the request object used for authentication. Each entry 34 # Configure parameters from the request object used for authentication. Each entry
35 # given should be a request method and it will automatically be passed to the 35 # given should be a request method and it will automatically be passed to the
@@ -41,12 +41,12 @@ Devise.setup do |config| @@ -41,12 +41,12 @@ Devise.setup do |config|
41 # Configure which authentication keys should be case-insensitive. 41 # Configure which authentication keys should be case-insensitive.
42 # These keys will be downcased upon creating or modifying a user and when used 42 # These keys will be downcased upon creating or modifying a user and when used
43 # to authenticate or find a user. Default is :email. 43 # to authenticate or find a user. Default is :email.
44 - config.case_insensitive_keys = [ Errbit::Config.user_has_username ? :username : :email ] 44 + config.case_insensitive_keys = [Errbit::Config.user_has_username ? :username : :email]
45 45
46 # Configure which authentication keys should have whitespace stripped. 46 # Configure which authentication keys should have whitespace stripped.
47 # These keys will have whitespace before and after removed upon creating or 47 # These keys will have whitespace before and after removed upon creating or
48 # modifying a user and when used to authenticate or find a user. Default is :email. 48 # modifying a user and when used to authenticate or find a user. Default is :email.
49 - config.strip_whitespace_keys = [ Errbit::Config.user_has_username ? :username : :email ] 49 + config.strip_whitespace_keys = [Errbit::Config.user_has_username ? :username : :email]
50 50
51 # Tell if authentication through request.params is enabled. True by default. 51 # Tell if authentication through request.params is enabled. True by default.
52 # It can be set to an array that will enable params authentication only for the 52 # It can be set to an array that will enable params authentication only for the
@@ -237,12 +237,12 @@ Devise.setup do |config| @@ -237,12 +237,12 @@ Devise.setup do |config|
237 237
238 if Errbit::Config.github_authentication || Rails.env.test? 238 if Errbit::Config.github_authentication || Rails.env.test?
239 github_options = { 239 github_options = {
240 - :scope => Errbit::Config.github_access_scope.join(','),  
241 - :skip_info => true,  
242 - :client_options => {  
243 - :site => Errbit::Config.github_api_url,  
244 - :authorize_url => "#{Errbit::Config.github_url}/login/oauth/authorize",  
245 - :token_url => "#{Errbit::Config.github_url}/login/oauth/access_token" 240 + scope: Errbit::Config.github_access_scope.join(','),
  241 + skip_info: true,
  242 + client_options: {
  243 + site: Errbit::Config.github_api_url,
  244 + authorize_url: "#{Errbit::Config.github_url}/login/oauth/authorize",
  245 + token_url: "#{Errbit::Config.github_url}/login/oauth/access_token"
246 } 246 }
247 } 247 }
248 248
config/initializers/ssl_enforcer.rb
1 # Enforce SSL connections, if configured 1 # Enforce SSL connections, if configured
2 if Errbit::Config.enforce_ssl 2 if Errbit::Config.enforce_ssl
3 require 'rack/ssl-enforcer' 3 require 'rack/ssl-enforcer'
4 - ActionMailer::Base.default_url_options.merge!(:protocol => 'https://') 4 + ActionMailer::Base.default_url_options.merge!(protocol: 'https://')
5 Rails.application.configure do 5 Rails.application.configure do
6 - config.middleware.use Rack::SslEnforcer, :except => /^\/deploys/ 6 + config.middleware.use Rack::SslEnforcer, except: %r{^/deploys}
7 end 7 end
8 end 8 end
config/load.rb
@@ -7,7 +7,7 @@ require_relative &#39;../lib/configurator&#39; @@ -7,7 +7,7 @@ require_relative &#39;../lib/configurator&#39;
7 # 7 #
8 # We use the first non-nil environment variable in the list. If the last array 8 # We use the first non-nil environment variable in the list. If the last array
9 # element is a proc, it runs at the end, overriding the config value 9 # element is a proc, it runs at the end, overriding the config value
10 -Errbit::Config = Configurator.run({ 10 +Errbit::Config = Configurator.run(
11 host: ['ERRBIT_HOST'], 11 host: ['ERRBIT_HOST'],
12 protocol: ['ERRBIT_PROTOCOL'], 12 protocol: ['ERRBIT_PROTOCOL'],
13 port: ['ERRBIT_PORT'], 13 port: ['ERRBIT_PORT'],
@@ -29,8 +29,8 @@ Errbit::Config = Configurator.run({ @@ -29,8 +29,8 @@ Errbit::Config = Configurator.run({
29 mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), 29 mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL),
30 30
31 # github 31 # github
32 - github_url: ['GITHUB_URL', ->(values) {  
33 - values[:github_url].gsub(/\/*\z/, '') 32 + github_url: ['GITHUB_URL', lambda { |values|
  33 + values[:github_url].gsub(%r{/*\z}, '')
34 }], 34 }],
35 github_authentication: ['GITHUB_AUTHENTICATION'], 35 github_authentication: ['GITHUB_AUTHENTICATION'],
36 github_client_id: ['GITHUB_CLIENT_ID'], 36 github_client_id: ['GITHUB_CLIENT_ID'],
@@ -40,7 +40,7 @@ Errbit::Config = Configurator.run({ @@ -40,7 +40,7 @@ Errbit::Config = Configurator.run({
40 github_api_url: ['GITHUB_API_URL'], 40 github_api_url: ['GITHUB_API_URL'],
41 github_site_title: ['GITHUB_SITE_TITLE'], 41 github_site_title: ['GITHUB_SITE_TITLE'],
42 42
43 - email_delivery_method: ['EMAIL_DELIVERY_METHOD', -> (values) { 43 + email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda { |values|
44 values[:email_delivery_method] && values[:email_delivery_method].to_sym 44 values[:email_delivery_method] && values[:email_delivery_method].to_sym
45 }], 45 }],
46 46
@@ -50,7 +50,7 @@ Errbit::Config = Configurator.run({ @@ -50,7 +50,7 @@ Errbit::Config = Configurator.run({
50 smtp_authentication: ['SMTP_AUTHENTICATION'], 50 smtp_authentication: ['SMTP_AUTHENTICATION'],
51 smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), 51 smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME),
52 smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), 52 smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD),
53 - smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) { 53 + smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda { |values|
54 values[:smtp_domain] || 54 values[:smtp_domain] ||
55 (values[:email_from] && values[:email_from].split('@').last) || nil 55 (values[:email_from] && values[:email_from].split('@').last) || nil
56 }], 56 }],
@@ -59,5 +59,5 @@ Errbit::Config = Configurator.run({ @@ -59,5 +59,5 @@ Errbit::Config = Configurator.run({
59 sendmail_location: ['SENDMAIL_LOCATION'], 59 sendmail_location: ['SENDMAIL_LOCATION'],
60 sendmail_arguments: ['SENDMAIL_ARGUMENTS'], 60 sendmail_arguments: ['SENDMAIL_ARGUMENTS'],
61 61
62 - devise_modules: ['DEVISE_MODULES'],  
63 -}) 62 + devise_modules: ['DEVISE_MODULES']
  63 +)
config/mongo.rb
@@ -10,7 +10,7 @@ Mongoid.configure do |config| @@ -10,7 +10,7 @@ Mongoid.configure do |config|
10 Errbit::Config.mongo_url 10 Errbit::Config.mongo_url
11 end 11 end
12 12
13 - config.load_configuration({ 13 + config.load_configuration(
14 clients: { 14 clients: {
15 default: { 15 default: {
16 uri: uri 16 uri: uri
@@ -19,5 +19,5 @@ Mongoid.configure do |config| @@ -19,5 +19,5 @@ Mongoid.configure do |config|
19 options: { 19 options: {
20 use_activesupport_time_zone: true 20 use_activesupport_time_zone: true
21 } 21 }
22 - }) 22 + )
23 end 23 end
config/routes.rb
1 Rails.application.routes.draw do 1 Rails.application.routes.draw do
2 - devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } 2 + devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
3 3
4 # Hoptoad Notifier Routes 4 # Hoptoad Notifier Routes
5 match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] 5 match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post]
6 get '/locate/:id' => 'notices#locate', :as => :locate 6 get '/locate/:id' => 'notices#locate', :as => :locate
7 post '/deploys.txt' => 'deploys#create' 7 post '/deploys.txt' => 'deploys#create'
8 8
9 - resources :notices, :only => [:show]  
10 - resources :deploys, :only => [:show] 9 + resources :notices, only: [:show]
  10 + resources :deploys, only: [:show]
11 resources :users do 11 resources :users do
12 member do 12 member do
13 delete :unlink_github 13 delete :unlink_github
14 end 14 end
15 end 15 end
16 16
17 - resources :site_config, :only => [:index] do 17 + resources :site_config, only: [:index] do
18 collection do 18 collection do
19 put :update 19 put :update
20 end 20 end
21 end 21 end
22 22
23 - resources :problems, :only => [:index] do 23 + resources :problems, only: [:index] do
24 collection do 24 collection do
25 post :destroy_several 25 post :destroy_several
26 post :resolve_several 26 post :resolve_several
@@ -34,7 +34,7 @@ Rails.application.routes.draw do @@ -34,7 +34,7 @@ Rails.application.routes.draw do
34 resources :apps do 34 resources :apps do
35 resources :problems do 35 resources :problems do
36 resources :notices 36 resources :notices
37 - resources :comments, :only => [:create, :destroy] 37 + resources :comments, only: [:create, :destroy]
38 38
39 collection do 39 collection do
40 post :destroy_all 40 post :destroy_all
@@ -47,8 +47,8 @@ Rails.application.routes.draw do @@ -47,8 +47,8 @@ Rails.application.routes.draw do
47 delete :unlink_issue 47 delete :unlink_issue
48 end 48 end
49 end 49 end
50 - resources :deploys, :only => [:index]  
51 - resources :watchers, :only => [:destroy, :update] 50 + resources :deploys, only: [:index]
  51 + resources :watchers, only: [:destroy, :update]
52 member do 52 member do
53 post :regenerate_api_key 53 post :regenerate_api_key
54 end 54 end
@@ -56,9 +56,9 @@ Rails.application.routes.draw do @@ -56,9 +56,9 @@ Rails.application.routes.draw do
56 56
57 namespace :api do 57 namespace :api do
58 namespace :v1 do 58 namespace :v1 do
59 - resources :problems, :only => [:index, :show], :defaults => { :format => 'json' }  
60 - resources :notices, :only => [:index], :defaults => { :format => 'json' }  
61 - resources :stats, :only => [], :defaults => { :format => 'json' } do 59 + resources :problems, only: [:index, :show], defaults: { format: 'json' }
  60 + resources :notices, only: [:index], defaults: { format: 'json' }
  61 + resources :stats, only: [], defaults: { format: 'json' } do
62 collection do 62 collection do
63 get :app 63 get :app
64 end 64 end
@@ -69,5 +69,5 @@ Rails.application.routes.draw do @@ -69,5 +69,5 @@ Rails.application.routes.draw do
69 match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post] 69 match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post]
70 match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post] 70 match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post]
71 71
72 - root :to => 'apps#index' 72 + root to: 'apps#index'
73 end 73 end
db/migrate/201510290041_extract_issue_tracker.rb
1 class ExtractIssueTracker < Mongoid::Migration 1 class ExtractIssueTracker < Mongoid::Migration
2 TRACKER_MAPPING = { 2 TRACKER_MAPPING = {
3 - 'ErrbitTracPlugin::IssueTracker' => 'trac', 3 + 'ErrbitTracPlugin::IssueTracker' => 'trac',
4 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket', 4 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket',
5 - 'IssueTrackers::FogbugzTracker' => 'fogbugz',  
6 - 'IssueTrackers::GithubIssuesTracker' => 'github',  
7 - 'IssueTrackers::GitlabTracker' => 'gitlab',  
8 - 'IssueTrackers::JiraTracker' => 'jira',  
9 - 'IssueTrackers::LighthouseTracker' => 'lighthouse',  
10 - 'IssueTrackers::PivotalLabsTracker' => 'pivotal',  
11 - 'IssueTrackers::RedmineTracker' => 'redmine',  
12 - 'IssueTrackers::UnfuddleTracker' => 'unfuddle' 5 + 'IssueTrackers::FogbugzTracker' => 'fogbugz',
  6 + 'IssueTrackers::GithubIssuesTracker' => 'github',
  7 + 'IssueTrackers::GitlabTracker' => 'gitlab',
  8 + 'IssueTrackers::JiraTracker' => 'jira',
  9 + 'IssueTrackers::LighthouseTracker' => 'lighthouse',
  10 + 'IssueTrackers::PivotalLabsTracker' => 'pivotal',
  11 + 'IssueTrackers::RedmineTracker' => 'redmine',
  12 + 'IssueTrackers::UnfuddleTracker' => 'unfuddle'
13 } 13 }
14 14
15 def self.up 15 def self.up
@@ -29,14 +29,12 @@ class ExtractIssueTracker &lt; Mongoid::Migration @@ -29,14 +29,12 @@ class ExtractIssueTracker &lt; Mongoid::Migration
29 29
30 tracker = { 30 tracker = {
31 'type_tracker' => TRACKER_MAPPING[type], 31 'type_tracker' => TRACKER_MAPPING[type],
32 - 'options' => options,  
33 - 'updated_at' => updated_at,  
34 - 'created_at' => created_at 32 + 'options' => options,
  33 + 'updated_at' => updated_at,
  34 + 'created_at' => created_at
35 } 35 }
36 36
37 - App.where({ _id: app.id }).update({  
38 - "$set" => { :issue_tracker => tracker }  
39 - }) 37 + App.where(_id: app.id).update("$set" => { issue_tracker: tracker })
40 end 38 end
41 end 39 end
42 40
@@ -15,7 +15,7 @@ puts &quot;-- password: #{admin_pass}&quot; @@ -15,7 +15,7 @@ puts &quot;-- password: #{admin_pass}&quot;
15 puts "" 15 puts ""
16 puts "Be sure to note down these credentials now!" 16 puts "Be sure to note down these credentials now!"
17 17
18 -user = User.find_or_initialize_by(:email => admin_email) 18 +user = User.find_or_initialize_by(email: admin_email)
19 19
20 user.name = 'Errbit Admin' 20 user.name = 'Errbit Admin'
21 user.password = admin_pass 21 user.password = admin_pass
lib/airbrake_api/v3/notice_parser.rb
@@ -11,14 +11,14 @@ module AirbrakeApi @@ -11,14 +11,14 @@ module AirbrakeApi
11 11
12 def report 12 def report
13 attributes = { 13 attributes = {
14 - error_class: error['type'],  
15 - message: error['message'],  
16 - backtrace: backtrace,  
17 - request: request, 14 + error_class: error['type'],
  15 + message: error['message'],
  16 + backtrace: backtrace,
  17 + request: request,
18 server_environment: server_environment, 18 server_environment: server_environment,
19 - api_key: params['key'].present? ? params['key'] : params['project_id'],  
20 - notifier: params['notifier'],  
21 - user_attributes: user_attributes 19 + api_key: params['key'].present? ? params['key'] : params['project_id'],
  20 + notifier: params['notifier'],
  21 + user_attributes: user_attributes
22 } 22 }
23 23
24 ErrorReport.new(attributes) 24 ErrorReport.new(attributes)
@@ -27,7 +27,7 @@ module AirbrakeApi @@ -27,7 +27,7 @@ module AirbrakeApi
27 private 27 private
28 28
29 def error 29 def error
30 - raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any? 30 + fail AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any?
31 @error ||= params['errors'].first 31 @error ||= params['errors'].first
32 end 32 end
33 33
@@ -35,7 +35,7 @@ module AirbrakeApi @@ -35,7 +35,7 @@ module AirbrakeApi
35 (error['backtrace'] || []).map do |backtrace_line| 35 (error['backtrace'] || []).map do |backtrace_line|
36 { 36 {
37 method: backtrace_line['function'], 37 method: backtrace_line['function'],
38 - file: backtrace_line['file'], 38 + file: backtrace_line['file'],
39 number: backtrace_line['line'], 39 number: backtrace_line['line'],
40 column: backtrace_line['column'] 40 column: backtrace_line['column']
41 } 41 }
@@ -45,9 +45,9 @@ module AirbrakeApi @@ -45,9 +45,9 @@ module AirbrakeApi
45 def server_environment 45 def server_environment
46 { 46 {
47 'environment-name' => context['environment'], 47 'environment-name' => context['environment'],
48 - 'hostname' => hostname,  
49 - 'project-root' => context['rootDirectory'],  
50 - 'app-version' => context['version'] 48 + 'hostname' => hostname,
  49 + 'project-root' => context['rootDirectory'],
  50 + 'app-version' => context['version']
51 } 51 }
52 end 52 end
53 53
@@ -57,12 +57,12 @@ module AirbrakeApi @@ -57,12 +57,12 @@ module AirbrakeApi
57 ) 57 )
58 58
59 { 59 {
60 - 'cgi-data' => environment,  
61 - 'session' => params['session'],  
62 - 'params' => params['params'],  
63 - 'url' => url, 60 + 'cgi-data' => environment,
  61 + 'session' => params['session'],
  62 + 'params' => params['params'],
  63 + 'url' => url,
64 'component' => context['component'], 64 'component' => context['component'],
65 - 'action' => context['action'] 65 + 'action' => context['action']
66 } 66 }
67 end 67 end
68 68
lib/hoptoad.rb
@@ -9,7 +9,7 @@ module Hoptoad @@ -9,7 +9,7 @@ module Hoptoad
9 9
10 class << self 10 class << self
11 def parse_xml!(xml) 11 def parse_xml!(xml)
12 - parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice'] || raise(ApiVersionError) 12 + parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice'] || fail(ApiVersionError)
13 processor = get_version_processor(parsed['version']) 13 processor = get_version_processor(parsed['version'])
14 processor.process_notice(parsed) 14 processor.process_notice(parsed)
15 end 15 end
@@ -17,7 +17,7 @@ module Hoptoad @@ -17,7 +17,7 @@ module Hoptoad
17 private def get_version_processor(version) 17 private def get_version_processor(version)
18 case version 18 case version
19 when /2\.[01234]/ then Hoptoad::V2 19 when /2\.[01234]/ then Hoptoad::V2
20 - else; raise ApiVersionError 20 + else; fail ApiVersionError
21 end 21 end
22 end 22 end
23 end 23 end
lib/hoptoad/v2.rb
@@ -12,23 +12,23 @@ module Hoptoad @@ -12,23 +12,23 @@ module Hoptoad
12 case node 12 case node
13 when Hash 13 when Hash
14 if node.key?('var') && node.key?('key') 14 if node.key?('var') && node.key?('key')
15 - {normalize_key(node['key']) => rekey(node['var'])} 15 + { normalize_key(node['key']) => rekey(node['var']) }
16 elsif node.key?('var') 16 elsif node.key?('var')
17 rekey(node['var']) 17 rekey(node['var'])
18 elsif node.key?('__content__') && node.key?('key') 18 elsif node.key?('__content__') && node.key?('key')
19 - {normalize_key(node['key']) => rekey(node['__content__'])} 19 + { normalize_key(node['key']) => rekey(node['__content__']) }
20 elsif node.key?('__content__') 20 elsif node.key?('__content__')
21 rekey(node['__content__']) 21 rekey(node['__content__'])
22 elsif node.key?('key') 22 elsif node.key?('key')
23 - {normalize_key(node['key']) => nil} 23 + { normalize_key(node['key']) => nil }
24 else 24 else
25 - node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))} 25 + node.inject({}) { |rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val)) }
26 end 26 end
27 when Array 27 when Array
28 if node.first.key?('key') 28 if node.first.key?('key')
29 - node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))} 29 + node.inject({}) { |rekeyed, keypair| rekeyed.merge(rekey(keypair)) }
30 else 30 else
31 - node.map {|n| rekey(n)} 31 + node.map { |n| rekey(n) }
32 end 32 end
33 else 33 else
34 node 34 node
@@ -53,18 +53,18 @@ module Hoptoad @@ -53,18 +53,18 @@ module Hoptoad
53 53
54 def self.for_errbit_api(notice) 54 def self.for_errbit_api(notice)
55 { 55 {
56 - :error_class => notice['error']['class'] || notice['error']['key'],  
57 - :message => notice['error']['message'],  
58 - :backtrace => notice['error']['backtrace']['line'], 56 + error_class: notice['error']['class'] || notice['error']['key'],
  57 + message: notice['error']['message'],
  58 + backtrace: notice['error']['backtrace']['line'],
59 59
60 - :request => notice['request'],  
61 - :server_environment => notice['server-environment'], 60 + request: notice['request'],
  61 + server_environment: notice['server-environment'],
62 62
63 - :api_key => notice['api-key'],  
64 - :notifier => notice['notifier'], 63 + api_key: notice['api-key'],
  64 + notifier: notice['notifier'],
65 # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem 65 # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem
66 - :user_attributes => notice['current-user'] || notice['user-attributes'] || {},  
67 - :framework => notice['framework'] 66 + user_attributes: notice['current-user'] || notice['user-attributes'] || {},
  67 + framework: notice['framework']
68 } 68 }
69 end 69 end
70 end 70 end
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
@@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do @@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do
7 private def send_notice(notice) 7 private def send_notice(notice)
8 # Log the error internally if we are not in a development environment. 8 # Log the error internally if we are not in a development environment.
9 if configuration.public? 9 if configuration.public?
10 - app = App.find_or_initialize_by(:name => "Self.Errbit") 10 + app = App.find_or_initialize_by(name: "Self.Errbit")
11 app.github_repo = "errbit/errbit" 11 app.github_repo = "errbit/errbit"
12 app.save! 12 app.save!
13 notice.send("api_key=", app.api_key) 13 notice.send("api_key=", app.api_key)
lib/tasks/errbit/database.rake
1 namespace :errbit do 1 namespace :errbit do
2 desc "Updates cached attributes on Problem" 2 desc "Updates cached attributes on Problem"
3 - task :problem_recache => :environment do 3 + task problem_recache: :environment do
4 ProblemRecacher.run 4 ProblemRecacher.run
5 end 5 end
6 6
7 desc "Delete resolved errors from the database. (Useful for limited heroku databases)" 7 desc "Delete resolved errors from the database. (Useful for limited heroku databases)"
8 - task :clear_resolved => :environment do 8 + task clear_resolved: :environment do
9 require 'resolved_problem_clearer' 9 require 'resolved_problem_clearer'
10 puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database." 10 puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database."
11 end 11 end
12 12
13 desc "Regenerate fingerprints" 13 desc "Regenerate fingerprints"
14 - task :notice_refingerprint => :environment do 14 + task notice_refingerprint: :environment do
15 NoticeRefingerprinter.run 15 NoticeRefingerprinter.run
16 ProblemRecacher.run 16 ProblemRecacher.run
17 end 17 end
18 18
19 desc "Remove notices in batch" 19 desc "Remove notices in batch"
20 - task :notices_delete, [ :problem_id ] => [ :environment ] do 20 + task :notices_delete, [:problem_id] => [:environment] do
21 BATCH_SIZE = 1000 21 BATCH_SIZE = 1000
22 if args[:problem_id] 22 if args[:problem_id]
23 item_count = Problem.find(args[:problem_id]).notices.count 23 item_count = Problem.find(args[:problem_id]).notices.count
lib/tasks/errbit/demo.rake
1 namespace :errbit do 1 namespace :errbit do
2 desc "Add a demo app & errors to your database (for testing)" 2 desc "Add a demo app & errors to your database (for testing)"
3 - task :demo => :environment do 3 + task demo: :environment do
4 require 'fabrication' 4 require 'fabrication'
5 5
6 - app = Fabricate(:app, :name => "Demo App #{Time.zone.now.strftime('%N')}") 6 + app = Fabricate(:app, name: "Demo App #{Time.zone.now.strftime('%N')}")
7 7
8 # Report a number of errors for the application 8 # Report a number of errors for the application
9 app.problems.delete_all 9 app.problems.delete_all
10 10
11 errors = [{ 11 errors = [{
12 - :error_class => "ArgumentError",  
13 - :message => "wrong number of arguments (3 for 0)" 12 + error_class: "ArgumentError",
  13 + message: "wrong number of arguments (3 for 0)"
14 }, { 14 }, {
15 - :error_class => "RuntimeError",  
16 - :message => "Could not find Red October" 15 + error_class: "RuntimeError",
  16 + message: "Could not find Red October"
17 }, { 17 }, {
18 - :error_class => "TypeError",  
19 - :message => "can't convert Symbol into Integer" 18 + error_class: "TypeError",
  19 + message: "can't convert Symbol into Integer"
20 }, { 20 }, {
21 - :error_class => "ActiveRecord::RecordNotFound",  
22 - :message => "could not find a record with the id 5" 21 + error_class: "ActiveRecord::RecordNotFound",
  22 + message: "could not find a record with the id 5"
23 }, { 23 }, {
24 - :error_class => "NameError",  
25 - :message => "uninitialized constant Tag" 24 + error_class: "NameError",
  25 + message: "uninitialized constant Tag"
26 }, { 26 }, {
27 - :error_class => "SyntaxError",  
28 - :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" 27 + error_class: "SyntaxError",
  28 + message: "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('"
29 }] 29 }]
30 30
31 RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8] 31 RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8]
32 32
33 def random_backtrace 33 def random_backtrace
34 backtrace = [] 34 backtrace = []
35 - 99.times {|t| backtrace << {  
36 - 'number' => t.hash % 1000,  
37 - 'file' => "/path/to/file.rb",  
38 - 'method' => RANDOM_METHODS.sample.to_s  
39 - }} 35 + 99.times {|t|
  36 + backtrace << {
  37 + 'number' => t.hash % 1000,
  38 + 'file' => "/path/to/file.rb",
  39 + 'method' => RANDOM_METHODS.sample.to_s
  40 + }}
40 backtrace 41 backtrace
41 end 42 end
42 43
43 errors.each do |error_template| 44 errors.each do |error_template|
44 rand(34).times do 45 rand(34).times do
45 - ErrorReport.new(error_template.reverse_merge({  
46 - :api_key => app.api_key,  
47 - :error_class => "StandardError",  
48 - :message => "Oops. Something went wrong!",  
49 - :backtrace => random_backtrace,  
50 - :request => {  
51 - 'component' => 'main',  
52 - 'action' => 'error',  
53 - 'url' => "http://example.com/post/#{[111, 222, 333].sample}",  
54 - },  
55 - :server_environment => {'environment-name' => Rails.env.to_s},  
56 - :notifier => {:name => "seeds.rb"},  
57 - :app_user => {  
58 - :id => "1234",  
59 - :username => "jsmith",  
60 - :name => "John Smith",  
61 - :url => "http://www.example.com/users/jsmith"  
62 - }  
63 - })).generate_notice! 46 + ErrorReport.new(
  47 + error_template.reverse_merge(
  48 + api_key: app.api_key,
  49 + error_class: "StandardError",
  50 + message: "Oops. Something went wrong!",
  51 + backtrace: random_backtrace,
  52 + request: {
  53 + 'component' => 'main',
  54 + 'action' => 'error',
  55 + 'url' => "http://example.com/post/#{[111, 222, 333].sample}"
  56 + },
  57 + server_environment: { 'environment-name' => Rails.env.to_s },
  58 + notifier: { name: "seeds.rb" },
  59 + app_user: {
  60 + id: "1234",
  61 + username: "jsmith",
  62 + name: "John Smith",
  63 + url: "http://www.example.com/users/jsmith"
  64 + }
  65 + )
  66 + ).generate_notice!
64 end 67 end
65 end 68 end
66 69
67 - Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app))) 70 + Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app)))
68 puts "=== Created demo app: '#{app.name}', with example errors." 71 puts "=== Created demo app: '#{app.name}', with example errors."
69 end 72 end
70 end 73 end
lib/tasks/heroku/cron.rake
1 desc "This task is called by the Heroku cron add-on" 1 desc "This task is called by the Heroku cron add-on"
2 -task :cron => :environment do 2 +task cron: :environment do
3 Rake::Task["errbit:db:clear_resolved"].invoke 3 Rake::Task["errbit:db:clear_resolved"].invoke
4 end 4 end
spec/acceptance/acceptance_helper.rb
@@ -7,9 +7,9 @@ OmniAuth.config.test_mode = true @@ -7,9 +7,9 @@ OmniAuth.config.test_mode = true
7 7
8 def mock_auth(user = "test_user", token = "abcdef") 8 def mock_auth(user = "test_user", token = "abcdef")
9 OmniAuth.config.mock_auth[:github] = Hashie::Mash.new( 9 OmniAuth.config.mock_auth[:github] = Hashie::Mash.new(
10 - 'provider' => 'github',  
11 - 'uid' => '1763',  
12 - 'extra' => { 10 + 'provider' => 'github',
  11 + 'uid' => '1763',
  12 + 'extra' => {
13 'raw_info' => { 13 'raw_info' => {
14 'login' => user 14 'login' => user
15 } 15 }
@@ -22,7 +22,7 @@ end @@ -22,7 +22,7 @@ end
22 22
23 def log_in(user) 23 def log_in(user)
24 visit '/' 24 visit '/'
25 - fill_in :user_email, :with => user.email  
26 - fill_in :user_password, :with => 'password' 25 + fill_in :user_email, with: user.email
  26 + fill_in :user_password, with: 'password'
27 click_on I18n.t('devise.sessions.new.sign_in') 27 click_on I18n.t('devise.sessions.new.sign_in')
28 end 28 end
spec/acceptance/app_regenerate_api_key_spec.rb
@@ -4,7 +4,7 @@ feature &quot;Regeneration api_Key&quot; do @@ -4,7 +4,7 @@ feature &quot;Regeneration api_Key&quot; do
4 let(:app) { Fabricate(:app) } 4 let(:app) { Fabricate(:app) }
5 let(:admin) { Fabricate(:admin) } 5 let(:admin) { Fabricate(:admin) }
6 let(:user) { 6 let(:user) {
7 - Fabricate(:user_watcher, :app => app).user 7 + Fabricate(:user_watcher, app: app).user
8 } 8 }
9 9
10 before do 10 before do
@@ -37,7 +37,7 @@ end @@ -37,7 +37,7 @@ end
37 feature "Create an application" do 37 feature "Create an application" do
38 let(:admin) { Fabricate(:admin) } 38 let(:admin) { Fabricate(:admin) }
39 let(:user) { 39 let(:user) {
40 - Fabricate(:user_watcher, :app => app).user 40 + Fabricate(:user_watcher, app: app).user
41 } 41 }
42 42
43 before do 43 before do
@@ -48,37 +48,37 @@ feature &quot;Create an application&quot; do @@ -48,37 +48,37 @@ feature &quot;Create an application&quot; do
48 visit '/' 48 visit '/'
49 log_in admin 49 log_in admin
50 click_on I18n.t('apps.index.new_app') 50 click_on I18n.t('apps.index.new_app')
51 - fill_in 'app_name', :with => 'My new app' 51 + fill_in 'app_name', with: 'My new app'
52 click_on I18n.t('apps.new.add_app') 52 click_on I18n.t('apps.new.add_app')
53 page.has_content?(I18n.t('controllers.apps.flash.create.success')) 53 page.has_content?(I18n.t('controllers.apps.flash.create.success'))
54 - expect(App.where(:name => 'My new app').count).to eq 1  
55 - expect(App.where(:name => 'My new app 2').count).to eq 0 54 + expect(App.where(name: 'My new app').count).to eq 1
  55 + expect(App.where(name: 'My new app 2').count).to eq 0
56 56
57 click_on I18n.t('shared.navigation.apps') 57 click_on I18n.t('shared.navigation.apps')
58 click_on 'My new app' 58 click_on 'My new app'
59 click_link I18n.t('apps.show.edit') 59 click_link I18n.t('apps.show.edit')
60 - fill_in 'app_name', :with => 'My new app 2' 60 + fill_in 'app_name', with: 'My new app 2'
61 click_on I18n.t('apps.edit.update') 61 click_on I18n.t('apps.edit.update')
62 page.has_content?(I18n.t('controllers.apps.flash.update.success')) 62 page.has_content?(I18n.t('controllers.apps.flash.update.success'))
63 - expect(App.where(:name => 'My new app').count).to eq 0  
64 - expect(App.where(:name => 'My new app 2').count).to eq 1 63 + expect(App.where(name: 'My new app').count).to eq 0
  64 + expect(App.where(name: 'My new app 2').count).to eq 1
65 end 65 end
66 66
67 - scenario "create an apps with issue tracker and edit it", :js => true do 67 + scenario "create an apps with issue tracker and edit it", js: true do
68 visit '/' 68 visit '/'
69 log_in admin 69 log_in admin
70 click_on I18n.t('apps.index.new_app') 70 click_on I18n.t('apps.index.new_app')
71 - fill_in 'app_name', :with => 'My new app' 71 + fill_in 'app_name', with: 'My new app'
72 find('.label_radio.github').click 72 find('.label_radio.github').click
73 73
74 fill_in 'app_github_repo', with: 'foo/bar' 74 fill_in 'app_github_repo', with: 'foo/bar'
75 within ".github.tracker_params" do 75 within ".github.tracker_params" do
76 - fill_in 'app_issue_tracker_attributes_options_username', :with => 'token'  
77 - fill_in 'app_issue_tracker_attributes_options_password', :with => 'pass' 76 + fill_in 'app_issue_tracker_attributes_options_username', with: 'token'
  77 + fill_in 'app_issue_tracker_attributes_options_password', with: 'pass'
78 end 78 end
79 click_on I18n.t('apps.new.add_app') 79 click_on I18n.t('apps.new.add_app')
80 expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true 80 expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true
81 - app = App.where(:name => 'My new app').first 81 + app = App.where(name: 'My new app').first
82 expect(app.issue_tracker.type_tracker).to eql 'github' 82 expect(app.issue_tracker.type_tracker).to eql 'github'
83 expect(app.issue_tracker.options['username']).to eql 'token' 83 expect(app.issue_tracker.options['username']).to eql 'token'
84 expect(app.issue_tracker.options['password']).to eql 'pass' 84 expect(app.issue_tracker.options['password']).to eql 'pass'
@@ -89,7 +89,7 @@ feature &quot;Create an application&quot; do @@ -89,7 +89,7 @@ feature &quot;Create an application&quot; do
89 find('.issue_tracker .label_radio.none').click 89 find('.issue_tracker .label_radio.none').click
90 click_on I18n.t('apps.edit.update') 90 click_on I18n.t('apps.edit.update')
91 expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true 91 expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true
92 - app = App.where(:name => 'My new app').first 92 + app = App.where(name: 'My new app').first
93 expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker 93 expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker
94 end 94 end
95 end 95 end
spec/acceptance/reset_password_token.rb
@@ -20,7 +20,7 @@ feature &#39;password reset token&#39; do @@ -20,7 +20,7 @@ feature &#39;password reset token&#39; do
20 expect(mail.body.encoded).to match(/change your password/) 20 expect(mail.body.encoded).to match(/change your password/)
21 expect(mail.body.encoded).to match(regex) 21 expect(mail.body.encoded).to match(regex)
22 if mail.body.encoded =~ regex 22 if mail.body.encoded =~ regex
23 - visit "/users/password/edit?reset_password_token=#{$1}" 23 + visit "/users/password/edit?reset_password_token=#{Regexp.last_match(1)}"
24 expect(page).to have_content 'Change your password' 24 expect(page).to have_content 'Change your password'
25 fill_in 'New password', with: 'test12345' 25 fill_in 'New password', with: 'test12345'
26 fill_in 'Type your new password again', with: 'test12345' 26 fill_in 'Type your new password again', with: 'test12345'
spec/acceptance/sign_in_with_github_spec.rb
@@ -3,7 +3,7 @@ require &#39;acceptance/acceptance_helper&#39; @@ -3,7 +3,7 @@ require &#39;acceptance/acceptance_helper&#39;
3 feature 'Sign in with GitHub' do 3 feature 'Sign in with GitHub' do
4 background do 4 background do
5 allow(Errbit::Config).to receive(:github_authentication).and_return(true) 5 allow(Errbit::Config).to receive(:github_authentication).and_return(true)
6 - Fabricate(:user, :github_login => 'nashby') 6 + Fabricate(:user, github_login: 'nashby')
7 end 7 end
8 8
9 scenario 'log in via GitHub with recognized user' do 9 scenario 'log in via GitHub with recognized user' do
@@ -11,7 +11,7 @@ feature &#39;Sign in with GitHub&#39; do @@ -11,7 +11,7 @@ feature &#39;Sign in with GitHub&#39; do
11 11
12 visit '/' 12 visit '/'
13 click_link 'Sign in with GitHub' 13 click_link 'Sign in with GitHub'
14 - expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", :kind => 'GitHub') 14 + expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", kind: 'GitHub')
15 end 15 end
16 16
17 scenario 'reject unrecognized user if authenticating via GitHub' do 17 scenario 'reject unrecognized user if authenticating via GitHub' do
spec/controllers/api/v1/notices_controller_spec.rb
@@ -6,30 +6,30 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do @@ -6,30 +6,30 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do
6 6
7 describe "GET /api/v1/notices" do 7 describe "GET /api/v1/notices" do
8 before do 8 before do
9 - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01'))  
10 - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01'))  
11 - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-21'))  
12 - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-30')) 9 + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01'))
  10 + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01'))
  11 + Fabricate(:notice, created_at: Time.zone.parse('2012-08-21'))
  12 + Fabricate(:notice, created_at: Time.zone.parse('2012-08-30'))
13 end 13 end
14 14
15 it "should return JSON if JSON is requested" do 15 it "should return JSON if JSON is requested" do
16 - get :index, :auth_token => @user.authentication_token, :format => "json" 16 + get :index, auth_token: @user.authentication_token, format: "json"
17 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) 17 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
18 end 18 end
19 19
20 it "should return XML if XML is requested" do 20 it "should return XML if XML is requested" do
21 - get :index, :auth_token => @user.authentication_token, :format => "xml" 21 + get :index, auth_token: @user.authentication_token, format: "xml"
22 expect(Nokogiri::XML(response.body).errors).to be_empty 22 expect(Nokogiri::XML(response.body).errors).to be_empty
23 end 23 end
24 24
25 it "should return JSON by default" do 25 it "should return JSON by default" do
26 - get :index, :auth_token => @user.authentication_token 26 + get :index, auth_token: @user.authentication_token
27 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) 27 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
28 end 28 end
29 29
30 describe "given a date range" do 30 describe "given a date range" do
31 it "should return only the notices created during the date range" do 31 it "should return only the notices created during the date range" do
32 - get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27"} 32 + get :index, auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27"
33 expect(response).to be_success 33 expect(response).to be_success
34 notices = JSON.load response.body 34 notices = JSON.load response.body
35 expect(notices.length).to eq 3 35 expect(notices.length).to eq 3
@@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do
37 end 37 end
38 38
39 it "should return all notices" do 39 it "should return all notices" do
40 - get :index, {:auth_token => @user.authentication_token} 40 + get :index, auth_token: @user.authentication_token
41 expect(response).to be_success 41 expect(response).to be_success
42 notices = JSON.load response.body 42 notices = JSON.load response.body
43 expect(notices.length).to eq 4 43 expect(notices.length).to eq 4
spec/controllers/api/v1/problems_controller_spec.rb
@@ -7,34 +7,34 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do @@ -7,34 +7,34 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
7 describe "GET /api/v1/problems/:id" do 7 describe "GET /api/v1/problems/:id" do
8 before do 8 before do
9 notice = Fabricate(:notice) 9 notice = Fabricate(:notice)
10 - err = Fabricate(:err, :notices => [notice])  
11 - @problem = Fabricate(:problem, :errs => [err]) 10 + err = Fabricate(:err, notices: [notice])
  11 + @problem = Fabricate(:problem, errs: [err])
12 end 12 end
13 13
14 it "should return JSON if JSON is requested" do 14 it "should return JSON if JSON is requested" do
15 - get :show, :auth_token => @user.authentication_token, :format => "json", :id => Problem.first.id 15 + get :show, auth_token: @user.authentication_token, format: "json", id: Problem.first.id
16 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError 16 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError
17 end 17 end
18 18
19 it "should return XML if XML is requested" do 19 it "should return XML if XML is requested" do
20 - get :index, :auth_token => @user.authentication_token, :format => "xml", :id => @problem.id 20 + get :index, auth_token: @user.authentication_token, format: "xml", id: @problem.id
21 expect(Nokogiri::XML(response.body).errors).to be_empty 21 expect(Nokogiri::XML(response.body).errors).to be_empty
22 end 22 end
23 23
24 it "should return JSON by default" do 24 it "should return JSON by default" do
25 - get :show, :auth_token => @user.authentication_token, :id => @problem.id  
26 - expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) 25 + get :show, auth_token: @user.authentication_token, id: @problem.id
  26 + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
27 end 27 end
28 28
29 it "should return the correct problem" do 29 it "should return the correct problem" do
30 - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id 30 + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id
31 31
32 returned_problem = JSON.parse(response.body) 32 returned_problem = JSON.parse(response.body)
33 expect(returned_problem["_id"]).to eq(@problem.id.to_s) 33 expect(returned_problem["_id"]).to eq(@problem.id.to_s)
34 end 34 end
35 35
36 it "should return only the correct fields" do 36 it "should return only the correct fields" do
37 - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id 37 + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id
38 returned_problem = JSON.parse(response.body) 38 returned_problem = JSON.parse(response.body)
39 39
40 expect(returned_problem.keys).to match_array(%w( 40 expect(returned_problem.keys).to match_array(%w(
@@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do @@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
52 end 52 end
53 53
54 it "returns a 404 if the problem cannot be found" do 54 it "returns a 404 if the problem cannot be found" do
55 - get :show, :auth_token => @user.authentication_token, :format => "json", :id => 'IdontExist' 55 + get :show, auth_token: @user.authentication_token, format: "json", id: 'IdontExist'
56 expect(response.status).to eq(404) 56 expect(response.status).to eq(404)
57 end 57 end
58 end 58 end
59 59
60 describe "GET /api/v1/problems" do 60 describe "GET /api/v1/problems" do
61 before do 61 before do
62 - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 02))  
63 - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 21))  
64 - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 21))  
65 - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) 62 + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 02))
  63 + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 21))
  64 + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 21))
  65 + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 30))
66 end 66 end
67 67
68 it "should return JSON if JSON is requested" do 68 it "should return JSON if JSON is requested" do
69 - get :index, :auth_token => @user.authentication_token, :format => "json"  
70 - expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) 69 + get :index, auth_token: @user.authentication_token, format: "json"
  70 + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
71 end 71 end
72 72
73 it "should return XML if XML is requested" do 73 it "should return XML if XML is requested" do
74 - get :index, :auth_token => @user.authentication_token, :format => "xml" 74 + get :index, auth_token: @user.authentication_token, format: "xml"
75 expect(Nokogiri::XML(response.body).errors).to be_empty 75 expect(Nokogiri::XML(response.body).errors).to be_empty
76 end 76 end
77 77
78 it "should return JSON by default" do 78 it "should return JSON by default" do
79 - get :index, :auth_token => @user.authentication_token  
80 - expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) 79 + get :index, auth_token: @user.authentication_token
  80 + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
81 end 81 end
82 82
83 describe "given a date range" do 83 describe "given a date range" do
84 it "should return only the problems open during the date range" do 84 it "should return only the problems open during the date range" do
85 - get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} 85 + get :index, auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27"
86 expect(response).to be_success 86 expect(response).to be_success
87 problems = JSON.load response.body 87 problems = JSON.load response.body
88 expect(problems.length).to eq 2 88 expect(problems.length).to eq 2
@@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
90 end 90 end
91 91
92 it "should return all problems" do 92 it "should return all problems" do
93 - get :index, {:auth_token => @user.authentication_token} 93 + get :index, auth_token: @user.authentication_token
94 expect(response).to be_success 94 expect(response).to be_success
95 problems = JSON.load response.body 95 problems = JSON.load response.body
96 expect(problems.length).to eq 4 96 expect(problems.length).to eq 4
spec/controllers/api/v3/notices_controller_spec.rb
@@ -15,22 +15,22 @@ describe Api::V3::NoticesController, type: :controller do @@ -15,22 +15,22 @@ describe Api::V3::NoticesController, type: :controller do
15 it 'returns created notice id in json format' do 15 it 'returns created notice id in json format' do
16 post :create, legit_body, legit_params 16 post :create, legit_body, legit_params
17 notice = Notice.last 17 notice = Notice.last
18 - expect(JSON.parse(response.body)).to eq({  
19 - 'id' => notice.id.to_s, 18 + expect(JSON.parse(response.body)).to eq(
  19 + 'id' => notice.id.to_s,
20 'url' => app_problem_url(app, notice.problem) 20 'url' => app_problem_url(app, notice.problem)
21 - }) 21 + )
22 end 22 end
23 23
24 it 'responds with 400 when request attributes are not valid' do 24 it 'responds with 400 when request attributes are not valid' do
25 - allow_any_instance_of(AirbrakeApi::V3::NoticeParser)  
26 - .to receive(:report).and_raise(AirbrakeApi::ParamsError) 25 + allow_any_instance_of(AirbrakeApi::V3::NoticeParser).
  26 + to receive(:report).and_raise(AirbrakeApi::ParamsError)
27 post :create, project_id: 'ID' 27 post :create, project_id: 'ID'
28 expect(response.status).to eq(400) 28 expect(response.status).to eq(400)
29 expect(response.body).to eq('Invalid request') 29 expect(response.body).to eq('Invalid request')
30 end 30 end
31 31
32 it 'responds with 422 when project_id is invalid' do 32 it 'responds with 422 when project_id is invalid' do
33 - post :create, legit_body, { project_id: 'hm?', key: 'wha?' } 33 + post :create, legit_body, project_id: 'hm?', key: 'wha?'
34 34
35 expect(response.status).to eq(422) 35 expect(response.status).to eq(422)
36 expect(response.body).to eq('Your API key is unknown') 36 expect(response.body).to eq('Your API key is unknown')
@@ -38,7 +38,7 @@ describe Api::V3::NoticesController, type: :controller do @@ -38,7 +38,7 @@ describe Api::V3::NoticesController, type: :controller do
38 38
39 it 'ignores notices for older api' do 39 it 'ignores notices for older api' do
40 app = Fabricate(:app, current_app_version: '2.0') 40 app = Fabricate(:app, current_app_version: '2.0')
41 - post :create, legit_body, { project_id: app.api_key, key: app.api_key } 41 + post :create, legit_body, project_id: app.api_key, key: app.api_key
42 expect(response.body).to eq('Notice for old app version ignored') 42 expect(response.body).to eq('Notice for old app version ignored')
43 expect(Notice.count).to eq(0) 43 expect(Notice.count).to eq(0)
44 end 44 end
spec/controllers/apps_controller_spec.rb
1 describe AppsController, type: 'controller' do 1 describe AppsController, type: 'controller' do
2 it_requires_authentication 2 it_requires_authentication
3 - it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete} 3 + it_requires_admin_privileges for: { new: :get, edit: :get, create: :post, update: :put, destroy: :delete }
4 4
5 let(:admin) { Fabricate(:admin) } 5 let(:admin) { Fabricate(:admin) }
6 let(:user) { Fabricate(:user) } 6 let(:user) { Fabricate(:user) }
7 - let(:watcher) { Fabricate(:user_watcher, :app => app, :user => user) } 7 + let(:watcher) { Fabricate(:user_watcher, app: app, user: user) }
8 let(:unwatched_app) { Fabricate(:app) } 8 let(:unwatched_app) { Fabricate(:app) }
9 let(:app) { unwatched_app } 9 let(:app) { unwatched_app }
10 let(:watched_app1) do 10 let(:watched_app1) do
11 a = Fabricate(:app) 11 a = Fabricate(:app)
12 - Fabricate(:user_watcher, :user => user, :app => a) 12 + Fabricate(:user_watcher, user: user, app: a)
13 a 13 a
14 end 14 end
15 let(:watched_app2) do 15 let(:watched_app2) do
16 a = Fabricate(:app) 16 a = Fabricate(:app)
17 - Fabricate(:user_watcher, :user => user, :app => a) 17 + Fabricate(:user_watcher, user: user, app: a)
18 a 18 a
19 end 19 end
20 let(:err) do 20 let(:err) do
21 - Fabricate(:err, :problem => problem) 21 + Fabricate(:err, problem: problem)
22 end 22 end
23 let(:notice) do 23 let(:notice) do
24 - Fabricate(:notice, :err => err) 24 + Fabricate(:notice, err: err)
25 end 25 end
26 let(:problem) do 26 let(:problem) do
27 - Fabricate(:problem, :app => app) 27 + Fabricate(:problem, app: app)
28 end 28 end
29 - let(:problem_resolved) { Fabricate(:problem_resolved, :app => app) } 29 + let(:problem_resolved) { Fabricate(:problem_resolved, app: app) }
30 30
31 describe "GET /apps" do 31 describe "GET /apps" do
32 context 'when logged in as an admin' do 32 context 'when logged in as an admin' do
@@ -55,43 +55,43 @@ describe AppsController, type: &#39;controller&#39; do @@ -55,43 +55,43 @@ describe AppsController, type: &#39;controller&#39; do
55 end 55 end
56 56
57 it 'finds the app' do 57 it 'finds the app' do
58 - get :show, :id => app.id 58 + get :show, id: app.id
59 expect(controller.app).to eq app 59 expect(controller.app).to eq app
60 end 60 end
61 61
62 it "should not raise errors for app with err without notices" do 62 it "should not raise errors for app with err without notices" do
63 err 63 err
64 - expect{ get :show, :id => app.id }.to_not raise_error 64 + expect { get :show, id: app.id }.to_not raise_error
65 end 65 end
66 66
67 it "should list atom feed successfully" do 67 it "should list atom feed successfully" do
68 - get :show, :id => app.id, :format => "atom" 68 + get :show, id: app.id, format: "atom"
69 expect(response).to be_success 69 expect(response).to be_success
70 end 70 end
71 71
72 it "should list available watchers by name" do 72 it "should list available watchers by name" do
73 - Fabricate(:user, :name => "Carol")  
74 - Fabricate(:user, :name => "Alice")  
75 - Fabricate(:user, :name => "Betty") 73 + Fabricate(:user, name: "Carol")
  74 + Fabricate(:user, name: "Alice")
  75 + Fabricate(:user, name: "Betty")
76 76
77 - get :show, :id => app.id 77 + get :show, id: app.id
78 78
79 expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name)) 79 expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name))
80 end 80 end
81 81
82 context "pagination" do 82 context "pagination" do
83 before(:each) do 83 before(:each) do
84 - 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } 84 + 35.times { Fabricate(:err, problem: Fabricate(:problem, app: app)) }
85 end 85 end
86 86
87 it "should have default per_page value for user" do 87 it "should have default per_page value for user" do
88 - get :show, :id => app.id 88 + get :show, id: app.id
89 expect(controller.problems.to_a.size).to eq User::PER_PAGE 89 expect(controller.problems.to_a.size).to eq User::PER_PAGE
90 end 90 end
91 91
92 it "should be able to override default per_page value" do 92 it "should be able to override default per_page value" do
93 admin.update_attribute :per_page, 10 93 admin.update_attribute :per_page, 10
94 - get :show, :id => app.id 94 + get :show, id: app.id
95 expect(controller.problems.to_a.size).to eq 10 95 expect(controller.problems.to_a.size).to eq 10
96 end 96 end
97 end 97 end
@@ -103,14 +103,14 @@ describe AppsController, type: &#39;controller&#39; do @@ -103,14 +103,14 @@ describe AppsController, type: &#39;controller&#39; do
103 103
104 context 'and no params' do 104 context 'and no params' do
105 it 'shows only unresolved problems' do 105 it 'shows only unresolved problems' do
106 - get :show, :id => app.id 106 + get :show, id: app.id
107 expect(controller.problems.size).to eq 1 107 expect(controller.problems.size).to eq 1
108 end 108 end
109 end 109 end
110 110
111 context 'and all_problems=true params' do 111 context 'and all_problems=true params' do
112 it 'shows all errors' do 112 it 'shows all errors' do
113 - get :show, :id => app.id, :all_errs => true 113 + get :show, id: app.id, all_errs: true
114 expect(controller.problems.size).to eq 2 114 expect(controller.problems.size).to eq 2
115 end 115 end
116 end 116 end
@@ -120,41 +120,41 @@ describe AppsController, type: &#39;controller&#39; do @@ -120,41 +120,41 @@ describe AppsController, type: &#39;controller&#39; do
120 before(:each) do 120 before(:each) do
121 environments = %w(production test development staging) 121 environments = %w(production test development staging)
122 20.times do |i| 122 20.times do |i|
123 - Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) 123 + Fabricate(:problem, app: app, environment: environments[i % environments.length])
124 end 124 end
125 end 125 end
126 126
127 context 'no params' do 127 context 'no params' do
128 it 'shows errs for all environments' do 128 it 'shows errs for all environments' do
129 - get :show, :id => app.id 129 + get :show, id: app.id
130 expect(controller.problems.size).to eq 20 130 expect(controller.problems.size).to eq 20
131 end 131 end
132 end 132 end
133 133
134 context 'environment production' do 134 context 'environment production' do
135 it 'shows errs for just production' do 135 it 'shows errs for just production' do
136 - get :show, :id => app.id, :environment => 'production' 136 + get :show, id: app.id, environment: 'production'
137 expect(controller.problems.size).to eq 5 137 expect(controller.problems.size).to eq 5
138 end 138 end
139 end 139 end
140 140
141 context 'environment staging' do 141 context 'environment staging' do
142 it 'shows errs for just staging' do 142 it 'shows errs for just staging' do
143 - get :show, :id => app.id, :environment => 'staging' 143 + get :show, id: app.id, environment: 'staging'
144 expect(controller.problems.size).to eq 5 144 expect(controller.problems.size).to eq 5
145 end 145 end
146 end 146 end
147 147
148 context 'environment development' do 148 context 'environment development' do
149 it 'shows errs for just development' do 149 it 'shows errs for just development' do
150 - get :show, :id => app.id, :environment => 'development' 150 + get :show, id: app.id, environment: 'development'
151 expect(controller.problems.size).to eq 5 151 expect(controller.problems.size).to eq 5
152 end 152 end
153 end 153 end
154 154
155 context 'environment test' do 155 context 'environment test' do
156 it 'shows errs for just test' do 156 it 'shows errs for just test' do
157 - get :show, :id => app.id, :environment => 'test' 157 + get :show, id: app.id, environment: 'test'
158 expect(controller.problems.size).to eq 5 158 expect(controller.problems.size).to eq 5
159 end 159 end
160 end 160 end
@@ -166,7 +166,7 @@ describe AppsController, type: &#39;controller&#39; do @@ -166,7 +166,7 @@ describe AppsController, type: &#39;controller&#39; do
166 sign_in Fabricate(:user) 166 sign_in Fabricate(:user)
167 app = Fabricate(:app) 167 app = Fabricate(:app)
168 168
169 - get :show, :id => app.id 169 + get :show, id: app.id
170 expect(controller.app).to eq app 170 expect(controller.app).to eq app
171 end 171 end
172 end 172 end
@@ -186,9 +186,9 @@ describe AppsController, type: &#39;controller&#39; do @@ -186,9 +186,9 @@ describe AppsController, type: &#39;controller&#39; do
186 end 186 end
187 187
188 it "should copy attributes from an existing app" do 188 it "should copy attributes from an existing app" do
189 - @app = Fabricate(:app, :name => "do not copy",  
190 - :github_repo => "test/example")  
191 - get :new, :copy_attributes_from => @app.id 189 + @app = Fabricate(:app, name: "do not copy",
  190 + github_repo: "test/example")
  191 + get :new, copy_attributes_from: @app.id
192 expect(controller.app).to be_a(App) 192 expect(controller.app).to be_a(App)
193 expect(controller.app).to be_new_record 193 expect(controller.app).to be_new_record
194 expect(controller.app.name).to be_blank 194 expect(controller.app.name).to be_blank
@@ -199,7 +199,7 @@ describe AppsController, type: &#39;controller&#39; do @@ -199,7 +199,7 @@ describe AppsController, type: &#39;controller&#39; do
199 describe "GET /apps/:id/edit" do 199 describe "GET /apps/:id/edit" do
200 it 'finds the correct app' do 200 it 'finds the correct app' do
201 app = Fabricate(:app) 201 app = Fabricate(:app)
202 - get :edit, :id => app.id 202 + get :edit, id: app.id
203 expect(controller.app).to eq app 203 expect(controller.app).to eq app
204 end 204 end
205 end 205 end
@@ -216,12 +216,12 @@ describe AppsController, type: &#39;controller&#39; do @@ -216,12 +216,12 @@ describe AppsController, type: &#39;controller&#39; do
216 end 216 end
217 217
218 it "should redirect to the app page" do 218 it "should redirect to the app page" do
219 - post :create, :app => {} 219 + post :create, app: {}
220 expect(response).to redirect_to(app_path(@app)) 220 expect(response).to redirect_to(app_path(@app))
221 end 221 end
222 222
223 it "should display a message" do 223 it "should display a message" do
224 - post :create, :app => {} 224 + post :create, app: {}
225 expect(request.flash[:success]).to match(/success/) 225 expect(request.flash[:success]).to match(/success/)
226 end 226 end
227 end 227 end
@@ -234,12 +234,12 @@ describe AppsController, type: &#39;controller&#39; do @@ -234,12 +234,12 @@ describe AppsController, type: &#39;controller&#39; do
234 234
235 context "when the update is successful" do 235 context "when the update is successful" do
236 it "should redirect to the app page" do 236 it "should redirect to the app page" do
237 - put :update, :id => @app.id, :app => {} 237 + put :update, id: @app.id, app: {}
238 expect(response).to redirect_to(app_path(@app)) 238 expect(response).to redirect_to(app_path(@app))
239 end 239 end
240 240
241 it "should display a message" do 241 it "should display a message" do
242 - put :update, :id => @app.id, :app => {} 242 + put :update, id: @app.id, app: {}
243 expect(request.flash[:success]).to match(/success/) 243 expect(request.flash[:success]).to match(/success/)
244 end 244 end
245 end 245 end
@@ -247,14 +247,14 @@ describe AppsController, type: &#39;controller&#39; do @@ -247,14 +247,14 @@ describe AppsController, type: &#39;controller&#39; do
247 context "changing name" do 247 context "changing name" do
248 it "should redirect to app page" do 248 it "should redirect to app page" do
249 id = @app.id 249 id = @app.id
250 - put :update, :id => id, :app => {:name => "new name"} 250 + put :update, id: id, app: { name: "new name" }
251 expect(response).to redirect_to(app_path(id)) 251 expect(response).to redirect_to(app_path(id))
252 end 252 end
253 end 253 end
254 254
255 context "when the update is unsuccessful" do 255 context "when the update is unsuccessful" do
256 it "should render the edit page" do 256 it "should render the edit page" do
257 - put :update, :id => @app.id, :app => { :name => '' } 257 + put :update, id: @app.id, app: { name: '' }
258 expect(response).to render_template(:edit) 258 expect(response).to render_template(:edit)
259 end 259 end
260 end 260 end
@@ -265,30 +265,30 @@ describe AppsController, type: &#39;controller&#39; do @@ -265,30 +265,30 @@ describe AppsController, type: &#39;controller&#39; do
265 end 265 end
266 266
267 it "should parse legal csv values" do 267 it "should parse legal csv values" do
268 - put :update, :id => @app.id, :app => { :email_at_notices => '1, 4, 7,8, 10' } 268 + put :update, id: @app.id, app: { email_at_notices: '1, 4, 7,8, 10' }
269 @app.reload 269 @app.reload
270 expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10] 270 expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10]
271 end 271 end
272 context "failed parsing of CSV" do 272 context "failed parsing of CSV" do
273 it "should set the default value" do 273 it "should set the default value" do
274 - @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4])  
275 - put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } 274 + @app = Fabricate(:app, email_at_notices: [1, 2, 3, 4])
  275 + put :update, id: @app.id, app: { email_at_notices: 'asdf, -1,0,foobar,gd00,0,abc' }
276 @app.reload 276 @app.reload
277 expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices 277 expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices
278 end 278 end
279 279
280 it "should display a message" do 280 it "should display a message" do
281 - put :update, :id => @app.id, :app => { :email_at_notices => 'qwertyuiop' } 281 + put :update, id: @app.id, app: { email_at_notices: 'qwertyuiop' }
282 expect(request.flash[:error]).to match(/Couldn't parse/) 282 expect(request.flash[:error]).to match(/Couldn't parse/)
283 end 283 end
284 end 284 end
285 end 285 end
286 286
287 - context "setting up issue tracker", :cur => true do 287 + context "setting up issue tracker", cur: true do
288 context "unknown tracker type" do 288 context "unknown tracker type" do
289 before(:each) do 289 before(:each) do
290 - put :update, :id => @app.id, :app => { :issue_tracker_attributes => {  
291 - :type_tracker => 'unknown', :options => {:project_id => '1234', :api_token => '123123', :account => 'myapp'} 290 + put :update, id: @app.id, app: { issue_tracker_attributes: {
  291 + type_tracker: 'unknown', options: { project_id: '1234', api_token: '123123', account: 'myapp' }
292 } } 292 } }
293 @app.reload 293 @app.reload
294 end 294 end
@@ -306,24 +306,24 @@ describe AppsController, type: &#39;controller&#39; do @@ -306,24 +306,24 @@ describe AppsController, type: &#39;controller&#39; do
306 end 306 end
307 307
308 it "should find the app" do 308 it "should find the app" do
309 - delete :destroy, :id => @app.id 309 + delete :destroy, id: @app.id
310 expect(controller.app).to eq @app 310 expect(controller.app).to eq @app
311 end 311 end
312 312
313 it "should destroy the app" do 313 it "should destroy the app" do
314 - delete :destroy, :id => @app.id 314 + delete :destroy, id: @app.id
315 expect { 315 expect {
316 @app.reload 316 @app.reload
317 }.to raise_error(Mongoid::Errors::DocumentNotFound) 317 }.to raise_error(Mongoid::Errors::DocumentNotFound)
318 end 318 end
319 319
320 it "should display a message" do 320 it "should display a message" do
321 - delete :destroy, :id => @app.id 321 + delete :destroy, id: @app.id
322 expect(request.flash[:success]).to match(/success/) 322 expect(request.flash[:success]).to match(/success/)
323 end 323 end
324 324
325 it "should redirect to the apps page" do 325 it "should redirect to the apps page" do
326 - delete :destroy, :id => @app.id 326 + delete :destroy, id: @app.id
327 expect(response).to redirect_to(apps_path) 327 expect(response).to redirect_to(apps_path)
328 end 328 end
329 end 329 end
@@ -336,7 +336,7 @@ describe AppsController, type: &#39;controller&#39; do @@ -336,7 +336,7 @@ describe AppsController, type: &#39;controller&#39; do
336 end 336 end
337 337
338 it 'redirect to root with flash error' do 338 it 'redirect to root with flash error' do
339 - post :regenerate_api_key, :id => 'foo' 339 + post :regenerate_api_key, id: 'foo'
340 expect(request).to redirect_to root_path 340 expect(request).to redirect_to root_path
341 end 341 end
342 end 342 end
@@ -348,7 +348,7 @@ describe AppsController, type: &#39;controller&#39; do @@ -348,7 +348,7 @@ describe AppsController, type: &#39;controller&#39; do
348 348
349 it 'redirect_to app view' do 349 it 'redirect_to app view' do
350 expect do 350 expect do
351 - post :regenerate_api_key, :id => app.id 351 + post :regenerate_api_key, id: app.id
352 expect(request).to redirect_to edit_app_path(app) 352 expect(request).to redirect_to edit_app_path(app)
353 end.to change { app.reload.api_key } 353 end.to change { app.reload.api_key }
354 end 354 end
spec/controllers/comments_controller_spec.rb
1 describe CommentsController, type: 'controller' do 1 describe CommentsController, type: 'controller' do
2 let(:app) { Fabricate(:app) } 2 let(:app) { Fabricate(:app) }
3 - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } 3 + let(:err) { Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production")) }
4 4
5 describe "POST /apps/:app_id/errs/:id/comments/create" do 5 describe "POST /apps/:app_id/errs/:id/comments/create" do
6 render_views 6 render_views
@@ -14,8 +14,8 @@ describe CommentsController, type: &#39;controller&#39; do @@ -14,8 +14,8 @@ describe CommentsController, type: &#39;controller&#39; do
14 let(:user) { Fabricate(:user) } 14 let(:user) { Fabricate(:user) }
15 15
16 before(:each) do 16 before(:each) do
17 - post :create, :app_id => problem.app.id, :problem_id => problem.id,  
18 - :comment => { :body => "One test comment", :user_id => user.id } 17 + post :create, app_id: problem.app.id, problem_id: problem.id,
  18 + comment: { body: "One test comment", user_id: user.id }
19 problem.reload 19 problem.reload
20 end 20 end
21 21
@@ -41,12 +41,12 @@ describe CommentsController, type: &#39;controller&#39; do @@ -41,12 +41,12 @@ describe CommentsController, type: &#39;controller&#39; do
41 let(:comment) { problem.reload.comments.first } 41 let(:comment) { problem.reload.comments.first }
42 42
43 before(:each) do 43 before(:each) do
44 - delete :destroy, :app_id => problem.app.id, :problem_id => problem.id, :id => comment.id.to_s 44 + delete :destroy, app_id: problem.app.id, problem_id: problem.id, id: comment.id.to_s
45 problem.reload 45 problem.reload
46 end 46 end
47 47
48 it "should delete the comment" do 48 it "should delete the comment" do
49 - expect(problem.comments.detect{|c| c.id.to_s == comment.id }).to be nil 49 + expect(problem.comments.detect { |c| c.id.to_s == comment.id }).to be nil
50 end 50 end
51 51
52 it "should redirect to problem page" do 52 it "should redirect to problem page" do
spec/controllers/deploys_controller_spec.rb
@@ -10,30 +10,28 @@ describe DeploysController, type: &#39;controller&#39; do @@ -10,30 +10,28 @@ describe DeploysController, type: &#39;controller&#39; do
10 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', 10 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5',
11 'message' => 'johns first deploy' 11 'message' => 'johns first deploy'
12 } 12 }
13 - @app = Fabricate(:app_with_watcher, :notify_on_deploys => true, :api_key => 'APIKEY') 13 + @app = Fabricate(:app_with_watcher, notify_on_deploys: true, api_key: 'APIKEY')
14 end 14 end
15 15
16 it 'finds the app via the api key' do 16 it 'finds the app via the api key' do
17 expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) 17 expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app)
18 - post :create, :deploy => @params, :api_key => 'APIKEY' 18 + post :create, deploy: @params, api_key: 'APIKEY'
19 end 19 end
20 20
21 it 'creates a deploy' do 21 it 'creates a deploy' do
22 expect(App).to receive(:find_by_api_key!).and_return(@app) 22 expect(App).to receive(:find_by_api_key!).and_return(@app)
23 expect(@app.deploys).to receive(:create!). 23 expect(@app.deploys).to receive(:create!).
24 - with({  
25 - :username => 'john.doe',  
26 - :environment => 'production',  
27 - :repository => 'git@github.com/errbit/errbit.git',  
28 - :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5',  
29 - :message => 'johns first deploy'  
30 -  
31 - }).and_return(Fabricate(:deploy))  
32 - post :create, :deploy => @params, :api_key => 'APIKEY' 24 + with(
  25 + username: 'john.doe',
  26 + environment: 'production',
  27 + repository: 'git@github.com/errbit/errbit.git',
  28 + revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5',
  29 + message: 'johns first deploy').and_return(Fabricate(:deploy))
  30 + post :create, deploy: @params, api_key: 'APIKEY'
33 end 31 end
34 32
35 it 'sends an email notification when configured to do so' do 33 it 'sends an email notification when configured to do so' do
36 - post :create, :deploy => @params, :api_key => 'APIKEY' 34 + post :create, deploy: @params, api_key: 'APIKEY'
37 email = ActionMailer::Base.deliveries.last 35 email = ActionMailer::Base.deliveries.last
38 expect(email.to).to include(@app.watchers.first.email) 36 expect(email.to).to include(@app.watchers.first.email)
39 expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" 37 expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe"
@@ -44,7 +42,7 @@ describe DeploysController, type: &#39;controller&#39; do @@ -44,7 +42,7 @@ describe DeploysController, type: &#39;controller&#39; do
44 before(:each) do 42 before(:each) do
45 @deploy = Fabricate :deploy 43 @deploy = Fabricate :deploy
46 sign_in Fabricate(:admin) 44 sign_in Fabricate(:admin)
47 - get :index, :app_id => @deploy.app.id 45 + get :index, app_id: @deploy.app.id
48 end 46 end
49 47
50 it "should render successfully" do 48 it "should render successfully" do
spec/controllers/devise_sessions_controller_spec.rb
@@ -10,12 +10,12 @@ describe Devise::SessionsController, type: &#39;controller&#39; do @@ -10,12 +10,12 @@ describe Devise::SessionsController, type: &#39;controller&#39; do
10 let(:user) { Fabricate(:user) } 10 let(:user) { Fabricate(:user) }
11 11
12 it 'redirects to app index page if there are no apps for the user' do 12 it 'redirects to app index page if there are no apps for the user' do
13 - post :create, { :user => { 'email' => user.email, 'password' => user.password } } 13 + post :create, user: { 'email' => user.email, 'password' => user.password }
14 expect(response).to redirect_to(root_path) 14 expect(response).to redirect_to(root_path)
15 end 15 end
16 16
17 it 'displays a friendly error when credentials are invalid' do 17 it 'displays a friendly error when credentials are invalid' do
18 - post :create, { :user => { 'email' => 'whatever', 'password' => 'somethinginvalid' } } 18 + post :create, user: { 'email' => 'whatever', 'password' => 'somethinginvalid' }
19 expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') 19 expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid')
20 end 20 end
21 end 21 end
spec/controllers/notices_controller_spec.rb
1 describe NoticesController, type: 'controller' do 1 describe NoticesController, type: 'controller' do
2 - it_requires_authentication :for => { :locate => :get } 2 + it_requires_authentication for: { locate: :get }
3 3
4 let(:notice) { Fabricate(:notice) } 4 let(:notice) { Fabricate(:notice) }
5 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } 5 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read }
6 let(:app) { Fabricate(:app) } 6 let(:app) { Fabricate(:app) }
7 - let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice, :should_keep? => true) } 7 + let(:error_report) { double(valid?: true, generate_notice!: true, notice: notice, should_keep?: true) }
8 8
9 context 'notices API' do 9 context 'notices API' do
10 context "with bogus xml" do 10 context "with bogus xml" do
11 it "returns an error" do 11 it "returns an error" do
12 expect(request).to receive(:raw_post).and_return('<r><b>notxml</r>') 12 expect(request).to receive(:raw_post).and_return('<r><b>notxml</r>')
13 - post :create, :format => :xml 13 + post :create, format: :xml
14 expect(response.status).to eq(422) 14 expect(response.status).to eq(422)
15 expect(response.body).to eq('The provided XML was not well-formed') 15 expect(response.body).to eq('The provided XML was not well-formed')
16 end 16 end
@@ -24,7 +24,7 @@ describe NoticesController, type: &#39;controller&#39; do @@ -24,7 +24,7 @@ describe NoticesController, type: &#39;controller&#39; do
24 context "with xml pass in raw_port" do 24 context "with xml pass in raw_port" do
25 before do 25 before do
26 expect(request).to receive(:raw_post).and_return(xml) 26 expect(request).to receive(:raw_post).and_return(xml)
27 - post :create, :format => :xml 27 + post :create, format: :xml
28 end 28 end
29 29
30 it "generates a notice from raw xml [POST]" do 30 it "generates a notice from raw xml [POST]" do
@@ -37,7 +37,7 @@ describe NoticesController, type: &#39;controller&#39; do @@ -37,7 +37,7 @@ describe NoticesController, type: &#39;controller&#39; do
37 end 37 end
38 38
39 it "generates a notice from xml in a data param [POST]" do 39 it "generates a notice from xml in a data param [POST]" do
40 - post :create, :data => xml, :format => :xml 40 + post :create, data: xml, format: :xml
41 expect(response).to be_success 41 expect(response).to be_success
42 # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) 42 # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53)
43 # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb 43 # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb
@@ -46,15 +46,15 @@ describe NoticesController, type: &#39;controller&#39; do @@ -46,15 +46,15 @@ describe NoticesController, type: &#39;controller&#39; do
46 end 46 end
47 47
48 it "generates a notice from xml [GET]" do 48 it "generates a notice from xml [GET]" do
49 - get :create, :data => xml, :format => :xml 49 + get :create, data: xml, format: :xml
50 expect(response).to be_success 50 expect(response).to be_success
51 expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) 51 expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>})
52 expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) 52 expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>})
53 end 53 end
54 context "with an invalid API_KEY" do 54 context "with an invalid API_KEY" do
55 - let(:error_report) { double(:valid? => false) } 55 + let(:error_report) { double(valid?: false) }
56 it 'return 422' do 56 it 'return 422' do
57 - post :create, :format => :xml, :data => xml 57 + post :create, format: :xml, data: xml
58 expect(response.status).to eq 422 58 expect(response.status).to eq 422
59 end 59 end
60 end 60 end
@@ -62,7 +62,7 @@ describe NoticesController, type: &#39;controller&#39; do @@ -62,7 +62,7 @@ describe NoticesController, type: &#39;controller&#39; do
62 62
63 context "without params needed" do 63 context "without params needed" do
64 it 'return 400' do 64 it 'return 400' do
65 - post :create, :format => :xml 65 + post :create, format: :xml
66 expect(response.status).to eq 400 66 expect(response.status).to eq 400
67 expect(response.body).to eq 'Need a data params in GET or raw post data' 67 expect(response.body).to eq 'Need a data params in GET or raw post data'
68 end 68 end
@@ -77,9 +77,9 @@ describe NoticesController, type: &#39;controller&#39; do @@ -77,9 +77,9 @@ describe NoticesController, type: &#39;controller&#39; do
77 end 77 end
78 78
79 it "should locate notice and redirect to problem" do 79 it "should locate notice and redirect to problem" do
80 - problem = Fabricate(:problem, :app => app, :environment => "production")  
81 - notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem))  
82 - get :locate, :id => notice.id 80 + problem = Fabricate(:problem, app: app, environment: "production")
  81 + notice = Fabricate(:notice, err: Fabricate(:err, problem: problem))
  82 + get :locate, id: notice.id
83 expect(response).to redirect_to(app_problem_path(problem.app, problem)) 83 expect(response).to redirect_to(app_problem_path(problem.app, problem))
84 end 84 end
85 end 85 end
spec/controllers/problems_controller_spec.rb
1 describe ProblemsController, type: 'controller' do 1 describe ProblemsController, type: 'controller' do
2 - it_requires_authentication :for => {  
3 - :index => :get, :show => :get, :resolve => :put, :search => :get 2 + it_requires_authentication for: {
  3 + index: :get, show: :get, resolve: :put, search: :get
4 }, 4 },
5 - :params => {:app_id => 'dummyid', :id => 'dummyid'} 5 + params: { app_id: 'dummyid', id: 'dummyid' }
6 6
7 let(:app) { Fabricate(:app) } 7 let(:app) { Fabricate(:app) }
8 - let(:err) { Fabricate(:err, :problem => problem) } 8 + let(:err) { Fabricate(:err, problem: problem) }
9 let(:user) { Fabricate(:user) } 9 let(:user) { Fabricate(:user) }
10 - let(:problem) { Fabricate(:problem, :app => app, :environment => "production") } 10 + let(:problem) { Fabricate(:problem, app: app, environment: "production") }
11 11
12 describe "GET /problems" do 12 describe "GET /problems" do
13 before(:each) do 13 before(:each) do
14 sign_in user 14 sign_in user
15 - @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production"))).problem 15 + @problem = Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production"))).problem
16 end 16 end
17 17
18 context "pagination" do 18 context "pagination" do
@@ -36,7 +36,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -36,7 +36,7 @@ describe ProblemsController, type: &#39;controller&#39; do
36 before(:each) do 36 before(:each) do
37 environments = %w(production test development staging) 37 environments = %w(production test development staging)
38 20.times do |i| 38 20.times do |i|
39 - Fabricate(:problem, :environment => environments[i % environments.length]) 39 + Fabricate(:problem, environment: environments[i % environments.length])
40 end 40 end
41 end 41 end
42 42
@@ -49,28 +49,28 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -49,28 +49,28 @@ describe ProblemsController, type: &#39;controller&#39; do
49 49
50 context 'environment production' do 50 context 'environment production' do
51 it 'shows problems for just production' do 51 it 'shows problems for just production' do
52 - get :index, :environment => 'production' 52 + get :index, environment: 'production'
53 expect(controller.problems.size).to eq 6 53 expect(controller.problems.size).to eq 6
54 end 54 end
55 end 55 end
56 56
57 context 'environment staging' do 57 context 'environment staging' do
58 it 'shows problems for just staging' do 58 it 'shows problems for just staging' do
59 - get :index, :environment => 'staging' 59 + get :index, environment: 'staging'
60 expect(controller.problems.size).to eq 5 60 expect(controller.problems.size).to eq 5
61 end 61 end
62 end 62 end
63 63
64 context 'environment development' do 64 context 'environment development' do
65 it 'shows problems for just development' do 65 it 'shows problems for just development' do
66 - get :index, :environment => 'development' 66 + get :index, environment: 'development'
67 expect(controller.problems.size).to eq 5 67 expect(controller.problems.size).to eq 5
68 end 68 end
69 end 69 end
70 70
71 context 'environment test' do 71 context 'environment test' do
72 it 'shows problems for just test' do 72 it 'shows problems for just test' do
73 - get :index, :environment => 'test' 73 + get :index, environment: 'test'
74 expect(controller.problems.size).to eq 5 74 expect(controller.problems.size).to eq 5
75 end 75 end
76 end 76 end
@@ -82,11 +82,11 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -82,11 +82,11 @@ describe ProblemsController, type: &#39;controller&#39; do
82 sign_in Fabricate(:user) 82 sign_in Fabricate(:user)
83 problems = Kaminari.paginate_array((1..30).to_a) 83 problems = Kaminari.paginate_array((1..30).to_a)
84 3.times { problems << Fabricate(:err).problem } 84 3.times { problems << Fabricate(:err).problem }
85 - 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } 85 + 3.times { problems << Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem }
86 expect(Problem).to receive(:ordered_by).and_return( 86 expect(Problem).to receive(:ordered_by).and_return(
87 - double('proxy', :page => double('other_proxy', :per => problems)) 87 + double('proxy', page: double('other_proxy', per: problems))
88 ) 88 )
89 - get :index, :all_errs => true 89 + get :index, all_errs: true
90 expect(controller.problems).to eq problems 90 expect(controller.problems).to eq problems
91 end 91 end
92 end 92 end
@@ -95,8 +95,8 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -95,8 +95,8 @@ describe ProblemsController, type: &#39;controller&#39; do
95 before do 95 before do
96 sign_in user 96 sign_in user
97 @app = Fabricate(:app) 97 @app = Fabricate(:app)
98 - @problem1 = Fabricate(:problem, :app => @app, message: "Most important")  
99 - @problem2 = Fabricate(:problem, :app => @app, message: "Very very important") 98 + @problem1 = Fabricate(:problem, app: @app, message: "Most important")
  99 + @problem2 = Fabricate(:problem, app: @app, message: "Very very important")
100 end 100 end
101 101
102 it "renders successfully" do 102 it "renders successfully" do
@@ -110,7 +110,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -110,7 +110,7 @@ describe ProblemsController, type: &#39;controller&#39; do
110 end 110 end
111 111
112 it "searches problems for given string" do 112 it "searches problems for given string" do
113 - get :search, :search => "\"Most important\"" 113 + get :search, search: "\"Most important\""
114 expect(controller.problems).to include(@problem1) 114 expect(controller.problems).to include(@problem1)
115 expect(controller.problems).to_not include(@problem2) 115 expect(controller.problems).to_not include(@problem2)
116 end 116 end
@@ -122,35 +122,35 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -122,35 +122,35 @@ describe ProblemsController, type: &#39;controller&#39; do
122 end 122 end
123 123
124 it "finds the app" do 124 it "finds the app" do
125 - get :show, :app_id => app.id, :id => err.problem.id 125 + get :show, app_id: app.id, id: err.problem.id
126 expect(controller.app).to eq app 126 expect(controller.app).to eq app
127 end 127 end
128 128
129 it "finds the problem" do 129 it "finds the problem" do
130 - get :show, :app_id => app.id, :id => err.problem.id 130 + get :show, app_id: app.id, id: err.problem.id
131 expect(controller.problem).to eq err.problem 131 expect(controller.problem).to eq err.problem
132 end 132 end
133 133
134 it "successfully render page" do 134 it "successfully render page" do
135 - get :show, :app_id => app.id, :id => err.problem.id 135 + get :show, app_id: app.id, id: err.problem.id
136 expect(response).to be_success 136 expect(response).to be_success
137 end 137 end
138 138
139 context 'pagination' do 139 context 'pagination' do
140 let!(:notices) do 140 let!(:notices) do
141 3.times.reduce([]) do |coll, i| 141 3.times.reduce([]) do |coll, i|
142 - coll << Fabricate(:notice, :err => err, :created_at => (i.seconds.from_now)) 142 + coll << Fabricate(:notice, err: err, created_at: (i.seconds.from_now))
143 end 143 end
144 end 144 end
145 145
146 it "paginates the notices 1 at a time, starting with the most recent" do 146 it "paginates the notices 1 at a time, starting with the most recent" do
147 - get :show, :app_id => app.id, :id => err.problem.id 147 + get :show, app_id: app.id, id: err.problem.id
148 expect(assigns(:notices).entries.count).to eq 1 148 expect(assigns(:notices).entries.count).to eq 1
149 expect(assigns(:notices)).to include(notices.last) 149 expect(assigns(:notices)).to include(notices.last)
150 end 150 end
151 151
152 it "paginates the notices 1 at a time, based on then notice param" do 152 it "paginates the notices 1 at a time, based on then notice param" do
153 - get :show, :app_id => app.id, :id => err.problem.id, :notice => 3 153 + get :show, app_id: app.id, id: err.problem.id, notice: 3
154 expect(assigns(:notices).entries.count).to eq 1 154 expect(assigns(:notices).entries.count).to eq 1
155 expect(assigns(:notices)).to include(notices.first) 155 expect(assigns(:notices)).to include(notices.first)
156 end 156 end
@@ -165,29 +165,29 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -165,29 +165,29 @@ describe ProblemsController, type: &#39;controller&#39; do
165 end 165 end
166 166
167 it 'finds the app and the problem' do 167 it 'finds the app and the problem' do
168 - put :resolve, :app_id => @err.app.id, :id => @err.problem.id 168 + put :resolve, app_id: @err.app.id, id: @err.problem.id
169 expect(controller.app).to eq @err.app 169 expect(controller.app).to eq @err.app
170 expect(controller.problem).to eq @err.problem 170 expect(controller.problem).to eq @err.problem
171 end 171 end
172 172
173 it "should resolve the issue" do 173 it "should resolve the issue" do
174 - put :resolve, :app_id => @err.app.id, :id => @err.problem.id 174 + put :resolve, app_id: @err.app.id, id: @err.problem.id
175 expect(@err.problem.reload.resolved).to be(true) 175 expect(@err.problem.reload.resolved).to be(true)
176 end 176 end
177 177
178 it "should display a message" do 178 it "should display a message" do
179 - put :resolve, :app_id => @err.app.id, :id => @err.problem.id 179 + put :resolve, app_id: @err.app.id, id: @err.problem.id
180 expect(request.flash[:success]).to match(/Great news/) 180 expect(request.flash[:success]).to match(/Great news/)
181 end 181 end
182 182
183 it "should redirect to the app page" do 183 it "should redirect to the app page" do
184 - put :resolve, :app_id => @err.app.id, :id => @err.problem.id 184 + put :resolve, app_id: @err.app.id, id: @err.problem.id
185 expect(response).to redirect_to(app_path(@err.app)) 185 expect(response).to redirect_to(app_path(@err.app))
186 end 186 end
187 187
188 it "should redirect back to problems page" do 188 it "should redirect back to problems page" do
189 request.env["HTTP_REFERER"] = problems_path 189 request.env["HTTP_REFERER"] = problems_path
190 - put :resolve, :app_id => @err.app.id, :id => @err.problem.id 190 + put :resolve, app_id: @err.app.id, id: @err.problem.id
191 expect(response).to redirect_to(problems_path) 191 expect(response).to redirect_to(problems_path)
192 end 192 end
193 end 193 end
@@ -245,7 +245,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -245,7 +245,7 @@ describe ProblemsController, type: &#39;controller&#39; do
245 245
246 it "should render whatever the issue tracker says" do 246 it "should render whatever the issue tracker says" do
247 allow_any_instance_of(Issue).to receive(:render_body_args).and_return( 247 allow_any_instance_of(Issue).to receive(:render_body_args).and_return(
248 - [{ :inline => 'one <%= problem.id %> two' }]) 248 + [{ inline: 'one <%= problem.id %> two' }])
249 post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' 249 post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html'
250 line = issue_tracker.tracker.output.shift 250 line = issue_tracker.tracker.output.shift
251 expect(line[1]).to eq("one #{problem.id} two") 251 expect(line[1]).to eq("one #{problem.id} two")
@@ -268,10 +268,10 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -268,10 +268,10 @@ describe ProblemsController, type: &#39;controller&#39; do
268 end 268 end
269 269
270 context "problem with issue" do 270 context "problem with issue" do
271 - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :issue_link => "http://some.host")) } 271 + let(:err) { Fabricate(:err, problem: Fabricate(:problem, issue_link: "http://some.host")) }
272 272
273 before(:each) do 273 before(:each) do
274 - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id 274 + delete :unlink_issue, app_id: err.app.id, id: err.problem.id
275 err.problem.reload 275 err.problem.reload
276 end 276 end
277 277
@@ -288,7 +288,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -288,7 +288,7 @@ describe ProblemsController, type: &#39;controller&#39; do
288 let(:err) { Fabricate :err } 288 let(:err) { Fabricate :err }
289 289
290 before(:each) do 290 before(:each) do
291 - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id 291 + delete :unlink_issue, app_id: err.app.id, id: err.problem.id
292 err.problem.reload 292 err.problem.reload
293 end 293 end
294 294
@@ -301,33 +301,33 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -301,33 +301,33 @@ describe ProblemsController, type: &#39;controller&#39; do
301 describe "Bulk Actions" do 301 describe "Bulk Actions" do
302 before(:each) do 302 before(:each) do
303 sign_in user 303 sign_in user
304 - @problem1 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem  
305 - @problem2 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => false)).problem 304 + @problem1 = Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem
  305 + @problem2 = Fabricate(:err, problem: Fabricate(:problem, resolved: false)).problem
306 end 306 end
307 307
308 context "POST /problems/merge_several" do 308 context "POST /problems/merge_several" do
309 it "should require at least two problems" do 309 it "should require at least two problems" do
310 - post :merge_several, :problems => [@problem1.id.to_s] 310 + post :merge_several, problems: [@problem1.id.to_s]
311 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge') 311 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge')
312 end 312 end
313 313
314 it "should merge the problems" do 314 it "should merge the problems" do
315 - expect(ProblemMerge).to receive(:new).and_return(double(:merge => true))  
316 - post :merge_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] 315 + expect(ProblemMerge).to receive(:new).and_return(double(merge: true))
  316 + post :merge_several, problems: [@problem1.id.to_s, @problem2.id.to_s]
317 end 317 end
318 end 318 end
319 319
320 context "POST /problems/unmerge_several" do 320 context "POST /problems/unmerge_several" do
321 it "should require at least one problem" do 321 it "should require at least one problem" do
322 - post :unmerge_several, :problems => [] 322 + post :unmerge_several, problems: []
323 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') 323 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
324 end 324 end
325 325
326 it "should unmerge a merged problem" do 326 it "should unmerge a merged problem" do
327 merged_problem = Problem.merge!(@problem1, @problem2) 327 merged_problem = Problem.merge!(@problem1, @problem2)
328 expect(merged_problem.errs.length).to eq 2 328 expect(merged_problem.errs.length).to eq 2
329 - expect{  
330 - post :unmerge_several, :problems => [merged_problem.id.to_s] 329 + expect {
  330 + post :unmerge_several, problems: [merged_problem.id.to_s]
331 expect(merged_problem.reload.errs.length).to eq 1 331 expect(merged_problem.reload.errs.length).to eq 1
332 }.to change(Problem, :count).by(1) 332 }.to change(Problem, :count).by(1)
333 end 333 end
@@ -335,22 +335,22 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -335,22 +335,22 @@ describe ProblemsController, type: &#39;controller&#39; do
335 335
336 context "POST /problems/resolve_several" do 336 context "POST /problems/resolve_several" do
337 it "should require at least one problem" do 337 it "should require at least one problem" do
338 - post :resolve_several, :problems => [] 338 + post :resolve_several, problems: []
339 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') 339 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
340 end 340 end
341 341
342 it "should resolve the issue" do 342 it "should resolve the issue" do
343 - post :resolve_several, :problems => [@problem2.id.to_s] 343 + post :resolve_several, problems: [@problem2.id.to_s]
344 expect(@problem2.reload.resolved?).to eq true 344 expect(@problem2.reload.resolved?).to eq true
345 end 345 end
346 346
347 it "should display a message about 1 err" do 347 it "should display a message about 1 err" do
348 - post :resolve_several, :problems => [@problem2.id.to_s] 348 + post :resolve_several, problems: [@problem2.id.to_s]
349 expect(flash[:success]).to match(/1 error has been resolved/) 349 expect(flash[:success]).to match(/1 error has been resolved/)
350 end 350 end
351 351
352 it "should display a message about 2 errs" do 352 it "should display a message about 2 errs" do
353 - post :resolve_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] 353 + post :resolve_several, problems: [@problem1.id.to_s, @problem2.id.to_s]
354 expect(flash[:success]).to match(/2 errors have been resolved/) 354 expect(flash[:success]).to match(/2 errors have been resolved/)
355 expect(controller.selected_problems).to eq [@problem1, @problem2] 355 expect(controller.selected_problems).to eq [@problem1, @problem2]
356 end 356 end
@@ -358,20 +358,20 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -358,20 +358,20 @@ describe ProblemsController, type: &#39;controller&#39; do
358 358
359 context "POST /problems/unresolve_several" do 359 context "POST /problems/unresolve_several" do
360 it "should require at least one problem" do 360 it "should require at least one problem" do
361 - post :unresolve_several, :problems => [] 361 + post :unresolve_several, problems: []
362 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') 362 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
363 end 363 end
364 364
365 it "should unresolve the issue" do 365 it "should unresolve the issue" do
366 - post :unresolve_several, :problems => [@problem1.id.to_s] 366 + post :unresolve_several, problems: [@problem1.id.to_s]
367 expect(@problem1.reload.resolved?).to eq false 367 expect(@problem1.reload.resolved?).to eq false
368 end 368 end
369 end 369 end
370 370
371 context "POST /problems/destroy_several" do 371 context "POST /problems/destroy_several" do
372 it "should delete the problems" do 372 it "should delete the problems" do
373 - expect{  
374 - post :destroy_several, :problems => [@problem1.id.to_s] 373 + expect {
  374 + post :destroy_several, problems: [@problem1.id.to_s]
375 }.to change(Problem, :count).by(-1) 375 }.to change(Problem, :count).by(-1)
376 end 376 end
377 end 377 end
@@ -380,25 +380,25 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -380,25 +380,25 @@ describe ProblemsController, type: &#39;controller&#39; do
380 before do 380 before do
381 sign_in user 381 sign_in user
382 @app = Fabricate(:app) 382 @app = Fabricate(:app)
383 - @problem1 = Fabricate(:problem, :app => @app)  
384 - @problem2 = Fabricate(:problem, :app => @app) 383 + @problem1 = Fabricate(:problem, app: @app)
  384 + @problem2 = Fabricate(:problem, app: @app)
385 end 385 end
386 386
387 it "destroys all problems" do 387 it "destroys all problems" do
388 expect { 388 expect {
389 - post :destroy_all, :app_id => @app.id 389 + post :destroy_all, app_id: @app.id
390 }.to change(Problem, :count).by(-2) 390 }.to change(Problem, :count).by(-2)
391 expect(controller.app).to eq @app 391 expect(controller.app).to eq @app
392 end 392 end
393 393
394 it "should display a message" do 394 it "should display a message" do
395 - put :destroy_all, :app_id => @app.id 395 + put :destroy_all, app_id: @app.id
396 expect(request.flash[:success]).to match(/been deleted/) 396 expect(request.flash[:success]).to match(/been deleted/)
397 end 397 end
398 398
399 it "should redirect back to the app page" do 399 it "should redirect back to the app page" do
400 request.env["HTTP_REFERER"] = edit_app_path(@app) 400 request.env["HTTP_REFERER"] = edit_app_path(@app)
401 - put :destroy_all, :app_id => @app.id 401 + put :destroy_all, app_id: @app.id
402 expect(response).to redirect_to(edit_app_path(@app)) 402 expect(response).to redirect_to(edit_app_path(@app))
403 end 403 end
404 end 404 end
spec/controllers/site_config_controller_spec.rb
1 describe SiteConfigController, type: 'controller' do 1 describe SiteConfigController, type: 'controller' do
2 it_requires_admin_privileges for: { 2 it_requires_admin_privileges for: {
3 - index: :get, 3 + index: :get,
4 update: :put 4 update: :put
5 } 5 }
6 6
@@ -18,7 +18,7 @@ describe SiteConfigController, type: &#39;controller&#39; do @@ -18,7 +18,7 @@ describe SiteConfigController, type: &#39;controller&#39; do
18 it 'updates' do 18 it 'updates' do
19 put :update, site_config: { 19 put :update, site_config: {
20 notice_fingerprinter_attributes: { 20 notice_fingerprinter_attributes: {
21 - backtrace_lines: 3, 21 + backtrace_lines: 3,
22 environment_name: false 22 environment_name: false
23 } 23 }
24 } 24 }
spec/controllers/users/omniauth_callbacks_controller_spec.rb
@@ -4,9 +4,9 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do @@ -4,9 +4,9 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do
4 request.env["devise.mapping"] = Devise.mappings[:user] 4 request.env["devise.mapping"] = Devise.mappings[:user]
5 env = { 5 env = {
6 "omniauth.auth" => Hashie::Mash.new( 6 "omniauth.auth" => Hashie::Mash.new(
7 - :provider => 'github',  
8 - :extra => { :raw_info => { :login => login }},  
9 - :credentials => { :token => token } 7 + provider: 'github',
  8 + extra: { raw_info: { login: login } },
  9 + credentials: { token: token }
10 ) 10 )
11 } 11 }
12 allow(@controller).to receive(:env).and_return(env) 12 allow(@controller).to receive(:env).and_return(env)
@@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do @@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do
18 end 18 end
19 19
20 it "should show an error if another user already has that github login" do 20 it "should show an error if another user already has that github login" do
21 - Fabricate(:user, :github_login => "existing_user") 21 + Fabricate(:user, github_login: "existing_user")
22 stub_env_for_github_omniauth("existing_user") 22 stub_env_for_github_omniauth("existing_user")
23 get :github 23 get :github
24 24
spec/controllers/users_controller_spec.rb
1 describe UsersController, type: 'controller' do 1 describe UsersController, type: 'controller' do
2 it_requires_authentication 2 it_requires_authentication
3 - it_requires_admin_privileges :for => {  
4 - :index => :get,  
5 - :show => :get,  
6 - :new => :get,  
7 - :create => :post,  
8 - :destroy => :delete 3 + it_requires_admin_privileges for: {
  4 + index: :get,
  5 + show: :get,
  6 + new: :get,
  7 + create: :post,
  8 + destroy: :delete
9 } 9 }
10 10
11 let(:admin) { Fabricate(:admin) } 11 let(:admin) { Fabricate(:admin) }
@@ -23,14 +23,14 @@ describe UsersController, type: &#39;controller&#39; do @@ -23,14 +23,14 @@ describe UsersController, type: &#39;controller&#39; do
23 23
24 context "GET /users/:other_id/edit" do 24 context "GET /users/:other_id/edit" do
25 it "redirects to the home page" do 25 it "redirects to the home page" do
26 - get :edit, :id => other_user.id 26 + get :edit, id: other_user.id
27 expect(response).to redirect_to(root_path) 27 expect(response).to redirect_to(root_path)
28 end 28 end
29 end 29 end
30 30
31 context "GET /users/:my_id/edit" do 31 context "GET /users/:my_id/edit" do
32 it 'finds the user' do 32 it 'finds the user' do
33 - get :edit, :id => user.id 33 + get :edit, id: user.id
34 expect(controller.user).to eq(user) 34 expect(controller.user).to eq(user)
35 expect(response).to render_template 'edit' 35 expect(response).to render_template 'edit'
36 end 36 end
@@ -38,7 +38,7 @@ describe UsersController, type: &#39;controller&#39; do @@ -38,7 +38,7 @@ describe UsersController, type: &#39;controller&#39; do
38 38
39 context "PUT /users/:other_id" do 39 context "PUT /users/:other_id" do
40 it "redirects to the home page" do 40 it "redirects to the home page" do
41 - put :update, :id => other_user.id 41 + put :update, id: other_user.id
42 expect(response).to redirect_to(root_path) 42 expect(response).to redirect_to(root_path)
43 end 43 end
44 end 44 end
@@ -46,47 +46,47 @@ describe UsersController, type: &#39;controller&#39; do @@ -46,47 +46,47 @@ describe UsersController, type: &#39;controller&#39; do
46 context "PUT /users/:my_id/id" do 46 context "PUT /users/:my_id/id" do
47 context "when the update is successful" do 47 context "when the update is successful" do
48 it "sets a message to display" do 48 it "sets a message to display" do
49 - put :update, :id => user.to_param, :user => {:name => 'Kermit'} 49 + put :update, id: user.to_param, user: { name: 'Kermit' }
50 expect(request.flash[:success]).to include('updated') 50 expect(request.flash[:success]).to include('updated')
51 end 51 end
52 52
53 it "redirects to the user's page" do 53 it "redirects to the user's page" do
54 - put :update, :id => user.to_param, :user => {:name => 'Kermit'} 54 + put :update, id: user.to_param, user: { name: 'Kermit' }
55 expect(response).to redirect_to(user_path(user)) 55 expect(response).to redirect_to(user_path(user))
56 end 56 end
57 57
58 it "should not be able to become an admin" do 58 it "should not be able to become an admin" do
59 expect { 59 expect {
60 - put :update, :id => user.to_param, :user => {:admin => true} 60 + put :update, id: user.to_param, user: { admin: true }
61 }.to_not change { 61 }.to_not change {
62 user.reload.admin 62 user.reload.admin
63 }.from(false) 63 }.from(false)
64 end 64 end
65 65
66 it "should be able to set per_page option" do 66 it "should be able to set per_page option" do
67 - put :update, :id => user.to_param, :user => {:per_page => 555} 67 + put :update, id: user.to_param, user: { per_page: 555 }
68 expect(user.reload.per_page).to eq 555 68 expect(user.reload.per_page).to eq 555
69 end 69 end
70 70
71 it "should be able to set time_zone option" do 71 it "should be able to set time_zone option" do
72 - put :update, :id => user.to_param, :user => {:time_zone => "Warsaw"} 72 + put :update, id: user.to_param, user: { time_zone: "Warsaw" }
73 expect(user.reload.time_zone).to eq "Warsaw" 73 expect(user.reload.time_zone).to eq "Warsaw"
74 end 74 end
75 75
76 it "should be able to not set github_login option" do 76 it "should be able to not set github_login option" do
77 - put :update, :id => user.to_param, :user => {:github_login => " "} 77 + put :update, id: user.to_param, user: { github_login: " " }
78 expect(user.reload.github_login).to eq nil 78 expect(user.reload.github_login).to eq nil
79 end 79 end
80 80
81 it "should be able to set github_login option" do 81 it "should be able to set github_login option" do
82 - put :update, :id => user.to_param, :user => {:github_login => "awesome_name"} 82 + put :update, id: user.to_param, user: { github_login: "awesome_name" }
83 expect(user.reload.github_login).to eq "awesome_name" 83 expect(user.reload.github_login).to eq "awesome_name"
84 end 84 end
85 end 85 end
86 86
87 context "when the update is unsuccessful" do 87 context "when the update is unsuccessful" do
88 it "renders the edit page" do 88 it "renders the edit page" do
89 - put :update, :id => user.to_param, :user => {:name => nil} 89 + put :update, id: user.to_param, user: { name: nil }
90 expect(response).to render_template(:edit) 90 expect(response).to render_template(:edit)
91 end 91 end
92 end 92 end
@@ -109,7 +109,7 @@ describe UsersController, type: &#39;controller&#39; do @@ -109,7 +109,7 @@ describe UsersController, type: &#39;controller&#39; do
109 109
110 context "GET /users/:id" do 110 context "GET /users/:id" do
111 it 'finds the user' do 111 it 'finds the user' do
112 - get :show, :id => user.id 112 + get :show, id: user.id
113 expect(controller.user).to eq user 113 expect(controller.user).to eq user
114 end 114 end
115 end 115 end
@@ -124,14 +124,14 @@ describe UsersController, type: &#39;controller&#39; do @@ -124,14 +124,14 @@ describe UsersController, type: &#39;controller&#39; do
124 124
125 context "GET /users/:id/edit" do 125 context "GET /users/:id/edit" do
126 it 'finds the user' do 126 it 'finds the user' do
127 - get :edit, :id => user.id 127 + get :edit, id: user.id
128 expect(controller.user).to eq user 128 expect(controller.user).to eq user
129 end 129 end
130 end 130 end
131 131
132 context "POST /users" do 132 context "POST /users" do
133 context "when the create is successful" do 133 context "when the create is successful" do
134 - let(:attrs) { {:user => Fabricate.to_params(:user)} } 134 + let(:attrs) { { user: Fabricate.to_params(:user) } }
135 135
136 it "sets a message to display" do 136 it "sets a message to display" do
137 post :create, attrs 137 post :create, attrs
@@ -166,7 +166,7 @@ describe UsersController, type: &#39;controller&#39; do @@ -166,7 +166,7 @@ describe UsersController, type: &#39;controller&#39; do
166 end 166 end
167 167
168 it "renders the new page" do 168 it "renders the new page" do
169 - post :create, :user => { :username => 'foo' } 169 + post :create, user: { username: 'foo' }
170 expect(response).to render_template(:new) 170 expect(response).to render_template(:new)
171 end 171 end
172 end 172 end
@@ -175,20 +175,20 @@ describe UsersController, type: &#39;controller&#39; do @@ -175,20 +175,20 @@ describe UsersController, type: &#39;controller&#39; do
175 context "PUT /users/:id" do 175 context "PUT /users/:id" do
176 context "when the update is successful" do 176 context "when the update is successful" do
177 before { 177 before {
178 - put :update, :id => user.to_param, :user => user_params 178 + put :update, id: user.to_param, user: user_params
179 } 179 }
180 180
181 context "with normal params" do 181 context "with normal params" do
182 - let(:user_params) { {:name => 'Kermit'} } 182 + let(:user_params) { { name: 'Kermit' } }
183 it "sets a message to display" do 183 it "sets a message to display" do
184 - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.reload.name) 184 + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', name: user.reload.name)
185 expect(response).to redirect_to(user_path(user)) 185 expect(response).to redirect_to(user_path(user))
186 end 186 end
187 end 187 end
188 end 188 end
189 context "when the update is unsuccessful" do 189 context "when the update is unsuccessful" do
190 it "renders the edit page" do 190 it "renders the edit page" do
191 - put :update, :id => user.to_param, :user => {:name => nil} 191 + put :update, id: user.to_param, user: { name: nil }
192 expect(response).to render_template(:edit) 192 expect(response).to render_template(:edit)
193 end 193 end
194 end 194 end
@@ -196,15 +196,15 @@ describe UsersController, type: &#39;controller&#39; do @@ -196,15 +196,15 @@ describe UsersController, type: &#39;controller&#39; do
196 196
197 context "DELETE /users/:id" do 197 context "DELETE /users/:id" do
198 context "with a destroy success" do 198 context "with a destroy success" do
199 - let(:user_destroy) { double(:destroy => true) } 199 + let(:user_destroy) { double(destroy: true) }
200 200
201 before { 201 before {
202 expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) 202 expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy)
203 - delete :destroy, :id => user.id 203 + delete :destroy, id: user.id
204 } 204 }
205 205
206 it 'should destroy user' do 206 it 'should destroy user' do
207 - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', :name => user.name) 207 + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', name: user.name)
208 expect(response).to redirect_to(users_path) 208 expect(response).to redirect_to(users_path)
209 end 209 end
210 end 210 end
@@ -212,7 +212,7 @@ describe UsersController, type: &#39;controller&#39; do @@ -212,7 +212,7 @@ describe UsersController, type: &#39;controller&#39; do
212 context "with trying destroy himself" do 212 context "with trying destroy himself" do
213 before { 213 before {
214 expect(UserDestroy).to_not receive(:new) 214 expect(UserDestroy).to_not receive(:new)
215 - delete :destroy, :id => admin.id 215 + delete :destroy, id: admin.id
216 } 216 }
217 217
218 it 'should not destroy user' do 218 it 'should not destroy user' do
@@ -230,14 +230,14 @@ describe UsersController, type: &#39;controller&#39; do @@ -230,14 +230,14 @@ describe UsersController, type: &#39;controller&#39; do
230 ActionController::Parameters.new(user_param) 230 ActionController::Parameters.new(user_param)
231 ) 231 )
232 } 232 }
233 - let(:user_param) { {'user' => { :name => 'foo', :admin => true }} } 233 + let(:user_param) { { 'user' => { name: 'foo', admin: true } } }
234 it 'not have admin field' do 234 it 'not have admin field' do
235 - expect(controller.send(:user_params)).to eq({'name' => 'foo'}) 235 + expect(controller.send(:user_params)).to eq('name' => 'foo')
236 end 236 end
237 context "with password and password_confirmation empty?" do 237 context "with password and password_confirmation empty?" do
238 - let(:user_param) { {'user' => { :name => 'foo', 'password' => '', 'password_confirmation' => '' }} } 238 + let(:user_param) { { 'user' => { :name => 'foo', 'password' => '', 'password_confirmation' => '' } } }
239 it 'not have password and password_confirmation field' do 239 it 'not have password and password_confirmation field' do
240 - expect(controller.send(:user_params)).to eq({'name' => 'foo'}) 240 + expect(controller.send(:user_params)).to eq('name' => 'foo')
241 end 241 end
242 end 242 end
243 end 243 end
spec/controllers/watchers_controller_spec.rb
@@ -15,12 +15,12 @@ describe WatchersController, type: &#39;controller&#39; do @@ -15,12 +15,12 @@ describe WatchersController, type: &#39;controller&#39; do
15 let(:watcher) { app.watchers.first } 15 let(:watcher) { app.watchers.first }
16 16
17 before(:each) do 17 before(:each) do
18 - delete :destroy, :app_id => app.id, :id => watcher.user.id.to_s 18 + delete :destroy, app_id: app.id, id: watcher.user.id.to_s
19 problem.reload 19 problem.reload
20 end 20 end
21 21
22 it "should delete the watcher" do 22 it "should delete the watcher" do
23 - expect(app.watchers.detect{|w| w.id.to_s == watcher.id }).to be nil 23 + expect(app.watchers.detect { |w| w.id.to_s == watcher.id }).to be nil
24 end 24 end
25 25
26 it "should redirect to app page" do 26 it "should redirect to app page" do
@@ -34,7 +34,7 @@ describe WatchersController, type: &#39;controller&#39; do @@ -34,7 +34,7 @@ describe WatchersController, type: &#39;controller&#39; do
34 34
35 context "successful watcher update" do 35 context "successful watcher update" do
36 before(:each) do 36 before(:each) do
37 - put :update, :app_id => app.id, :id => user.id.to_s 37 + put :update, app_id: app.id, id: user.id.to_s
38 problem.reload 38 problem.reload
39 end 39 end
40 40
spec/decorators/app_decorator_spec.rb
1 describe AppDecorator do 1 describe AppDecorator do
2 describe "#email_at_notices" do 2 describe "#email_at_notices" do
3 it 'return the list separate by comma' do 3 it 'return the list separate by comma' do
4 - expect(AppDecorator.new(double(:email_at_notices => [2, 3])).email_at_notices).to eql '2, 3' 4 + expect(AppDecorator.new(double(email_at_notices: [2, 3])).email_at_notices).to eql '2, 3'
5 end 5 end
6 end 6 end
7 7
8 describe "#notify_user_display" do 8 describe "#notify_user_display" do
9 it 'return display:none if notify' do 9 it 'return display:none if notify' do
10 - expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;' 10 + expect(AppDecorator.new(double(notify_all_users: true)).notify_user_display).to eql 'display: none;'
11 end 11 end
12 12
13 it 'return blank if no notify' do 13 it 'return blank if no notify' do
14 - expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql '' 14 + expect(AppDecorator.new(double(notify_all_users: false)).notify_user_display).to eql ''
15 end 15 end
16 end 16 end
17 17
18 describe "#notify_err_display" do 18 describe "#notify_err_display" do
19 it 'return display:none if no notify' do 19 it 'return display:none if no notify' do
20 - expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;' 20 + expect(AppDecorator.new(double(notify_on_errs: false)).notify_err_display).to eql 'display: none;'
21 end 21 end
22 22
23 it 'return blank if no notify' do 23 it 'return blank if no notify' do
24 - expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql '' 24 + expect(AppDecorator.new(double(notify_on_errs: true)).notify_err_display).to eql ''
25 end 25 end
26 end 26 end
27 end 27 end
spec/decorators/backtrace_decorator_spec.rb
@@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do @@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do
3 described_class.new(Backtrace.new( 3 described_class.new(Backtrace.new(
4 lines: [ 4 lines: [
5 { number: 131, 5 { number: 131,
6 - file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', 6 + file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb',
7 method: :update_preferences }, 7 method: :update_preferences },
8 { number: 61, 8 { number: 61,
9 - file: '[PROJECT_ROOT]app/controllers/application_controller.rb', 9 + file: '[PROJECT_ROOT]app/controllers/application_controller.rb',
10 method: :call }, 10 method: :call },
11 { number: 182, 11 { number: 182,
12 - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', 12 + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb',
13 method: :call }, 13 method: :call },
14 { number: 384, 14 { number: 384,
15 - file: '[PROJECT_ROOT]app/models/account.rb', 15 + file: '[PROJECT_ROOT]app/models/account.rb',
16 method: :update_server_tag_scope }, 16 method: :update_server_tag_scope },
17 { number: 182, 17 { number: 182,
18 - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', 18 + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb',
19 method: :evaluate_method }, 19 method: :evaluate_method },
20 { number: 23, 20 { number: 23,
21 - file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', 21 + file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows',
22 method: '<main>' } 22 method: '<main>' }
23 ] 23 ]
24 )) 24 ))
spec/decorators/backtrace_line_decorator_spec.rb
@@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do @@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do
2 let(:backtrace_line) do 2 let(:backtrace_line) do
3 described_class.new( 3 described_class.new(
4 number: 884, 4 number: 884,
5 - file: '/path/to/file/ea315ea4.rb', 5 + file: '/path/to/file/ea315ea4.rb',
6 method: :instance_eval) 6 method: :instance_eval)
7 end 7 end
8 let(:backtrace_line_in_app) do 8 let(:backtrace_line_in_app) do
9 described_class.new( 9 described_class.new(
10 number: 884, 10 number: 884,
11 - file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb', 11 + file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
12 method: :instance_eval) 12 method: :instance_eval)
13 end 13 end
14 let(:app) { Fabricate(:app, github_repo: 'foo/bar') } 14 let(:app) { Fabricate(:app, github_repo: 'foo/bar') }
spec/decorators/issue_tracker_decorator_spec.rb
1 describe IssueTrackerDecorator do 1 describe IssueTrackerDecorator do
2 let(:fake_tracker) do 2 let(:fake_tracker) do
3 klass = Class.new(ErrbitPlugin::IssueTracker) { 3 klass = Class.new(ErrbitPlugin::IssueTracker) {
4 - def self.label; 'fake'; end  
5 - def self.note; 'a note'; end 4 + def self.label
  5 + 'fake'
  6 + end
  7 +
  8 + def self.note
  9 + 'a note'
  10 + end
6 11
7 def self.fields 12 def self.fields
8 { 13 {
9 - :foo => {:label => 'foo'},  
10 - :bar => {:label => 'bar'} 14 + foo: { label: 'foo' },
  15 + bar: { label: 'bar' }
11 } 16 }
12 end 17 end
13 18
14 - def configured?; true; end 19 + def configured?
  20 + true
  21 + end
15 } 22 }
16 klass.new 'nothing special' 23 klass.new 'nothing special'
17 end 24 end
spec/decorators/issue_tracker_field_decorator.rb
1 describe IssueTrackerFieldDecorator do 1 describe IssueTrackerFieldDecorator do
2 describe "#label" do 2 describe "#label" do
3 it 'return the label of field_info by default' do 3 it 'return the label of field_info by default' do
4 - expect(IssueTrackerFieldDecorator.new(:foo, {:label => 'hello'}).label).to eq 'hello' 4 + expect(IssueTrackerFieldDecorator.new(:foo, label: 'hello').label).to eq 'hello'
5 end 5 end
6 6
7 it 'return the key of field if no label define' do 7 it 'return the key of field if no label define' do
spec/decorators/issue_tracker_type_decorator_spec.rb
1 describe IssueTrackerDecorator do 1 describe IssueTrackerDecorator do
2 let(:fake_tracker_class) do 2 let(:fake_tracker_class) do
3 klass = Class.new(ErrbitPlugin::IssueTracker) do 3 klass = Class.new(ErrbitPlugin::IssueTracker) do
4 - def self.label; 'fake'; end  
5 - def self.note; 'a note'; end 4 + def self.label
  5 + 'fake'
  6 + end
  7 +
  8 + def self.note
  9 + 'a note'
  10 + end
6 11
7 def self.fields 12 def self.fields
8 { 13 {
9 - :foo => {:label => 'foo'},  
10 - :bar => {:label => 'bar'} 14 + foo: { label: 'foo' },
  15 + bar: { label: 'bar' }
11 } 16 }
12 end 17 end
13 18
14 def self.icons 19 def self.icons
15 { 20 {
16 one: ['text/plain', 'all your base are belong to us'], 21 one: ['text/plain', 'all your base are belong to us'],
17 - two: ['application/xml', '<root></root>'], 22 + two: ['application/xml', '<root></root>']
18 } 23 }
19 end 24 end
20 end 25 end
21 26
22 - allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return({  
23 - fake: klass  
24 - }) 27 + allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(fake: klass)
25 28
26 klass 29 klass
27 end 30 end
@@ -36,11 +39,11 @@ describe IssueTrackerDecorator do @@ -36,11 +39,11 @@ describe IssueTrackerDecorator do
36 end 39 end
37 40
38 describe "#fields" do 41 describe "#fields" do
39 - it 'return all Fields define decorate' do 42 + it 'return all FIELDS define decorate' do
40 decorator.fields do |itf| 43 decorator.fields do |itf|
41 expect(itf).to be_a(IssueTrackerFieldDecorator) 44 expect(itf).to be_a(IssueTrackerFieldDecorator)
42 expect([:foo, :bar]).to be_include(itf.object) 45 expect([:foo, :bar]).to be_include(itf.object)
43 - expect([{:label => 'foo'}, {:label => 'bar'}]).to be_include(itf.field_info) 46 + expect([{ label: 'foo' }, { label: 'bar' }]).to be_include(itf.field_info)
44 end 47 end
45 end 48 end
46 end 49 end
spec/decorators/watcher_decorator_spec.rb
@@ -2,13 +2,13 @@ describe WatcherDecorator do @@ -2,13 +2,13 @@ describe WatcherDecorator do
2 describe "#email_choosen" do 2 describe "#email_choosen" do
3 context "with email define" do 3 context "with email define" do
4 it 'return blank' do 4 it 'return blank' do
5 - expect(WatcherDecorator.new(double(:email => 'foo')).email_choosen).to eql '' 5 + expect(WatcherDecorator.new(double(email: 'foo')).email_choosen).to eql ''
6 end 6 end
7 end 7 end
8 8
9 context "without email define" do 9 context "without email define" do
10 it 'return choosen' do 10 it 'return choosen' do
11 - expect(WatcherDecorator.new(double(:email => '')).email_choosen).to eql 'chosen' 11 + expect(WatcherDecorator.new(double(email: '')).email_choosen).to eql 'chosen'
12 end 12 end
13 end 13 end
14 end 14 end