Commit 9d51326c1930ce03eb7b3f70c916d2fcd0e4a469
Exists in
master
and in
1 other branch
Merge pull request #988 from rud/chore/fix-more-whitespace
Rubocop: indentation consistency fixes
Showing
66 changed files
with
316 additions
and
438 deletions
Show diff stats
.rubocop.yml
| @@ -21,7 +21,19 @@ Style/IndentationConsistency: | @@ -21,7 +21,19 @@ Style/IndentationConsistency: | ||
| 21 | # modifier keywords shall be indented the same as public methods and that | 21 | # modifier keywords shall be indented the same as public methods and that |
| 22 | # protected and private members shall be indented one step more than the | 22 | # protected and private members shall be indented one step more than the |
| 23 | # modifiers. | 23 | # modifiers. |
| 24 | - EnforcedStyle: rails | 24 | + EnforcedStyle: rails |
| 25 | 25 | ||
| 26 | Style/AccessModifierIndentation: | 26 | Style/AccessModifierIndentation: |
| 27 | EnforcedStyle: outdent | 27 | EnforcedStyle: outdent |
| 28 | + | ||
| 29 | +Style/AlignParameters: | ||
| 30 | + EnforcedStyle: with_fixed_indentation | ||
| 31 | + | ||
| 32 | +Style/IndentHash: | ||
| 33 | + EnforcedStyle: consistent | ||
| 34 | + | ||
| 35 | +Style/SpaceAroundOperators: | ||
| 36 | + MultiSpaceAllowedForOperators: | ||
| 37 | + - '=' | ||
| 38 | + - '=>' | ||
| 39 | + - '||=' |
.rubocop_todo.yml
| @@ -64,29 +64,12 @@ Style/AlignHash: | @@ -64,29 +64,12 @@ Style/AlignHash: | ||
| 64 | - 'spec/controllers/problems_controller_spec.rb' | 64 | - 'spec/controllers/problems_controller_spec.rb' |
| 65 | - 'spec/models/problem_spec.rb' | 65 | - 'spec/models/problem_spec.rb' |
| 66 | 66 | ||
| 67 | -# Offense count: 6 | ||
| 68 | -# Cop supports --auto-correct. | ||
| 69 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 70 | -Style/AlignParameters: | ||
| 71 | - Exclude: | ||
| 72 | - - 'app/helpers/apps_helper.rb' | ||
| 73 | - - 'app/models/app.rb' | ||
| 74 | - - 'app/models/notification_services/gtalk_service.rb' | ||
| 75 | - - 'config/initializers/devise.rb' | ||
| 76 | - | ||
| 77 | # Offense count: 105 | 67 | # Offense count: 105 |
| 78 | # Cop supports --auto-correct. | 68 | # Cop supports --auto-correct. |
| 79 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | 69 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. |
| 80 | Style/BlockDelimiters: | 70 | Style/BlockDelimiters: |
| 81 | Enabled: false | 71 | Enabled: false |
| 82 | 72 | ||
| 83 | -# Offense count: 2 | ||
| 84 | -# Cop supports --auto-correct. | ||
| 85 | -Style/BlockEndNewline: | ||
| 86 | - Exclude: | ||
| 87 | - - 'spec/models/error_report_spec.rb' | ||
| 88 | - - 'spec/views/apps/show.atom.builder_spec.rb' | ||
| 89 | - | ||
| 90 | # Offense count: 49 | 73 | # Offense count: 49 |
| 91 | # Cop supports --auto-correct. | 74 | # Cop supports --auto-correct. |
| 92 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 75 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| @@ -195,39 +178,6 @@ Style/IfUnlessModifier: | @@ -195,39 +178,6 @@ Style/IfUnlessModifier: | ||
| 195 | - 'app/models/notice.rb' | 178 | - 'app/models/notice.rb' |
| 196 | - 'app/models/user.rb' | 179 | - 'app/models/user.rb' |
| 197 | 180 | ||
| 198 | -# Offense count: 5 | ||
| 199 | -# Cop supports --auto-correct. | ||
| 200 | -Style/IndentArray: | ||
| 201 | - Exclude: | ||
| 202 | - - 'app/models/notification_services/gtalk_service.rb' | ||
| 203 | - - 'app/models/notification_services/hoiio_service.rb' | ||
| 204 | - - 'app/models/notification_services/pushover_service.rb' | ||
| 205 | - - 'app/models/notification_services/slack_service.rb' | ||
| 206 | - - 'spec/models/notification_service/slack_service_spec.rb' | ||
| 207 | - | ||
| 208 | -# Offense count: 72 | ||
| 209 | -# Cop supports --auto-correct. | ||
| 210 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 211 | -Style/IndentHash: | ||
| 212 | - Enabled: false | ||
| 213 | - | ||
| 214 | -# Offense count: 27 | ||
| 215 | -# Cop supports --auto-correct. | ||
| 216 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 217 | -Style/IndentationConsistency: | ||
| 218 | - Exclude: | ||
| 219 | - - 'app/controllers/apps_controller.rb' | ||
| 220 | - - 'app/controllers/comments_controller.rb' | ||
| 221 | - - 'app/controllers/deploys_controller.rb' | ||
| 222 | - - 'app/controllers/users_controller.rb' | ||
| 223 | - - 'app/helpers/application_helper.rb' | ||
| 224 | - - 'app/models/app.rb' | ||
| 225 | - - 'app/models/comment.rb' | ||
| 226 | - - 'app/models/deploy.rb' | ||
| 227 | - - 'app/models/problem.rb' | ||
| 228 | - - 'app/models/watcher.rb' | ||
| 229 | - - 'lib/hoptoad.rb' | ||
| 230 | - | ||
| 231 | # Offense count: 6 | 181 | # Offense count: 6 |
| 232 | # Cop supports --auto-correct. | 182 | # Cop supports --auto-correct. |
| 233 | Style/Lambda: | 183 | Style/Lambda: |
| @@ -354,44 +304,18 @@ Style/SingleSpaceBeforeFirstArg: | @@ -354,44 +304,18 @@ Style/SingleSpaceBeforeFirstArg: | ||
| 354 | - 'spec/fabricators/notice_fabricator.rb' | 304 | - 'spec/fabricators/notice_fabricator.rb' |
| 355 | - 'spec/fabricators/user_fabricator.rb' | 305 | - 'spec/fabricators/user_fabricator.rb' |
| 356 | 306 | ||
| 357 | -# Offense count: 43 | ||
| 358 | -# Cop supports --auto-correct. | ||
| 359 | -Style/SpaceAfterComma: | ||
| 360 | - Enabled: false | ||
| 361 | - | ||
| 362 | # Offense count: 2 | 307 | # Offense count: 2 |
| 363 | # Cop supports --auto-correct. | 308 | # Cop supports --auto-correct. |
| 364 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 309 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| 365 | Style/SpaceAroundEqualsInParameterDefault: | 310 | Style/SpaceAroundEqualsInParameterDefault: |
| 366 | Enabled: false | 311 | Enabled: false |
| 367 | 312 | ||
| 368 | -# Offense count: 28 | ||
| 369 | -# Cop supports --auto-correct. | ||
| 370 | -# Configuration parameters: MultiSpaceAllowedForOperators. | ||
| 371 | -Style/SpaceAroundOperators: | ||
| 372 | - Exclude: | ||
| 373 | - - 'app/controllers/api/v1/problems_controller.rb' | ||
| 374 | - - 'app/helpers/application_helper.rb' | ||
| 375 | - - 'app/helpers/apps_helper.rb' | ||
| 376 | - - 'app/helpers/hash_helper.rb' | ||
| 377 | - - 'app/models/issue_tracker.rb' | ||
| 378 | - - 'app/models/notification_service.rb' | ||
| 379 | - - 'config/load.rb' | ||
| 380 | - - 'spec/controllers/problems_controller_spec.rb' | ||
| 381 | - - 'spec/models/notice_observer_spec.rb' | ||
| 382 | - | ||
| 383 | # Offense count: 27 | 313 | # Offense count: 27 |
| 384 | # Cop supports --auto-correct. | 314 | # Cop supports --auto-correct. |
| 385 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 315 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| 386 | Style/SpaceBeforeBlockBraces: | 316 | Style/SpaceBeforeBlockBraces: |
| 387 | Enabled: false | 317 | Enabled: false |
| 388 | 318 | ||
| 389 | -# Offense count: 1 | ||
| 390 | -# Cop supports --auto-correct. | ||
| 391 | -Style/SpaceBeforeComma: | ||
| 392 | - Exclude: | ||
| 393 | - - 'app/decorators/backtrace_line_decorator.rb' | ||
| 394 | - | ||
| 395 | # Offense count: 3 | 319 | # Offense count: 3 |
| 396 | # Cop supports --auto-correct. | 320 | # Cop supports --auto-correct. |
| 397 | Style/SpaceBeforeComment: | 321 | Style/SpaceBeforeComment: |
| @@ -423,41 +347,12 @@ Style/SpaceInsideBrackets: | @@ -423,41 +347,12 @@ Style/SpaceInsideBrackets: | ||
| 423 | Style/SpaceInsideHashLiteralBraces: | 347 | Style/SpaceInsideHashLiteralBraces: |
| 424 | Enabled: false | 348 | Enabled: false |
| 425 | 349 | ||
| 426 | -# Offense count: 23 | ||
| 427 | -# Cop supports --auto-correct. | ||
| 428 | -Style/SpaceInsideParens: | ||
| 429 | - Exclude: | ||
| 430 | - - 'spec/controllers/api/v1/problems_controller_spec.rb' | ||
| 431 | - - 'spec/controllers/comments_controller_spec.rb' | ||
| 432 | - - 'spec/controllers/problems_controller_spec.rb' | ||
| 433 | - - 'spec/interactors/problem_merge_spec.rb' | ||
| 434 | - - 'spec/mailers/mailer_spec.rb' | ||
| 435 | - - 'spec/models/notice_observer_spec.rb' | ||
| 436 | - - 'spec/models/notice_spec.rb' | ||
| 437 | - | ||
| 438 | -# Offense count: 9 | ||
| 439 | -# Cop supports --auto-correct. | ||
| 440 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 441 | -Style/SpaceInsideStringInterpolation: | ||
| 442 | - Exclude: | ||
| 443 | - - 'app/models/issue.rb' | ||
| 444 | - - 'app/models/notification_service.rb' | ||
| 445 | - - 'app/models/notification_services/flowdock_service.rb' | ||
| 446 | - - 'app/models/notification_services/hoiio_service.rb' | ||
| 447 | - - 'spec/controllers/problems_controller_spec.rb' | ||
| 448 | - | ||
| 449 | # Offense count: 873 | 350 | # Offense count: 873 |
| 450 | # Cop supports --auto-correct. | 351 | # Cop supports --auto-correct. |
| 451 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 352 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| 452 | Style/StringLiterals: | 353 | Style/StringLiterals: |
| 453 | Enabled: false | 354 | Enabled: false |
| 454 | 355 | ||
| 455 | -# Offense count: 1 | ||
| 456 | -# Cop supports --auto-correct. | ||
| 457 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 458 | -Style/StringLiteralsInInterpolation: | ||
| 459 | - Enabled: false | ||
| 460 | - | ||
| 461 | # Offense count: 3 | 356 | # Offense count: 3 |
| 462 | # Cop supports --auto-correct. | 357 | # Cop supports --auto-correct. |
| 463 | # Configuration parameters: IgnoredMethods. | 358 | # Configuration parameters: IgnoredMethods. |
| @@ -467,12 +362,6 @@ Style/SymbolProc: | @@ -467,12 +362,6 @@ Style/SymbolProc: | ||
| 467 | - 'app/models/deploy.rb' | 362 | - 'app/models/deploy.rb' |
| 468 | - 'spec/models/deploy_spec.rb' | 363 | - 'spec/models/deploy_spec.rb' |
| 469 | 364 | ||
| 470 | -# Offense count: 21 | ||
| 471 | -# Cop supports --auto-correct. | ||
| 472 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 473 | -Style/TrailingBlankLines: | ||
| 474 | - Enabled: false | ||
| 475 | - | ||
| 476 | # Offense count: 13 | 365 | # Offense count: 13 |
| 477 | # Cop supports --auto-correct. | 366 | # Cop supports --auto-correct. |
| 478 | # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. | 367 | # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. |
app/controllers/api/v1/problems_controller.rb
| @@ -24,7 +24,7 @@ class Api::V1::ProblemsController < ApplicationController | @@ -24,7 +24,7 @@ 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 |
app/controllers/apps_controller.rb
| @@ -103,43 +103,43 @@ protected | @@ -103,43 +103,43 @@ protected | ||
| 103 | end | 103 | end |
| 104 | end | 104 | end |
| 105 | 105 | ||
| 106 | - def plug_params(app) | ||
| 107 | - app.watchers.build if app.watchers.none? | ||
| 108 | - app.issue_tracker ||= IssueTracker.new | ||
| 109 | - app.notification_service = NotificationService.new unless app.notification_service_configured? | ||
| 110 | - app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from] | ||
| 111 | - end | 106 | + def plug_params(app) |
| 107 | + app.watchers.build if app.watchers.none? | ||
| 108 | + app.issue_tracker ||= IssueTracker.new | ||
| 109 | + app.notification_service = NotificationService.new unless app.notification_service_configured? | ||
| 110 | + app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from] | ||
| 111 | + end | ||
| 112 | 112 | ||
| 113 | - # email_at_notices is edited as a string, and stored as an array. | ||
| 114 | - def parse_email_at_notices_or_set_default | ||
| 115 | - if params[:app] && (val = params[:app][:email_at_notices]) | ||
| 116 | - # Sanitize negative values, split on comma, | ||
| 117 | - # strip, parse as integer, remove all '0's. | ||
| 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} | ||
| 120 | - if email_at_notices.any? | ||
| 121 | - params[:app][:email_at_notices] = email_at_notices | ||
| 122 | - else | ||
| 123 | - default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices | ||
| 124 | - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
| 125 | - end | 113 | + # email_at_notices is edited as a string, and stored as an array. |
| 114 | + def parse_email_at_notices_or_set_default | ||
| 115 | + if params[:app] && (val = params[:app][:email_at_notices]) | ||
| 116 | + # Sanitize negative values, split on comma, | ||
| 117 | + # strip, parse as integer, remove all '0's. | ||
| 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} | ||
| 120 | + if email_at_notices.any? | ||
| 121 | + params[:app][:email_at_notices] = email_at_notices | ||
| 122 | + else | ||
| 123 | + default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices | ||
| 124 | + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
| 126 | end | 125 | end |
| 127 | end | 126 | end |
| 127 | + end | ||
| 128 | 128 | ||
| 129 | - def parse_notice_at_notices_or_set_default | ||
| 130 | - if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) | ||
| 131 | - # Sanitize negative values, split on comma, | ||
| 132 | - # strip, parse as integer, remove all '0's. | ||
| 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 } | ||
| 135 | - if notify_at_notices.any? | ||
| 136 | - params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices | ||
| 137 | - else | ||
| 138 | - default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices | ||
| 139 | - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
| 140 | - end | 129 | + def parse_notice_at_notices_or_set_default |
| 130 | + if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) | ||
| 131 | + # Sanitize negative values, split on comma, | ||
| 132 | + # strip, parse as integer, remove all '0's. | ||
| 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 } | ||
| 135 | + if notify_at_notices.any? | ||
| 136 | + params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices | ||
| 137 | + else | ||
| 138 | + default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices | ||
| 139 | + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
| 141 | end | 140 | end |
| 142 | end | 141 | end |
| 142 | + end | ||
| 143 | 143 | ||
| 144 | private def app_params | 144 | private def app_params |
| 145 | params.require(:app).permit! | 145 | params.require(:app).permit! |
app/controllers/comments_controller.rb
| @@ -30,11 +30,11 @@ protected | @@ -30,11 +30,11 @@ protected | ||
| 30 | @app = App.find(params[:app_id]) | 30 | @app = App.find(params[:app_id]) |
| 31 | end | 31 | end |
| 32 | 32 | ||
| 33 | - def find_problem | ||
| 34 | - @problem = @app.problems.find(params[:problem_id]) | ||
| 35 | - end | 33 | + def find_problem |
| 34 | + @problem = @app.problems.find(params[:problem_id]) | ||
| 35 | + end | ||
| 36 | 36 | ||
| 37 | - def comment_params | ||
| 38 | - params.require(:comment).permit! | ||
| 39 | - end | 37 | + def comment_params |
| 38 | + params.require(:comment).permit! | ||
| 39 | + end | ||
| 40 | end | 40 | end |
app/controllers/deploys_controller.rb
| @@ -30,14 +30,13 @@ private | @@ -30,14 +30,13 @@ private | ||
| 30 | end | 30 | end |
| 31 | end | 31 | end |
| 32 | 32 | ||
| 33 | - # handle Heroku's HTTP post deployhook format | ||
| 34 | - def heroku_deploy | ||
| 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], | ||
| 40 | - } | ||
| 41 | - end | 33 | + # handle Heroku's HTTP post deployhook format |
| 34 | + def heroku_deploy | ||
| 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], | ||
| 40 | + } | ||
| 41 | + end | ||
| 42 | end | 42 | end |
| 43 | - |
app/controllers/users_controller.rb
| @@ -63,7 +63,7 @@ protected | @@ -63,7 +63,7 @@ protected | ||
| 63 | end | 63 | end |
| 64 | 64 | ||
| 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 |
| @@ -73,4 +73,3 @@ protected | @@ -73,4 +73,3 @@ protected | ||
| 73 | @user_password_params ||= params[:user] ? params.require(:user).permit(:password, :password_confirmation) : {} | 73 | @user_password_params ||= params[:user] ? params.require(:user).permit(:password, :password_confirmation) : {} |
| 74 | end | 74 | end |
| 75 | end | 75 | end |
| 76 | - |
app/decorators/backtrace_line_decorator.rb
| @@ -79,7 +79,7 @@ private | @@ -79,7 +79,7 @@ private | ||
| 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 |
app/decorators/issue_tracker_field_decorator.rb
| @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator < Draper::Decorator | @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator < 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
| @@ -6,7 +6,7 @@ class IssueTrackerTypeDecorator < Draper::Decorator | @@ -6,7 +6,7 @@ class IssueTrackerTypeDecorator < Draper::Decorator | ||
| 6 | def icons | 6 | def icons |
| 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])}"; c |
| 11 | end | 11 | end |
| 12 | end | 12 | end |
app/helpers/application_helper.rb
| @@ -5,9 +5,9 @@ module ApplicationHelper | @@ -5,9 +5,9 @@ module ApplicationHelper | ||
| 5 | 5 | ||
| 6 | def generate_problem_ical(notices) | 6 | def generate_problem_ical(notices) |
| 7 | RiCal.Calendar do |cal| | 7 | RiCal.Calendar do |cal| |
| 8 | - notices.each_with_index do |notice,idx| | 8 | + notices.each_with_index do |notice, idx| |
| 9 | cal.event do |event| | 9 | cal.event do |event| |
| 10 | - event.summary = "#{idx+1} #{notice.message}" | 10 | + event.summary = "#{idx + 1} #{notice.message}" |
| 11 | event.description = notice.url if notice.url | 11 | event.description = notice.url if notice.url |
| 12 | event.dtstart = notice.created_at.utc | 12 | event.dtstart = notice.created_at.utc |
| 13 | event.dtend = notice.created_at.utc + 60.minutes | 13 | event.dtend = notice.created_at.utc + 60.minutes |
| @@ -21,9 +21,9 @@ module ApplicationHelper | @@ -21,9 +21,9 @@ module ApplicationHelper | ||
| 21 | 21 | ||
| 22 | def generate_ical(deploys) | 22 | def generate_ical(deploys) |
| 23 | RiCal.Calendar { |cal| | 23 | RiCal.Calendar { |cal| |
| 24 | - deploys.each_with_index do |deploy,idx| | 24 | + deploys.each_with_index do |deploy, idx| |
| 25 | cal.event do |event| | 25 | cal.event do |event| |
| 26 | - event.summary = "#{idx+1} #{deploy.repository}" | 26 | + event.summary = "#{idx + 1} #{deploy.repository}" |
| 27 | event.description = deploy.revision.to_s | 27 | event.description = deploy.revision.to_s |
| 28 | event.dtstart = deploy.created_at.utc | 28 | event.dtstart = deploy.created_at.utc |
| 29 | event.dtend = deploy.created_at.utc + 60.minutes | 29 | event.dtend = deploy.created_at.utc + 60.minutes |
| @@ -81,7 +81,7 @@ private | @@ -81,7 +81,7 @@ private | ||
| 81 | tallies.values.inject(0) {|sum, n| sum + n} | 81 | tallies.values.inject(0) {|sum, n| sum + n} |
| 82 | end | 82 | end |
| 83 | 83 | ||
| 84 | - def head_size | ||
| 85 | - 4 | ||
| 86 | - end | 84 | + def head_size |
| 85 | + 4 | ||
| 86 | + end | ||
| 87 | end | 87 | end |
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
| @@ -11,6 +11,6 @@ module FormHelper | @@ -11,6 +11,6 @@ module FormHelper | ||
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | def label_for_attr(builder, field) | 13 | def label_for_attr(builder, field) |
| 14 | - (builder.object_name + field).gsub(/[\[\]]/,'_').squeeze('_') | 14 | + (builder.object_name + field).gsub(/[\[\]]/, '_').squeeze('_') |
| 15 | end | 15 | end |
| 16 | end | 16 | end |
app/helpers/hash_helper.rb
| @@ -9,11 +9,11 @@ module HashHelper | @@ -9,11 +9,11 @@ module HashHelper | ||
| 9 | sorted_keys = hash.keys.sort | 9 | sorted_keys = hash.keys.sort |
| 10 | sorted_keys.each do |key| | 10 | sorted_keys.each do |key| |
| 11 | val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect | 11 | val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect |
| 12 | - pretty += "\n#{' '*nesting*tab_size}" | 12 | + pretty += "\n#{' ' * nesting * tab_size}" |
| 13 | pretty += "#{key.inspect} => #{val}" | 13 | pretty += "#{key.inspect} => #{val}" |
| 14 | pretty += "," unless key == sorted_keys.last | 14 | pretty += "," unless key == sorted_keys.last |
| 15 | end | 15 | end |
| 16 | nesting -= 1 | 16 | nesting -= 1 |
| 17 | - pretty += "\n#{' '*nesting*tab_size}}" | 17 | + pretty += "\n#{' ' * nesting * tab_size}}" |
| 18 | end | 18 | end |
| 19 | end | 19 | end |
app/helpers/problems_helper.rb
app/mailers/mailer.rb
| @@ -59,6 +59,6 @@ class Mailer < ActionMailer::Base | @@ -59,6 +59,6 @@ class Mailer < ActionMailer::Base | ||
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | private def errbit_headers(header) | 61 | private def errbit_headers(header) |
| 62 | - header.each { |key,value| headers["X-Errbit-#{key}"] = value.to_s } | 62 | + header.each { |key, value| headers["X-Errbit-#{key}"] = value.to_s } |
| 63 | end | 63 | end |
| 64 | end | 64 | end |
app/models/app.rb
| @@ -196,26 +196,25 @@ protected | @@ -196,26 +196,25 @@ protected | ||
| 196 | ) | 196 | ) |
| 197 | end | 197 | end |
| 198 | 198 | ||
| 199 | - def generate_api_key | ||
| 200 | - self.api_key ||= SecureRandom.hex | ||
| 201 | - end | 199 | + def generate_api_key |
| 200 | + self.api_key ||= SecureRandom.hex | ||
| 201 | + end | ||
| 202 | 202 | ||
| 203 | - def check_issue_tracker | ||
| 204 | - if issue_tracker.present? | ||
| 205 | - issue_tracker.valid? | ||
| 206 | - issue_tracker.errors.full_messages.each do |error| | ||
| 207 | - errors[:base] << error | ||
| 208 | - end if issue_tracker.errors | ||
| 209 | - end | 203 | + def check_issue_tracker |
| 204 | + if issue_tracker.present? | ||
| 205 | + issue_tracker.valid? | ||
| 206 | + issue_tracker.errors.full_messages.each do |error| | ||
| 207 | + errors[:base] << error | ||
| 208 | + end if issue_tracker.errors | ||
| 210 | end | 209 | end |
| 210 | + end | ||
| 211 | 211 | ||
| 212 | - def normalize_github_repo | ||
| 213 | - return if github_repo.blank? | ||
| 214 | - github_host = URI.parse(Errbit::Config.github_url).host | ||
| 215 | - github_host = Regexp.escape(github_host) | ||
| 216 | - github_repo.strip! | ||
| 217 | - github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') | ||
| 218 | - github_repo.sub!(/\.git$/, '') | ||
| 219 | - end | 212 | + def normalize_github_repo |
| 213 | + return if github_repo.blank? | ||
| 214 | + github_host = URI.parse(Errbit::Config.github_url).host | ||
| 215 | + github_host = Regexp.escape(github_host) | ||
| 216 | + github_repo.strip! | ||
| 217 | + github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') | ||
| 218 | + github_repo.sub!(/\.git$/, '') | ||
| 219 | + end | ||
| 220 | end | 220 | end |
| 221 | - |
app/models/comment.rb
| @@ -34,7 +34,7 @@ protected | @@ -34,7 +34,7 @@ protected | ||
| 34 | err.inc(comments_count: 1) | 34 | err.inc(comments_count: 1) |
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | - def decrease_counter_cache | ||
| 38 | - err.inc(comments_count: -1) if err | ||
| 39 | - end | 37 | + def decrease_counter_cache |
| 38 | + err.inc(comments_count: -1) if err | ||
| 39 | + end | ||
| 40 | end | 40 | end |
app/models/deploy.rb
| @@ -23,7 +23,7 @@ class Deploy | @@ -23,7 +23,7 @@ class Deploy | ||
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | def short_revision | 25 | def short_revision |
| 26 | - revision.to_s[0,7] | 26 | + revision.to_s[0, 7] |
| 27 | end | 27 | end |
| 28 | 28 | ||
| 29 | protected | 29 | protected |
| @@ -32,16 +32,15 @@ protected | @@ -32,16 +32,15 @@ protected | ||
| 32 | app.resolve_errs_on_deploy? | 32 | app.resolve_errs_on_deploy? |
| 33 | end | 33 | end |
| 34 | 34 | ||
| 35 | - def store_cached_attributes_on_problems | ||
| 36 | - Problem.where(:app_id => app.id).update_all( | ||
| 37 | - last_deploy_at: created_at | ||
| 38 | - ) | ||
| 39 | - end | 35 | + def store_cached_attributes_on_problems |
| 36 | + Problem.where(:app_id => app.id).update_all( | ||
| 37 | + last_deploy_at: created_at | ||
| 38 | + ) | ||
| 39 | + end | ||
| 40 | 40 | ||
| 41 | - def deliver_email | ||
| 42 | - if app.notify_on_deploys? && app.notification_recipients.any? | ||
| 43 | - Mailer.deploy_notification(self).deliver_now | ||
| 44 | - end | 41 | + def deliver_email |
| 42 | + if app.notify_on_deploys? && app.notification_recipients.any? | ||
| 43 | + Mailer.deploy_notification(self).deliver_now | ||
| 45 | end | 44 | end |
| 45 | + end | ||
| 46 | end | 46 | end |
| 47 | - |
app/models/issue.rb
| @@ -22,7 +22,7 @@ class Issue | @@ -22,7 +22,7 @@ class Issue | ||
| 22 | if tracker.respond_to?(:title) | 22 | if tracker.respond_to?(:title) |
| 23 | tracker.title | 23 | tracker.title |
| 24 | else | 24 | else |
| 25 | - "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" | 25 | + "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" |
| 26 | end | 26 | end |
| 27 | end | 27 | end |
| 28 | 28 |
app/models/issue_tracker.rb
| @@ -27,7 +27,7 @@ class IssueTracker | @@ -27,7 +27,7 @@ class IssueTracker | ||
| 27 | 27 | ||
| 28 | # Allow the tracker to validate its own params | 28 | # Allow the tracker to validate its own params |
| 29 | def validate_tracker | 29 | def validate_tracker |
| 30 | - (tracker.errors || {}).each do |k,v| | 30 | + (tracker.errors || {}).each do |k, v| |
| 31 | errors.add k, v | 31 | errors.add k, v |
| 32 | end | 32 | end |
| 33 | end | 33 | end |
app/models/notice.rb
| @@ -132,15 +132,15 @@ protected | @@ -132,15 +132,15 @@ protected | ||
| 132 | 132 | ||
| 133 | def sanitize | 133 | def sanitize |
| 134 | [:server_environment, :request, :notifier].each do |h| | 134 | [:server_environment, :request, :notifier].each do |h| |
| 135 | - send("#{h}=",sanitize_hash(send(h))) | 135 | + send("#{h}=", sanitize_hash(send(h))) |
| 136 | end | 136 | end |
| 137 | end | 137 | end |
| 138 | 138 | ||
| 139 | def sanitize_hash(hash) | 139 | def sanitize_hash(hash) |
| 140 | hash.recurse do |recurse_hash| | 140 | hash.recurse do |recurse_hash| |
| 141 | - recurse_hash.inject({}) do |h,(k,v)| | 141 | + recurse_hash.inject({}) do |h, (k, v)| |
| 142 | if k.is_a?(String) | 142 | if k.is_a?(String) |
| 143 | - h[k.gsub(/\./,'.').gsub(/^\$/,'$')] = v | 143 | + h[k.gsub(/\./, '.').gsub(/^\$/, '$')] = v |
| 144 | else | 144 | else |
| 145 | h[k] = v | 145 | h[k] = v |
| 146 | end | 146 | end |
app/models/notification_service.rb
| @@ -35,12 +35,12 @@ class NotificationService | @@ -35,12 +35,12 @@ class NotificationService | ||
| 35 | def check_params; true; end | 35 | def check_params; true; end |
| 36 | 36 | ||
| 37 | def notification_description(problem) | 37 | def notification_description(problem) |
| 38 | - "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" | 38 | + "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | # Allows us to set the issue tracker class from a single form. | 41 | # Allows us to set the issue tracker class from a single form. |
| 42 | def type; _type; end | 42 | def type; _type; end |
| 43 | - def type=(t); self._type=t; end | 43 | + def type=(t); self._type = t; end |
| 44 | 44 | ||
| 45 | def url; nil; end | 45 | def url; nil; end |
| 46 | 46 |
app/models/notification_services/flowdock_service.rb
| @@ -35,7 +35,7 @@ if defined? Flowdock | @@ -35,7 +35,7 @@ if defined? Flowdock | ||
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | def content(problem, url) | 37 | def content(problem, url) |
| 38 | - full_description = "[#{ problem.environment }][#{ problem.where }] #{problem.message}" | 38 | + full_description = "[#{problem.environment}][#{problem.where}] #{problem.message}" |
| 39 | <<-MSG.strip_heredoc | 39 | <<-MSG.strip_heredoc |
| 40 | #{ERB::Util.html_escape full_description}<br> | 40 | #{ERB::Util.html_escape full_description}<br> |
| 41 | <a href="#{url}">#{url}</a> | 41 | <a href="#{url}">#{url}</a> |
app/models/notification_services/gtalk_service.rb
| 1 | class NotificationServices::GtalkService < NotificationService | 1 | class NotificationServices::GtalkService < NotificationService |
| 2 | Label = "gtalk" | 2 | Label = "gtalk" |
| 3 | Fields += [ | 3 | Fields += [ |
| 4 | - [:subdomain, { | ||
| 5 | - :placeholder => "username@example.com", | ||
| 6 | - :label => "Username" | ||
| 7 | - }], | ||
| 8 | - [:api_token, { | ||
| 9 | - :placeholder => "password", | ||
| 10 | - :label => "Password" | ||
| 11 | - }], | ||
| 12 | - [:user_id, { | ||
| 13 | - :placeholder => "touser@example.com, anotheruser@example.com", | ||
| 14 | - :label => "Send To User(s)" | ||
| 15 | - }, :room_id], | ||
| 16 | - [:room_id, { | ||
| 17 | - :placeholder => "toroom@conference.example.com", | ||
| 18 | - :label => "Send To Room (one only)" | ||
| 19 | - }, :user_id], | ||
| 20 | - [ :service, { | ||
| 21 | - :placeholder => "talk.google.com", | ||
| 22 | - :label => "Jabber Service" | ||
| 23 | - }], | ||
| 24 | - [ :service_url, { | ||
| 25 | - :placeholder => "http://www.google.com/talk/", | ||
| 26 | - :label => "Link To Jabber Service" | ||
| 27 | - }] | 4 | + [:subdomain, { |
| 5 | + :placeholder => "username@example.com", | ||
| 6 | + :label => "Username" | ||
| 7 | + }], | ||
| 8 | + [:api_token, { | ||
| 9 | + :placeholder => "password", | ||
| 10 | + :label => "Password" | ||
| 11 | + }], | ||
| 12 | + [:user_id, { | ||
| 13 | + :placeholder => "touser@example.com, anotheruser@example.com", | ||
| 14 | + :label => "Send To User(s)" | ||
| 15 | + }, :room_id], | ||
| 16 | + [:room_id, { | ||
| 17 | + :placeholder => "toroom@conference.example.com", | ||
| 18 | + :label => "Send To Room (one only)" | ||
| 19 | + }, :user_id], | ||
| 20 | + [ :service, { | ||
| 21 | + :placeholder => "talk.google.com", | ||
| 22 | + :label => "Jabber Service" | ||
| 23 | + }], | ||
| 24 | + [ :service_url, { | ||
| 25 | + :placeholder => "http://www.google.com/talk/", | ||
| 26 | + :label => "Link To Jabber Service" | ||
| 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? } | 31 | if Fields.detect { |f| self[f[0]].blank? && self[f[2]].blank? } |
| 32 | errors.add :base, | 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""" | 33 | + """You must specify your Username, Password, service, service_url |
| 34 | + and either rooms or users to send to or both""" | ||
| 35 | end | 35 | end |
| 36 | end | 36 | end |
| 37 | 37 |
app/models/notification_services/hoiio_service.rb
| 1 | class NotificationServices::HoiioService < NotificationService | 1 | class NotificationServices::HoiioService < NotificationService |
| 2 | Label = "hoiio" | 2 | Label = "hoiio" |
| 3 | Fields += [ | 3 | Fields += [ |
| 4 | - [:api_token, { | ||
| 5 | - :placeholder => "App ID", | ||
| 6 | - :label => "App ID" | ||
| 7 | - }], | ||
| 8 | - [:subdomain, { | ||
| 9 | - :placeholder => "Access Token", | ||
| 10 | - :label => "Access Token" | ||
| 11 | - }], | ||
| 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." | ||
| 15 | - }] | 4 | + [:api_token, { |
| 5 | + :placeholder => "App ID", | ||
| 6 | + :label => "App ID" | ||
| 7 | + }], | ||
| 8 | + [:subdomain, { | ||
| 9 | + :placeholder => "Access Token", | ||
| 10 | + :label => "Access Token" | ||
| 11 | + }], | ||
| 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." | ||
| 15 | + }] | ||
| 16 | ] | 16 | ] |
| 17 | 17 | ||
| 18 | def check_params | 18 | def check_params |
| @@ -26,7 +26,7 @@ class NotificationServices::HoiioService < NotificationService | @@ -26,7 +26,7 @@ class NotificationServices::HoiioService < NotificationService | ||
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | def notification_description(problem) | 28 | def notification_description(problem) |
| 29 | - "[#{ problem.environment }]#{problem.message.to_s.truncate(50)}" | 29 | + "[#{problem.environment}]#{problem.message.to_s.truncate(50)}" |
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | def create_notification(problem) | 32 | def create_notification(problem) |
app/models/notification_services/hubot_service.rb
| @@ -29,4 +29,3 @@ class NotificationServices::HubotService < NotificationService | @@ -29,4 +29,3 @@ class NotificationServices::HubotService < NotificationService | ||
| 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 |
| 32 | - |
app/models/notification_services/pushover_service.rb
| 1 | class NotificationServices::PushoverService < NotificationService | 1 | class NotificationServices::PushoverService < NotificationService |
| 2 | Label = "pushover" | 2 | Label = "pushover" |
| 3 | Fields += [ | 3 | Fields += [ |
| 4 | - [:api_token, { | ||
| 5 | - :placeholder => "User Key", | ||
| 6 | - :label => "User Key" | ||
| 7 | - }], | ||
| 8 | - [:subdomain, { | ||
| 9 | - :placeholder => "Application API Token", | ||
| 10 | - :label => "Application API Token" | ||
| 11 | - }] | 4 | + [:api_token, { |
| 5 | + :placeholder => "User Key", | ||
| 6 | + :label => "User Key" | ||
| 7 | + }], | ||
| 8 | + [:subdomain, { | ||
| 9 | + :placeholder => "Application API Token", | ||
| 10 | + :label => "Application API Token" | ||
| 11 | + }] | ||
| 12 | ] | 12 | ] |
| 13 | 13 | ||
| 14 | def check_params | 14 | def check_params |
app/models/notification_services/slack_service.rb
| @@ -21,41 +21,41 @@ class NotificationServices::SlackService < NotificationService | @@ -21,41 +21,41 @@ class NotificationServices::SlackService < NotificationService | ||
| 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 => [ | ||
| 28 | - { | ||
| 29 | - :title => "Environment", | ||
| 30 | - :value => problem.environment, | ||
| 31 | - :short => false | ||
| 32 | - }, | ||
| 33 | - { | ||
| 34 | - :title => "Location", | ||
| 35 | - :value => problem.where, | ||
| 36 | - :short => false | ||
| 37 | - }, | ||
| 38 | - { | ||
| 39 | - :title => "Message", | ||
| 40 | - :value => problem.message.to_s, | ||
| 41 | - :short => false | ||
| 42 | - }, | ||
| 43 | - { | ||
| 44 | - :title => "First Noticed", | ||
| 45 | - :value => problem.first_notice_at, | ||
| 46 | - :short => false | ||
| 47 | - }, | ||
| 48 | - { | ||
| 49 | - :title => "Last Noticed", | ||
| 50 | - :value => problem.last_notice_at, | ||
| 51 | - :short => false | ||
| 52 | - }, | ||
| 53 | - { | ||
| 54 | - :title => "Times Occurred", | ||
| 55 | - :value => problem.notices_count, | ||
| 56 | - :short => false | ||
| 57 | - } | ||
| 58 | - ] | 24 | + :fallback => message_for_slack(problem), |
| 25 | + :pretext => "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
| 26 | + :color => "#D00000", | ||
| 27 | + :fields => [ | ||
| 28 | + { | ||
| 29 | + :title => "Environment", | ||
| 30 | + :value => problem.environment, | ||
| 31 | + :short => false | ||
| 32 | + }, | ||
| 33 | + { | ||
| 34 | + :title => "Location", | ||
| 35 | + :value => problem.where, | ||
| 36 | + :short => false | ||
| 37 | + }, | ||
| 38 | + { | ||
| 39 | + :title => "Message", | ||
| 40 | + :value => problem.message.to_s, | ||
| 41 | + :short => false | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + :title => "First Noticed", | ||
| 45 | + :value => problem.first_notice_at, | ||
| 46 | + :short => false | ||
| 47 | + }, | ||
| 48 | + { | ||
| 49 | + :title => "Last Noticed", | ||
| 50 | + :value => problem.last_notice_at, | ||
| 51 | + :short => false | ||
| 52 | + }, | ||
| 53 | + { | ||
| 54 | + :title => "Times Occurred", | ||
| 55 | + :value => problem.notices_count, | ||
| 56 | + :short => false | ||
| 57 | + } | ||
| 58 | + ] | ||
| 59 | } | 59 | } |
| 60 | ] | 60 | ] |
| 61 | }.to_json | 61 | }.to_json |
app/models/problem.rb
| @@ -118,7 +118,7 @@ class Problem | @@ -118,7 +118,7 @@ class Problem | ||
| 118 | 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0 | 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| |
| 122 | digest = Digest::MD5.hexdigest(notice.send(v)) | 122 | digest = Digest::MD5.hexdigest(notice.send(v)) |
| 123 | field = "#{k}.#{digest}" | 123 | field = "#{k}.#{digest}" |
| 124 | 124 | ||
| @@ -132,7 +132,7 @@ class Problem | @@ -132,7 +132,7 @@ class Problem | ||
| 132 | end | 132 | end |
| 133 | 133 | ||
| 134 | def recache | 134 | def recache |
| 135 | - CACHED_NOTICE_ATTRIBUTES.each do |k,v| | 135 | + CACHED_NOTICE_ATTRIBUTES.each do |k, v| |
| 136 | # clear all cached attributes | 136 | # clear all cached attributes |
| 137 | send("#{k}=", {}) | 137 | send("#{k}=", {}) |
| 138 | 138 | ||
| @@ -257,7 +257,7 @@ private | @@ -257,7 +257,7 @@ private | ||
| 257 | counter | 257 | counter |
| 258 | end | 258 | end |
| 259 | 259 | ||
| 260 | - def attribute_index(value) | ||
| 261 | - Digest::MD5.hexdigest(value.to_s) | ||
| 262 | - end | 260 | + def attribute_index(value) |
| 261 | + Digest::MD5.hexdigest(value.to_s) | ||
| 262 | + end | ||
| 263 | end | 263 | end |
app/models/watcher.rb
| @@ -31,13 +31,12 @@ protected | @@ -31,13 +31,12 @@ protected | ||
| 31 | errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? | 31 | errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? |
| 32 | end | 32 | end |
| 33 | 33 | ||
| 34 | - def clear_unused_watcher_type | ||
| 35 | - case watcher_type | ||
| 36 | - when 'user' | ||
| 37 | - self.email = nil | ||
| 38 | - when 'email' | ||
| 39 | - self.user = self.user_id = nil | ||
| 40 | - end | 34 | + def clear_unused_watcher_type |
| 35 | + case watcher_type | ||
| 36 | + when 'user' | ||
| 37 | + self.email = nil | ||
| 38 | + when 'email' | ||
| 39 | + self.user = self.user_id = nil | ||
| 41 | end | 40 | end |
| 41 | + end | ||
| 42 | end | 42 | end |
| 43 | - |
autotest/discover.rb
config/initializers/hoptoad.rb
| @@ -6,4 +6,3 @@ HoptoadNotifier.configure do |config| | @@ -6,4 +6,3 @@ HoptoadNotifier.configure do |config| | ||
| 6 | # Don't log error that causes 404 page | 6 | # Don't log error that causes 404 page |
| 7 | config.ignore << "Mongoid::Errors::DocumentNotFound" | 7 | config.ignore << "Mongoid::Errors::DocumentNotFound" |
| 8 | end | 8 | end |
| 9 | - |
config/load.rb
| @@ -52,8 +52,7 @@ Errbit::Config = Configurator.run({ | @@ -52,8 +52,7 @@ Errbit::Config = Configurator.run({ | ||
| 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', ->(values) { |
| 54 | values[:smtp_domain] || | 54 | values[:smtp_domain] || |
| 55 | - (values[:email_from] && values[:email_from].split('@').last)|| | ||
| 56 | - nil | 55 | + (values[:email_from] && values[:email_from].split('@').last) || nil |
| 57 | }], | 56 | }], |
| 58 | 57 | ||
| 59 | # sendmail settings | 58 | # sendmail settings |
config/routes.rb
config/unicorn.default.rb
db/migrate/201510290041_extract_issue_tracker.rb
| 1 | class ExtractIssueTracker < Mongoid::Migration | 1 | class ExtractIssueTracker < Mongoid::Migration |
| 2 | - | ||
| 3 | TRACKER_MAPPING = { | 2 | TRACKER_MAPPING = { |
| 4 | 'ErrbitTracPlugin::IssueTracker' => 'trac', | 3 | 'ErrbitTracPlugin::IssueTracker' => 'trac', |
| 5 | 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket', | 4 | 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket', |
| @@ -26,18 +25,18 @@ class ExtractIssueTracker < Mongoid::Migration | @@ -26,18 +25,18 @@ class ExtractIssueTracker < Mongoid::Migration | ||
| 26 | updated_at = options.delete('updated_at') | 25 | updated_at = options.delete('updated_at') |
| 27 | created_at = options.delete('created_at') | 26 | created_at = options.delete('created_at') |
| 28 | 27 | ||
| 29 | - if TRACKER_MAPPING.include?(type) | ||
| 30 | - tracker = { | ||
| 31 | - 'type_tracker' => TRACKER_MAPPING[type], | ||
| 32 | - 'options' => options, | ||
| 33 | - 'updated_at' => updated_at, | ||
| 34 | - 'created_at' => created_at | ||
| 35 | - } | 28 | + next unless TRACKER_MAPPING.include?(type) |
| 29 | + | ||
| 30 | + tracker = { | ||
| 31 | + 'type_tracker' => TRACKER_MAPPING[type], | ||
| 32 | + 'options' => options, | ||
| 33 | + 'updated_at' => updated_at, | ||
| 34 | + 'created_at' => created_at | ||
| 35 | + } | ||
| 36 | 36 | ||
| 37 | - App.where({ _id: app.id }).update({ | ||
| 38 | - "$set" => { :issue_tracker => tracker } | ||
| 39 | - }) | ||
| 40 | - end | 37 | + App.where({ _id: app.id }).update({ |
| 38 | + "$set" => { :issue_tracker => tracker } | ||
| 39 | + }) | ||
| 41 | end | 40 | end |
| 42 | end | 41 | end |
| 43 | 42 |
db/seeds.rb
| @@ -6,7 +6,7 @@ puts "-------------------------------" | @@ -6,7 +6,7 @@ puts "-------------------------------" | ||
| 6 | # Create an initial Admin User | 6 | # Create an initial Admin User |
| 7 | admin_username = "errbit" | 7 | admin_username = "errbit" |
| 8 | admin_email = "errbit@#{Errbit::Config.host}" | 8 | admin_email = "errbit@#{Errbit::Config.host}" |
| 9 | -admin_pass = SecureRandom.urlsafe_base64(12)[0,12] | 9 | +admin_pass = SecureRandom.urlsafe_base64(12)[0, 12] |
| 10 | 10 | ||
| 11 | puts "Creating an initial admin user:" | 11 | puts "Creating an initial admin user:" |
| 12 | puts "-- username: #{admin_username}" if Errbit::Config.user_has_username | 12 | puts "-- username: #{admin_username}" if Errbit::Config.user_has_username |
lib/airbrake_api/params_error.rb
lib/airbrake_api/v3/notice_parser.rb
lib/hoptoad.rb
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
lib/recurse.rb
lib/tasks/errbit/demo.rake
| @@ -3,7 +3,7 @@ namespace :errbit do | @@ -3,7 +3,7 @@ namespace :errbit do | ||
| 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 |
lib/tasks/heroku/cron.rake
| @@ -2,4 +2,3 @@ desc "This task is called by the Heroku cron add-on" | @@ -2,4 +2,3 @@ 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 |
| 5 | - |
spec/controllers/api/v1/problems_controller_spec.rb
| @@ -37,7 +37,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -37,7 +37,7 @@ describe Api::V1::ProblemsController, type: 'controller' 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( |
| 41 | app_name | 41 | app_name |
| 42 | first_notice_at | 42 | first_notice_at |
| 43 | message | 43 | message |
| @@ -53,7 +53,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -53,7 +53,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
| 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 |
spec/controllers/comments_controller_spec.rb
| @@ -24,7 +24,7 @@ describe CommentsController, type: 'controller' do | @@ -24,7 +24,7 @@ describe CommentsController, type: 'controller' do | ||
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | it "should redirect to problem page" do | 26 | it "should redirect to problem page" do |
| 27 | - expect(response).to redirect_to( app_problem_path(problem.app, problem) ) | 27 | + expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
| 28 | end | 28 | end |
| 29 | end | 29 | end |
| 30 | end | 30 | end |
| @@ -50,7 +50,7 @@ describe CommentsController, type: 'controller' do | @@ -50,7 +50,7 @@ describe CommentsController, type: 'controller' do | ||
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | it "should redirect to problem page" do | 52 | it "should redirect to problem page" do |
| 53 | - expect(response).to redirect_to( app_problem_path(problem.app, problem) ) | 53 | + expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
| 54 | end | 54 | end |
| 55 | end | 55 | end |
| 56 | end | 56 | end |
spec/controllers/notices_controller_spec.rb
| @@ -2,7 +2,7 @@ describe NoticesController, type: 'controller' do | @@ -2,7 +2,7 @@ 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 |
spec/controllers/problems_controller_spec.rb
| @@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' do | @@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' 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 |
| @@ -218,7 +218,7 @@ describe ProblemsController, type: 'controller' do | @@ -218,7 +218,7 @@ describe ProblemsController, type: 'controller' do | ||
| 218 | 218 | ||
| 219 | it "should save the right title" do | 219 | it "should save the right title" do |
| 220 | post :create_issue, app_id: problem.app.id, id: problem.id | 220 | post :create_issue, app_id: problem.app.id, id: problem.id |
| 221 | - title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" | 221 | + title = "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" |
| 222 | line = issue_tracker.tracker.output.shift | 222 | line = issue_tracker.tracker.output.shift |
| 223 | expect(line[0]).to eq(title) | 223 | expect(line[0]).to eq(title) |
| 224 | end | 224 | end |
| @@ -256,7 +256,7 @@ describe ProblemsController, type: 'controller' do | @@ -256,7 +256,7 @@ describe ProblemsController, type: 'controller' do | ||
| 256 | context "when app has no issue tracker" do | 256 | context "when app has no issue tracker" do |
| 257 | it "should redirect to problem page" do | 257 | it "should redirect to problem page" do |
| 258 | post :create_issue, app_id: problem.app.id, id: problem.id | 258 | post :create_issue, app_id: problem.app.id, id: problem.id |
| 259 | - expect(response).to redirect_to( app_problem_path(problem.app, problem) ) | 259 | + expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
| 260 | expect(flash[:error]).to eql "This app has no issue tracker" | 260 | expect(flash[:error]).to eql "This app has no issue tracker" |
| 261 | end | 261 | end |
| 262 | end | 262 | end |
| @@ -276,7 +276,7 @@ describe ProblemsController, type: 'controller' do | @@ -276,7 +276,7 @@ describe ProblemsController, type: 'controller' do | ||
| 276 | end | 276 | end |
| 277 | 277 | ||
| 278 | it "should redirect to problem page" do | 278 | it "should redirect to problem page" do |
| 279 | - expect(response).to redirect_to( app_problem_path(err.app, err.problem) ) | 279 | + expect(response).to redirect_to(app_problem_path(err.app, err.problem)) |
| 280 | end | 280 | end |
| 281 | 281 | ||
| 282 | it "should clear issue link" do | 282 | it "should clear issue link" do |
| @@ -293,7 +293,7 @@ describe ProblemsController, type: 'controller' do | @@ -293,7 +293,7 @@ describe ProblemsController, type: 'controller' do | ||
| 293 | end | 293 | end |
| 294 | 294 | ||
| 295 | it "should redirect to problem page" do | 295 | it "should redirect to problem page" do |
| 296 | - expect(response).to redirect_to( app_problem_path(err.app, err.problem) ) | 296 | + expect(response).to redirect_to(app_problem_path(err.app, err.problem)) |
| 297 | end | 297 | end |
| 298 | end | 298 | end |
| 299 | end | 299 | end |
| @@ -380,8 +380,8 @@ describe ProblemsController, type: 'controller' do | @@ -380,8 +380,8 @@ describe ProblemsController, type: 'controller' 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 |
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 |
spec/fabricators/app_fabricator.rb
spec/fabricators/comment_fabricator.rb
spec/fabricators/sequences_fabricator.rb
spec/interactors/problem_merge_spec.rb
| @@ -52,8 +52,8 @@ describe ProblemMerge do | @@ -52,8 +52,8 @@ describe ProblemMerge do | ||
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | context "with problem with comment" do | 54 | context "with problem with comment" do |
| 55 | - let!(:comment) { Fabricate(:comment, :err => problem ) } | ||
| 56 | - let!(:comment_2) { Fabricate(:comment, :err => problem_1, :user => comment.user ) } | 55 | + let!(:comment) { Fabricate(:comment, :err => problem) } |
| 56 | + let!(:comment_2) { Fabricate(:comment, :err => problem_1, :user => comment.user) } | ||
| 57 | it 'merge comment' do | 57 | it 'merge comment' do |
| 58 | expect { | 58 | expect { |
| 59 | problem_merge.merge | 59 | problem_merge.merge |
spec/mailers/mailer_spec.rb
| @@ -81,13 +81,13 @@ describe Mailer do | @@ -81,13 +81,13 @@ describe Mailer do | ||
| 81 | end | 81 | end |
| 82 | 82 | ||
| 83 | it "should have the error count in the subject" do | 83 | it "should have the error count in the subject" do |
| 84 | - expect(email.subject).to match( /^\(3\) / ) | 84 | + expect(email.subject).to match(/^\(3\) /) |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | context 'with a very long message' do | 87 | context 'with a very long message' do |
| 88 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|_a| "0123456789" }.join('')) } | 88 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|_a| "0123456789" }.join('')) } |
| 89 | it "should truncate the long message" do | 89 | it "should truncate the long message" do |
| 90 | - expect(email.subject).to match( / \d{47}\.{3}$/ ) | 90 | + expect(email.subject).to match(/ \d{47}\.{3}$/) |
| 91 | end | 91 | end |
| 92 | end | 92 | end |
| 93 | end | 93 | end |
spec/models/app_spec.rb
| @@ -165,10 +165,10 @@ describe App, type: 'model' do | @@ -165,10 +165,10 @@ describe App, type: 'model' do | ||
| 165 | context '#find_or_create_err!' do | 165 | context '#find_or_create_err!' do |
| 166 | let(:app) { Fabricate(:app) } | 166 | let(:app) { Fabricate(:app) } |
| 167 | let(:conditions) { { | 167 | let(:conditions) { { |
| 168 | - :error_class => 'Whoops', | ||
| 169 | - :environment => 'production', | ||
| 170 | - :fingerprint => 'some-finger-print' | ||
| 171 | - } | 168 | + :error_class => 'Whoops', |
| 169 | + :environment => 'production', | ||
| 170 | + :fingerprint => 'some-finger-print' | ||
| 171 | + } | ||
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | it 'returns the correct err if one already exists' do | 174 | it 'returns the correct err if one already exists' do |
| @@ -188,7 +188,7 @@ describe App, type: 'model' do | @@ -188,7 +188,7 @@ describe App, type: 'model' do | ||
| 188 | expect(Err.where(conditions).first).to be_nil | 188 | expect(Err.where(conditions).first).to be_nil |
| 189 | expect { | 189 | expect { |
| 190 | app.find_or_create_err!(conditions) | 190 | app.find_or_create_err!(conditions) |
| 191 | - }.to change(Problem,:count).by(1) | 191 | + }.to change(Problem, :count).by(1) |
| 192 | end | 192 | end |
| 193 | 193 | ||
| 194 | context "without error_class" do | 194 | context "without error_class" do |
| @@ -201,7 +201,7 @@ describe App, type: 'model' do | @@ -201,7 +201,7 @@ describe App, type: 'model' do | ||
| 201 | expect(Err.where(conditions).first).to be_nil | 201 | expect(Err.where(conditions).first).to be_nil |
| 202 | expect { | 202 | expect { |
| 203 | app.find_or_create_err!(conditions) | 203 | app.find_or_create_err!(conditions) |
| 204 | - }.to change(Problem,:count).by(1) | 204 | + }.to change(Problem, :count).by(1) |
| 205 | end | 205 | end |
| 206 | end | 206 | end |
| 207 | end | 207 | end |
spec/models/deploy_spec.rb
| @@ -39,4 +39,3 @@ describe Deploy, type: 'model' do | @@ -39,4 +39,3 @@ describe Deploy, type: 'model' do | ||
| 39 | expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567" | 39 | expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567" |
| 40 | end | 40 | end |
| 41 | end | 41 | end |
| 42 | - |
spec/models/error_report_spec.rb
| @@ -18,7 +18,7 @@ end | @@ -18,7 +18,7 @@ end | ||
| 18 | 18 | ||
| 19 | describe ErrorReport do | 19 | describe ErrorReport do |
| 20 | let(:xml){ | 20 | let(:xml){ |
| 21 | - Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read | 21 | + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | let(:error_report) { ErrorReport.new(xml) } | 24 | let(:error_report) { ErrorReport.new(xml) } |
| @@ -53,7 +53,7 @@ describe ErrorReport do | @@ -53,7 +53,7 @@ describe ErrorReport do | ||
| 53 | 53 | ||
| 54 | context "with a minimal notice" do | 54 | context "with a minimal notice" do |
| 55 | let(:xml){ | 55 | let(:xml){ |
| 56 | - Rails.root.join('spec','fixtures','minimal_test_notice.xml').read | 56 | + Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | it 'save a notice' do | 59 | it 'save a notice' do |
| @@ -66,11 +66,13 @@ describe ErrorReport do | @@ -66,11 +66,13 @@ describe ErrorReport do | ||
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | context "with notice generate by Airbrake gem" do | 68 | context "with notice generate by Airbrake gem" do |
| 69 | - let(:xml) { Airbrake::Notice.new( | ||
| 70 | - :exception => Exception.new, | ||
| 71 | - :api_key => 'APIKEY', | ||
| 72 | - :project_root => Rails.root | ||
| 73 | - ).to_xml } | 69 | + let(:xml) { |
| 70 | + Airbrake::Notice.new( | ||
| 71 | + :exception => Exception.new, | ||
| 72 | + :api_key => 'APIKEY', | ||
| 73 | + :project_root => Rails.root | ||
| 74 | + ).to_xml | ||
| 75 | + } | ||
| 74 | it 'save a notice' do | 76 | it 'save a notice' do |
| 75 | expect { | 77 | expect { |
| 76 | error_report.generate_notice! | 78 | error_report.generate_notice! |
| @@ -236,7 +238,7 @@ describe ErrorReport do | @@ -236,7 +238,7 @@ describe ErrorReport do | ||
| 236 | 238 | ||
| 237 | context "with xml without request section" do | 239 | context "with xml without request section" do |
| 238 | let(:xml){ | 240 | let(:xml){ |
| 239 | - Rails.root.join('spec','fixtures','hoptoad_test_notice_without_request_section.xml').read | 241 | + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read |
| 240 | } | 242 | } |
| 241 | it "save a notice" do | 243 | it "save a notice" do |
| 242 | expect { | 244 | expect { |
| @@ -249,7 +251,7 @@ describe ErrorReport do | @@ -249,7 +251,7 @@ describe ErrorReport do | ||
| 249 | 251 | ||
| 250 | context "with xml with only a single line of backtrace" do | 252 | context "with xml with only a single line of backtrace" do |
| 251 | let(:xml){ | 253 | let(:xml){ |
| 252 | - Rails.root.join('spec','fixtures','hoptoad_test_notice_with_one_line_of_backtrace.xml').read | 254 | + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read |
| 253 | } | 255 | } |
| 254 | it "save a notice" do | 256 | it "save a notice" do |
| 255 | expect { | 257 | expect { |
spec/models/notice_observer_spec.rb
| @@ -6,9 +6,9 @@ describe "Callback on Notice", type: 'model' do | @@ -6,9 +6,9 @@ describe "Callback on Notice", type: 'model' do | ||
| 6 | message: "some message", | 6 | message: "some message", |
| 7 | backtrace: [ | 7 | backtrace: [ |
| 8 | { | 8 | { |
| 9 | - "number"=>"425", | ||
| 10 | - "file"=>"[GEM_ROOT]/callbacks.rb", | ||
| 11 | - "method"=>"__callbacks" | 9 | + "number" => "425", |
| 10 | + "file" => "[GEM_ROOT]/callbacks.rb", | ||
| 11 | + "method" => "__callbacks" | ||
| 12 | } | 12 | } |
| 13 | ], | 13 | ], |
| 14 | request: { "component" => "application" }, | 14 | request: { "component" => "application" }, |
| @@ -18,9 +18,9 @@ describe "Callback on Notice", type: 'model' do | @@ -18,9 +18,9 @@ describe "Callback on Notice", type: 'model' do | ||
| 18 | }, | 18 | }, |
| 19 | api_key: api_key, | 19 | api_key: api_key, |
| 20 | notifier: { | 20 | notifier: { |
| 21 | - "name"=>"Hoptoad Notifier", | ||
| 22 | - "version"=>"2.3.2", | ||
| 23 | - "url"=>"http://hoptoadapp.com" | 21 | + "name" => "Hoptoad Notifier", |
| 22 | + "version" => "2.3.2", | ||
| 23 | + "url" => "http://hoptoadapp.com" | ||
| 24 | }, | 24 | }, |
| 25 | framework: "Rails: 3.2.11" | 25 | framework: "Rails: 3.2.11" |
| 26 | } | 26 | } |
| @@ -78,7 +78,7 @@ describe "Callback on Notice", type: 'model' do | @@ -78,7 +78,7 @@ describe "Callback on Notice", type: 'model' do | ||
| 78 | Fabricate( | 78 | Fabricate( |
| 79 | :app_with_watcher, | 79 | :app_with_watcher, |
| 80 | notify_on_errs: true, | 80 | notify_on_errs: true, |
| 81 | - email_at_notices: [1,100] | 81 | + email_at_notices: [1, 100] |
| 82 | ) | 82 | ) |
| 83 | end | 83 | end |
| 84 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } | 84 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } |
| @@ -130,7 +130,7 @@ describe "Callback on Notice", type: 'model' do | @@ -130,7 +130,7 @@ describe "Callback on Notice", type: 'model' do | ||
| 130 | describe 'should not send a notification if a notification service is not' \ | 130 | describe 'should not send a notification if a notification service is not' \ |
| 131 | 'configured' do | 131 | 'configured' do |
| 132 | let(:notification_service) { Fabricate(:notification_service) } | 132 | let(:notification_service) { Fabricate(:notification_service) } |
| 133 | - let(:app) { Fabricate(:app, notification_service: notification_service )} | 133 | + let(:app) { Fabricate(:app, notification_service: notification_service)} |
| 134 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } | 134 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } |
| 135 | 135 | ||
| 136 | before { Errbit::Config.per_app_notify_at_notices = true } | 136 | before { Errbit::Config.per_app_notify_at_notices = true } |
| @@ -161,7 +161,7 @@ describe "Callback on Notice", type: 'model' do | @@ -161,7 +161,7 @@ describe "Callback on Notice", type: 'model' do | ||
| 161 | 161 | ||
| 162 | describe "should send a notification at desired intervals" do | 162 | describe "should send a notification at desired intervals" do |
| 163 | let(:notification_service) do | 163 | let(:notification_service) do |
| 164 | - Fabricate(:campfire_notification_service, notify_at_notices: [1,2]) | 164 | + Fabricate(:campfire_notification_service, notify_at_notices: [1, 2]) |
| 165 | end | 165 | end |
| 166 | let(:app) { Fabricate(:app, notification_service: notification_service) } | 166 | let(:app) { Fabricate(:app, notification_service: notification_service) } |
| 167 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } | 167 | let(:notice_attrs) { notice_attrs_for.call(app.api_key) } |
spec/models/notice_spec.rb
| @@ -61,7 +61,7 @@ describe Notice, type: 'model' do | @@ -61,7 +61,7 @@ describe Notice, type: 'model' do | ||
| 61 | 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' | 61 | 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' |
| 62 | }}) | 62 | }}) |
| 63 | expect(notice.user_agent.browser).to eq 'Chrome' | 63 | expect(notice.user_agent.browser).to eq 'Chrome' |
| 64 | - expect(notice.user_agent.version.to_s).to match( /^10\.0/ ) | 64 | + expect(notice.user_agent.version.to_s).to match(/^10\.0/) |
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | it "should be nil if HTTP_USER_AGENT is blank" do | 67 | it "should be nil if HTTP_USER_AGENT is blank" do |
spec/models/notification_service/slack_service_spec.rb
| @@ -9,41 +9,41 @@ describe NotificationServices::SlackService, type: 'model' do | @@ -9,41 +9,41 @@ describe NotificationServices::SlackService, type: 'model' do | ||
| 9 | payload = { | 9 | payload = { |
| 10 | :attachments => [ | 10 | :attachments => [ |
| 11 | { | 11 | { |
| 12 | - :fallback => notification_service.message_for_slack(problem), | ||
| 13 | - :pretext => "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
| 14 | - :color => "#D00000", | ||
| 15 | - :fields => [ | ||
| 16 | - { | ||
| 17 | - :title => "Environment", | ||
| 18 | - :value => problem.environment, | ||
| 19 | - :short => false | ||
| 20 | - }, | ||
| 21 | - { | ||
| 22 | - :title => "Location", | ||
| 23 | - :value => problem.where, | ||
| 24 | - :short => false | ||
| 25 | - }, | ||
| 26 | - { | ||
| 27 | - :title => "Message", | ||
| 28 | - :value => problem.message.to_s, | ||
| 29 | - :short => false | ||
| 30 | - }, | ||
| 31 | - { | ||
| 32 | - :title => "First Noticed", | ||
| 33 | - :value => problem.first_notice_at, | ||
| 34 | - :short => false | ||
| 35 | - }, | ||
| 36 | - { | ||
| 37 | - :title => "Last Noticed", | ||
| 38 | - :value => problem.last_notice_at, | ||
| 39 | - :short => false | ||
| 40 | - }, | ||
| 41 | - { | ||
| 42 | - :title => "Times Occurred", | ||
| 43 | - :value => problem.notices_count, | ||
| 44 | - :short => false | ||
| 45 | - } | ||
| 46 | - ] | 12 | + :fallback => notification_service.message_for_slack(problem), |
| 13 | + :pretext => "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
| 14 | + :color => "#D00000", | ||
| 15 | + :fields => [ | ||
| 16 | + { | ||
| 17 | + :title => "Environment", | ||
| 18 | + :value => problem.environment, | ||
| 19 | + :short => false | ||
| 20 | + }, | ||
| 21 | + { | ||
| 22 | + :title => "Location", | ||
| 23 | + :value => problem.where, | ||
| 24 | + :short => false | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + :title => "Message", | ||
| 28 | + :value => problem.message.to_s, | ||
| 29 | + :short => false | ||
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + :title => "First Noticed", | ||
| 33 | + :value => problem.first_notice_at, | ||
| 34 | + :short => false | ||
| 35 | + }, | ||
| 36 | + { | ||
| 37 | + :title => "Last Noticed", | ||
| 38 | + :value => problem.last_notice_at, | ||
| 39 | + :short => false | ||
| 40 | + }, | ||
| 41 | + { | ||
| 42 | + :title => "Times Occurred", | ||
| 43 | + :value => problem.notices_count, | ||
| 44 | + :short => false | ||
| 45 | + } | ||
| 46 | + ] | ||
| 47 | } | 47 | } |
| 48 | ] | 48 | ] |
| 49 | }.to_json | 49 | }.to_json |
spec/requests/notices_controller_spec.rb
| @@ -3,7 +3,7 @@ describe "Notices management", type: 'request' do | @@ -3,7 +3,7 @@ describe "Notices management", type: 'request' do | ||
| 3 | 3 | ||
| 4 | describe "create a new notice" do | 4 | describe "create a new notice" do |
| 5 | context "with valide notice" do | 5 | context "with valide notice" do |
| 6 | - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } | 6 | + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 7 | it 'save a new notice' do | 7 | it 'save a new notice' do |
| 8 | expect { | 8 | expect { |
| 9 | post '/notifier_api/v2/notices', :data => xml | 9 | post '/notifier_api/v2/notices', :data => xml |
| @@ -15,7 +15,7 @@ describe "Notices management", type: 'request' do | @@ -15,7 +15,7 @@ describe "Notices management", type: 'request' do | ||
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | context "with notice with empty backtrace" do | 17 | context "with notice with empty backtrace" do |
| 18 | - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice_without_line_of_backtrace.xml').read } | 18 | + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } |
| 19 | it 'save a new notice' do | 19 | it 'save a new notice' do |
| 20 | expect { | 20 | expect { |
| 21 | post '/notifier_api/v2/notices', :data => xml | 21 | post '/notifier_api/v2/notices', :data => xml |
| @@ -28,7 +28,7 @@ describe "Notices management", type: 'request' do | @@ -28,7 +28,7 @@ describe "Notices management", type: 'request' do | ||
| 28 | 28 | ||
| 29 | context "with notice with bad api_key" do | 29 | context "with notice with bad api_key" do |
| 30 | let(:errbit_app) { Fabricate(:app) } | 30 | let(:errbit_app) { Fabricate(:app) } |
| 31 | - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } | 31 | + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 32 | it 'not save a new notice and return 422' do | 32 | it 'not save a new notice and return 422' do |
| 33 | expect { | 33 | expect { |
| 34 | post '/notifier_api/v2/notices', :data => xml | 34 | post '/notifier_api/v2/notices', :data => xml |
| @@ -39,7 +39,7 @@ describe "Notices management", type: 'request' do | @@ -39,7 +39,7 @@ describe "Notices management", type: 'request' do | ||
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | context "with GET request" do | 41 | context "with GET request" do |
| 42 | - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } | 42 | + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 43 | it 'save a new notice' do | 43 | it 'save a new notice' do |
| 44 | expect { | 44 | expect { |
| 45 | get '/notifier_api/v2/notices', :data => xml | 45 | get '/notifier_api/v2/notices', :data => xml |
spec/views/apps/edit.html.haml_spec.rb
| @@ -27,7 +27,7 @@ describe "apps/edit.html.haml", type: 'view' do | @@ -27,7 +27,7 @@ describe "apps/edit.html.haml", type: 'view' do | ||
| 27 | context "with unvalid app" do | 27 | context "with unvalid app" do |
| 28 | let(:app) { | 28 | let(:app) { |
| 29 | app = stub_model(App) | 29 | app = stub_model(App) |
| 30 | - app.errors.add(:base,'You must specify your') | 30 | + app.errors.add(:base, 'You must specify your') |
| 31 | app | 31 | app |
| 32 | } | 32 | } |
| 33 | 33 |
spec/views/apps/new.html.haml_spec.rb
| @@ -23,7 +23,7 @@ describe "apps/new.html.haml", type: 'view' do | @@ -23,7 +23,7 @@ describe "apps/new.html.haml", type: 'view' do | ||
| 23 | context "with unvalid app" do | 23 | context "with unvalid app" do |
| 24 | let(:app) { | 24 | let(:app) { |
| 25 | app = stub_model(App) | 25 | app = stub_model(App) |
| 26 | - app.errors.add(:base,'You must specify your') | 26 | + app.errors.add(:base, 'You must specify your') |
| 27 | app | 27 | app |
| 28 | } | 28 | } |
| 29 | 29 |
spec/views/apps/show.atom.builder_spec.rb
| 1 | describe "apps/show.atom.builder", type: 'view' do | 1 | describe "apps/show.atom.builder", type: 'view' do |
| 2 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
| 3 | - let(:problems) { [ | ||
| 4 | - stub_model(Problem, :message => 'foo', :app => app) | ||
| 5 | - ]} | 3 | + let(:problems) { [stub_model(Problem, :message => 'foo', :app => app)] } |
| 6 | 4 | ||
| 7 | before do | 5 | before do |
| 8 | allow(view).to receive(:app).and_return(app) | 6 | allow(view).to receive(:app).and_return(app) |
spec/views/problems/index.html.haml_spec.rb
| @@ -22,7 +22,6 @@ describe "problems/index.html.haml", type: 'view' do | @@ -22,7 +22,6 @@ describe "problems/index.html.haml", type: 'view' do | ||
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | describe "show/hide resolved button behavior" do | 24 | describe "show/hide resolved button behavior" do |
| 25 | - | ||
| 26 | it "displays unresolved errors title and button" do | 25 | it "displays unresolved errors title and button" do |
| 27 | allow(view).to receive(:all_errs).and_return(false) | 26 | allow(view).to receive(:all_errs).and_return(false) |
| 28 | render | 27 | render |
| @@ -36,6 +35,5 @@ describe "problems/index.html.haml", type: 'view' do | @@ -36,6 +35,5 @@ describe "problems/index.html.haml", type: 'view' do | ||
| 36 | expect(view.content_for :title).to match 'All Errors' | 35 | expect(view.content_for :title).to match 'All Errors' |
| 37 | expect(view.content_for :action_bar).to have_link 'hide resolved' | 36 | expect(view.content_for :action_bar).to have_link 'hide resolved' |
| 38 | end | 37 | end |
| 39 | - | ||
| 40 | end | 38 | end |
| 41 | end | 39 | end |