Commit 46aadb58946834b93a708890227ab93579041014

Authored by Laust Rud Jacobsen
1 parent fe3f623c
Exists in master and in 1 other branch production

Rubocop: hashes: format neatly with symbols for keys and aligned values

Showing 141 changed files with 947 additions and 958 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 141 files displayed.

@@ -36,6 +36,9 @@ Style/DotPosition: @@ -36,6 +36,9 @@ Style/DotPosition:
36 Style/IndentHash: 36 Style/IndentHash:
37 EnforcedStyle: consistent 37 EnforcedStyle: consistent
38 38
  39 +Style/AlignHash:
  40 + EnforcedColonStyle: table
  41 +
39 Style/SpaceAroundOperators: 42 Style/SpaceAroundOperators:
40 MultiSpaceAllowedForOperators: 43 MultiSpaceAllowedForOperators:
41 - '=' 44 - '='
.rubocop_todo.yml
@@ -53,17 +53,6 @@ Rails/Validation: @@ -53,17 +53,6 @@ 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.
@@ -141,12 +130,6 @@ Style/FormatString: @@ -141,12 +130,6 @@ Style/FormatString:
141 Style/GuardClause: 130 Style/GuardClause:
142 Enabled: false 131 Enabled: false
143 132
144 -# Offense count: 1168  
145 -# Cop supports --auto-correct.  
146 -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.  
147 -Style/HashSyntax:  
148 - Enabled: false  
149 -  
150 # Offense count: 6 133 # Offense count: 6
151 # Cop supports --auto-correct. 134 # Cop supports --auto-correct.
152 # Configuration parameters: MaxLineLength. 135 # Configuration parameters: MaxLineLength.
@@ -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 }
@@ -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
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.
@@ -45,6 +45,6 @@ private @@ -45,6 +45,6 @@ private
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) {
@@ -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/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)
@@ -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
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
@@ -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/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
@@ -58,7 +58,7 @@ module ApplicationHelper @@ -58,7 +58,7 @@ module ApplicationHelper
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] }. \ 59 rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \
60 sort { |a, b| b[0] <=> a[0] } 60 sort { |a, b| b[0] <=> a[0] }
61 - render "problems/tally_table", :rows => rows 61 + render "problems/tally_table", rows: rows
62 end 62 end
63 63
64 def head(collection) 64 def head(collection)
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 }. 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;" }) 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,7 +2,7 @@ module FormHelper @@ -2,7 +2,7 @@ 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('') do |errs, msg| 8 document.errors.full_messages.inject('') do |errs, msg|
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
@@ -6,7 +6,7 @@ module SortHelper @@ -6,7 +6,7 @@ module SortHelper
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
@@ -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/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
@@ -23,8 +23,8 @@ class Mailer &lt; ActionMailer::Base @@ -23,8 +23,8 @@ class Mailer &lt; ActionMailer::Base
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)
@@ -36,8 +36,8 @@ class Mailer &lt; ActionMailer::Base @@ -36,8 +36,8 @@ class Mailer &lt; ActionMailer::Base
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)
@@ -54,8 +54,8 @@ class Mailer &lt; ActionMailer::Base @@ -54,8 +54,8 @@ class Mailer &lt; ActionMailer::Base
54 'Problem-Id' => @problem.id, 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,51 +3,54 @@ class App @@ -3,51 +3,54 @@ 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, ->(user) do
@@ -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
app/models/backtrace.rb
@@ -8,7 +8,7 @@ class Backtrace @@ -8,7 +8,7 @@ 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)
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,11 +8,11 @@ class Deploy @@ -8,11 +8,11 @@ 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
@@ -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_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,21 +5,21 @@ class Notice @@ -5,21 +5,21 @@ 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
app/models/notification_service.rb
@@ -5,22 +5,22 @@ class NotificationService @@ -5,22 +5,22 @@ 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, 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)' 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
app/models/notification_services/campfire_service.rb
@@ -3,16 +3,16 @@ if defined? Campy @@ -3,16 +3,16 @@ if defined? Campy
3 LABEL = "campfire" 3 LABEL = "campfire"
4 FIELDS += [ 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
@@ -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
@@ -4,8 +4,8 @@ if defined? Flowdock @@ -4,8 +4,8 @@ if defined? Flowdock
4 FIELDS += [ 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 ]
@@ -21,10 +21,10 @@ if defined? Flowdock @@ -21,10 +21,10 @@ 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(api_token: api_token, source: "Errbit", from: { name: "Errbit", address: ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' })
25 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}" 25 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}"
26 url = app_problem_url problem.app, problem 26 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) 27 + flow.push_to_team_inbox(subject: subject, content: content(problem, url), project: project_name(problem), link: url)
28 end 28 end
29 29
30 private 30 private
app/models/notification_services/gtalk_service.rb
@@ -2,28 +2,28 @@ class NotificationServices::GtalkService &lt; NotificationService @@ -2,28 +2,28 @@ class NotificationServices::GtalkService &lt; NotificationService
2 LABEL = "gtalk" 2 LABEL = "gtalk"
3 FIELDS += [ 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, { 20 [:service, {
21 - :placeholder => "talk.google.com",  
22 - :label => "Jabber Service" 21 + placeholder: "talk.google.com",
  22 + label: "Jabber Service"
23 }], 23 }],
24 [:service_url, { 24 [:service_url, {
25 - :placeholder => "http://www.google.com/talk/",  
26 - :label => "Link To Jabber Service" 25 + placeholder: "http://www.google.com/talk/",
  26 + label: "Link To Jabber Service"
27 }] 27 }]
28 ] 28 ]
29 29
app/models/notification_services/hipchat_service.rb
@@ -3,20 +3,20 @@ if defined? HipChat @@ -3,20 +3,20 @@ if defined? HipChat
3 LABEL = 'hipchat' 3 LABEL = 'hipchat'
4 FIELDS += [ 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" 18 + placeholder: "Room name",
  19 + label: "Room name"
20 }] 20 }]
21 ] 21 ]
22 MANDATORY_FIELDS = [:service, :api_token, :room_id] 22 MANDATORY_FIELDS = [:service, :api_token, :room_id]
@@ -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
@@ -2,16 +2,16 @@ class NotificationServices::HoiioService &lt; NotificationService @@ -2,16 +2,16 @@ class NotificationServices::HoiioService &lt; NotificationService
2 LABEL = "hoiio" 2 LABEL = "hoiio"
3 FIELDS += [ 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
@@ -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
@@ -2,12 +2,12 @@ class NotificationServices::HubotService &lt; NotificationService @@ -2,12 +2,12 @@ class NotificationServices::HubotService &lt; NotificationService
2 LABEL = "hubot" 2 LABEL = "hubot"
3 FIELDS += [ 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
@@ -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
@@ -2,12 +2,12 @@ class NotificationServices::PushoverService &lt; NotificationService @@ -2,12 +2,12 @@ class NotificationServices::PushoverService &lt; NotificationService
2 LABEL = "pushover" 2 LABEL = "pushover"
3 FIELDS += [ 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
@@ -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
@@ -2,8 +2,8 @@ class NotificationServices::SlackService &lt; NotificationService @@ -2,8 +2,8 @@ class NotificationServices::SlackService &lt; NotificationService
2 LABEL = "slack" 2 LABEL = "slack"
3 FIELDS += [ 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
@@ -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,7 @@ class NotificationServices::SlackService &lt; NotificationService @@ -62,7 +62,7 @@ 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(service_url, body: post_payload(problem), headers: { 'Content-Type' => 'application/json' })
66 end 66 end
67 67
68 def configured? 68 def configured?
app/models/notification_services/webhook_service.rb
@@ -2,8 +2,8 @@ class NotificationServices::WebhookService &lt; NotificationService @@ -2,8 +2,8 @@ class NotificationServices::WebhookService &lt; NotificationService
2 LABEL = "webhook" 2 LABEL = "webhook"
3 FIELDS = [ 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
@@ -14,10 +14,10 @@ class NotificationServices::WebhookService &lt; NotificationService @@ -14,10 +14,10 @@ class NotificationServices::WebhookService &lt; NotificationService
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 + { problem: { url: problem_url(problem) }.merge(problem.as_json).to_json }
18 end 18 end
19 19
20 def create_notification(problem) 20 def create_notification(problem)
21 - HTTParty.post(api_token, :body => message_for_webhook(problem)) 21 + HTTParty.post(api_token, body: message_for_webhook(problem))
22 end 22 end
23 end 23 end
app/models/problem.rb
@@ -7,59 +7,59 @@ class Problem @@ -7,59 +7,59 @@ 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 { 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 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) } 61 + scope :resolved, -> { where(resolved: true) }
  62 + scope :unresolved, -> { where(resolved: false) }
63 scope :ordered, -> { order_by(:last_notice_at.desc) } 63 scope :ordered, -> { order_by(:last_notice_at.desc) }
64 scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } 64 scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) }
65 65
@@ -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)
@@ -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
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
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/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/devise.rb
@@ -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 => %r{^/deploys} 6 + config.middleware.use Rack::SslEnforcer, except: %r{^/deploys}
7 end 7 end
8 end 8 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
@@ -35,7 +35,7 @@ class ExtractIssueTracker &lt; Mongoid::Migration @@ -35,7 +35,7 @@ class ExtractIssueTracker &lt; Mongoid::Migration
35 } 35 }
36 36
37 App.where({ _id: app.id }).update({ 37 App.where({ _id: app.id }).update({
38 - "$set" => { :issue_tracker => tracker } 38 + "$set" => { issue_tracker: tracker }
39 }) 39 })
40 end 40 end
41 end 41 end
@@ -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)
@@ -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 }
lib/hoptoad/v2.rb
@@ -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
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]
@@ -44,28 +44,28 @@ namespace :errbit do @@ -44,28 +44,28 @@ namespace :errbit do
44 errors.each do |error_template| 44 errors.each do |error_template|
45 rand(34).times do 45 rand(34).times do
46 ErrorReport.new(error_template.reverse_merge({ 46 ErrorReport.new(error_template.reverse_merge({
47 - :api_key => app.api_key,  
48 - :error_class => "StandardError",  
49 - :message => "Oops. Something went wrong!",  
50 - :backtrace => random_backtrace,  
51 - :request => { 47 + api_key: app.api_key,
  48 + error_class: "StandardError",
  49 + message: "Oops. Something went wrong!",
  50 + backtrace: random_backtrace,
  51 + request: {
52 'component' => 'main', 52 'component' => 'main',
53 'action' => 'error', 53 'action' => 'error',
54 'url' => "http://example.com/post/#{[111, 222, 333].sample}" 54 'url' => "http://example.com/post/#{[111, 222, 333].sample}"
55 }, 55 },
56 - :server_environment => { 'environment-name' => Rails.env.to_s },  
57 - :notifier => { :name => "seeds.rb" },  
58 - :app_user => {  
59 - :id => "1234",  
60 - :username => "jsmith",  
61 - :name => "John Smith",  
62 - :url => "http://www.example.com/users/jsmith" 56 + server_environment: { 'environment-name' => Rails.env.to_s },
  57 + notifier: { name: "seeds.rb" },
  58 + app_user: {
  59 + id: "1234",
  60 + username: "jsmith",
  61 + name: "John Smith",
  62 + url: "http://www.example.com/users/jsmith"
63 } 63 }
64 })).generate_notice! 64 })).generate_notice!
65 end 65 end
66 end 66 end
67 67
68 - Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app))) 68 + Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app)))
69 puts "=== Created demo app: '#{app.name}', with example errors." 69 puts "=== Created demo app: '#{app.name}', with example errors."
70 end 70 end
71 end 71 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
@@ -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/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 25 + get :show, auth_token: @user.authentication_token, id: @problem.id
26 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) 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" 69 + get :index, auth_token: @user.authentication_token, format: "json"
70 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) 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 79 + get :index, auth_token: @user.authentication_token
80 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) 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/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,7 +41,7 @@ describe CommentsController, type: &#39;controller&#39; do @@ -41,7 +41,7 @@ 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
spec/controllers/deploys_controller_spec.rb
@@ -10,30 +10,30 @@ describe DeploysController, type: &#39;controller&#39; do @@ -10,30 +10,30 @@ 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({ 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' 25 + username: 'john.doe',
  26 + environment: 'production',
  27 + repository: 'git@github.com/errbit/errbit.git',
  28 + revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5',
  29 + message: 'johns first deploy'
30 30
31 }).and_return(Fabricate(:deploy)) 31 }).and_return(Fabricate(:deploy))
32 - post :create, :deploy => @params, :api_key => 'APIKEY' 32 + post :create, deploy: @params, api_key: 'APIKEY'
33 end 33 end
34 34
35 it 'sends an email notification when configured to do so' do 35 it 'sends an email notification when configured to do so' do
36 - post :create, :deploy => @params, :api_key => 'APIKEY' 36 + post :create, deploy: @params, api_key: 'APIKEY'
37 email = ActionMailer::Base.deliveries.last 37 email = ActionMailer::Base.deliveries.last
38 expect(email.to).to include(@app.watchers.first.email) 38 expect(email.to).to include(@app.watchers.first.email)
39 expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" 39 expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe"
@@ -44,7 +44,7 @@ describe DeploysController, type: &#39;controller&#39; do @@ -44,7 +44,7 @@ describe DeploysController, type: &#39;controller&#39; do
44 before(:each) do 44 before(:each) do
45 @deploy = Fabricate :deploy 45 @deploy = Fabricate :deploy
46 sign_in Fabricate(:admin) 46 sign_in Fabricate(:admin)
47 - get :index, :app_id => @deploy.app.id 47 + get :index, app_id: @deploy.app.id
48 end 48 end
49 49
50 it "should render successfully" do 50 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,25 +301,25 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -301,25 +301,25 @@ 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
@@ -327,7 +327,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -327,7 +327,7 @@ describe ProblemsController, type: &#39;controller&#39; 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 { 329 expect {
330 - post :unmerge_several, :problems => [merged_problem.id.to_s] 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,12 +358,12 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -358,12 +358,12 @@ 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
@@ -371,7 +371,7 @@ describe ProblemsController, type: &#39;controller&#39; do @@ -371,7 +371,7 @@ describe ProblemsController, type: &#39;controller&#39; do
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 { 373 expect {
374 - post :destroy_several, :problems => [@problem1.id.to_s] 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,7 +230,7 @@ describe UsersController, type: &#39;controller&#39; do @@ -230,7 +230,7 @@ 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
spec/controllers/watchers_controller_spec.rb
@@ -15,7 +15,7 @@ describe WatchersController, type: &#39;controller&#39; do @@ -15,7 +15,7 @@ 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
@@ -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
@@ -11,8 +11,8 @@ describe IssueTrackerDecorator do @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do
11 11
12 def self.fields 12 def self.fields
13 { 13 {
14 - :foo => { :label => 'foo' },  
15 - :bar => { :label => 'bar' } 14 + foo: { label: 'foo' },
  15 + bar: { label: 'bar' }
16 } 16 }
17 end 17 end
18 18
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
@@ -11,8 +11,8 @@ describe IssueTrackerDecorator do @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do
11 11
12 def self.fields 12 def self.fields
13 { 13 {
14 - :foo => { :label => 'foo' },  
15 - :bar => { :label => 'bar' } 14 + foo: { label: 'foo' },
  15 + bar: { label: 'bar' }
16 } 16 }
17 end 17 end
18 18
@@ -45,7 +45,7 @@ describe IssueTrackerDecorator do @@ -45,7 +45,7 @@ describe IssueTrackerDecorator do
45 decorator.fields do |itf| 45 decorator.fields do |itf|
46 expect(itf).to be_a(IssueTrackerFieldDecorator) 46 expect(itf).to be_a(IssueTrackerFieldDecorator)
47 expect([:foo, :bar]).to be_include(itf.object) 47 expect([:foo, :bar]).to be_include(itf.object)
48 - expect([{ :label => 'foo' }, { :label => 'bar' }]).to be_include(itf.field_info) 48 + expect([{ label: 'foo' }, { label: 'bar' }]).to be_include(itf.field_info)
49 end 49 end
50 end 50 end
51 end 51 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
spec/errbit_plugin/mock_issue_tracker.rb
@@ -10,8 +10,8 @@ module ErrbitPlugin @@ -10,8 +10,8 @@ module ErrbitPlugin
10 10
11 def self.fields 11 def self.fields
12 { 12 {
13 - :foo => { :label => 'foo' },  
14 - :bar => { :label => 'bar' } 13 + foo: { label: 'foo' },
  14 + bar: { label: 'bar' }
15 } 15 }
16 end 16 end
17 17
spec/fabricators/app_fabricator.rb
@@ -3,9 +3,9 @@ Fabricator(:app) do @@ -3,9 +3,9 @@ Fabricator(:app) do
3 repository_branch 'master' 3 repository_branch 'master'
4 end 4 end
5 5
6 -Fabricator(:app_with_watcher, :from => :app) do  
7 - watchers(:count => 1) { |parent, _i|  
8 - Fabricate.build(:watcher, :app => parent) 6 +Fabricator(:app_with_watcher, from: :app) do
  7 + watchers(count: 1) { |parent, _i|
  8 + Fabricate.build(:watcher, app: parent)
9 } 9 }
10 end 10 end
11 11
@@ -15,7 +15,7 @@ Fabricator(:watcher) do @@ -15,7 +15,7 @@ Fabricator(:watcher) do
15 email { sequence(:email) { |n| "email#{n}@example.com" } } 15 email { sequence(:email) { |n| "email#{n}@example.com" } }
16 end 16 end
17 17
18 -Fabricator(:user_watcher, :from => :watcher) do 18 +Fabricator(:user_watcher, from: :watcher) do
19 user 19 user
20 watcher_type 'user' 20 watcher_type 'user'
21 end 21 end
spec/fabricators/backtrace_fabricator.rb
1 Fabricator :backtrace do 1 Fabricator :backtrace do
2 - lines(:count => 99) do 2 + lines(count: 99) do
3 { 3 {
4 number: rand(999), 4 number: rand(999),
5 - file: "/path/to/file/#{SecureRandom.hex(4)}.rb", 5 + file: "/path/to/file/#{SecureRandom.hex(4)}.rb",
6 method: ActiveSupport.methods.sample 6 method: ActiveSupport.methods.sample
7 } 7 }
8 end 8 end
spec/fabricators/comment_fabricator.rb
1 Fabricator :comment do 1 Fabricator :comment do
2 user 2 user
3 body 'Test comment' 3 body 'Test comment'
4 - err(:fabricator => :problem) 4 + err(fabricator: :problem)
5 end 5 end
spec/fabricators/issue_tracker_fabricator.rb
@@ -2,8 +2,8 @@ Fabricator :issue_tracker do @@ -2,8 +2,8 @@ Fabricator :issue_tracker do
2 type_tracker 'mock' 2 type_tracker 'mock'
3 options { 3 options {
4 { 4 {
5 - :foo => 'one',  
6 - :bar => 'two' 5 + foo: 'one',
  6 + bar: 'two'
7 }} 7 }}
8 app 8 app
9 end 9 end
spec/fabricators/notification_service_fabricator.rb
@@ -6,20 +6,20 @@ Fabricator :notification_service do @@ -6,20 +6,20 @@ Fabricator :notification_service do
6 notify_at_notices { sequence { |_a| [0] } } 6 notify_at_notices { sequence { |_a| [0] } }
7 end 7 end
8 8
9 -Fabricator :gtalk_notification_service, :from => :notification_service, :class_name => "NotificationServices::GtalkService" do 9 +Fabricator :gtalk_notification_service, from: :notification_service, class_name: "NotificationServices::GtalkService" do
10 user_id { sequence :word } 10 user_id { sequence :word }
11 service_url { sequence :word } 11 service_url { sequence :word }
12 service { sequence :word } 12 service { sequence :word }
13 end 13 end
14 14
15 -Fabricator :slack_notification_service, :from => :notification_service, :class_name => "NotificationServices::SlackService" do 15 +Fabricator :slack_notification_service, from: :notification_service, class_name: "NotificationServices::SlackService" do
16 service_url { sequence :word } 16 service_url { sequence :word }
17 end 17 end
18 18
19 -Fabricator :hipchat_notification_service, :from => :notification_service, :class_name => "NotificationServices::HipchatService" do 19 +Fabricator :hipchat_notification_service, from: :notification_service, class_name: "NotificationServices::HipchatService" do
20 service { 'v2' } 20 service { 'v2' }
21 end 21 end
22 22
23 %w(campfire flowdock hoiio hubot pushover webhook).each do |t| 23 %w(campfire flowdock hoiio hubot pushover webhook).each do |t|
24 - Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationServices::#{t.camelcase}Service" 24 + Fabricator "#{t}_notification_service".to_sym, from: :notification_service, class_name: "NotificationServices::#{t.camelcase}Service"
25 end 25 end
spec/fabricators/problem_fabricator.rb
@@ -5,25 +5,25 @@ Fabricator(:problem) do @@ -5,25 +5,25 @@ Fabricator(:problem) do
5 environment 'production' 5 environment 'production'
6 end 6 end
7 7
8 -Fabricator(:problem_with_comments, :from => :problem) do 8 +Fabricator(:problem_with_comments, from: :problem) do
9 after_create { |parent| 9 after_create { |parent|
10 3.times do 10 3.times do
11 - Fabricate(:comment, :err => parent) 11 + Fabricate(:comment, err: parent)
12 end 12 end
13 } 13 }
14 end 14 end
15 15
16 -Fabricator(:problem_with_errs, :from => :problem) do 16 +Fabricator(:problem_with_errs, from: :problem) do
17 after_create { |parent| 17 after_create { |parent|
18 3.times do 18 3.times do
19 - Fabricate(:err, :problem => parent) 19 + Fabricate(:err, problem: parent)
20 end 20 end
21 } 21 }
22 end 22 end
23 23
24 -Fabricator(:problem_resolved, :from => :problem) do 24 +Fabricator(:problem_resolved, from: :problem) do
25 after_create do |pr| 25 after_create do |pr|
26 - Fabricate(:notice, :err => Fabricate(:err, :problem => pr)) 26 + Fabricate(:notice, err: Fabricate(:err, problem: pr))
27 pr.resolve! 27 pr.resolve!
28 end 28 end
29 end 29 end
spec/fabricators/user_fabricator.rb
@@ -5,6 +5,6 @@ Fabricator :user do @@ -5,6 +5,6 @@ Fabricator :user do
5 password_confirmation 'password' 5 password_confirmation 'password'
6 end 6 end
7 7
8 -Fabricator :admin, :from => :user do 8 +Fabricator :admin, from: :user do
9 admin true 9 admin true
10 end 10 end
spec/helpers/problems_helper_spec.rb
1 describe ProblemsHelper do 1 describe ProblemsHelper do
2 describe '#truncated_problem_message' do 2 describe '#truncated_problem_message' do
3 it 'is html safe' do 3 it 'is html safe' do
4 - problem = double('problem', :message => '#<NoMethodError: ...>') 4 + problem = double('problem', message: '#<NoMethodError: ...>')
5 truncated = helper.truncated_problem_message(problem) 5 truncated = helper.truncated_problem_message(problem)
6 expect(truncated).to be_html_safe 6 expect(truncated).to be_html_safe
7 expect(truncated).to_not include('<', '>') 7 expect(truncated).to_not include('<', '>')
8 end 8 end
9 9
10 it 'does not double escape html' do 10 it 'does not double escape html' do
11 - problem = double('problem', :message => '#<NoMethodError: ...>') 11 + problem = double('problem', message: '#<NoMethodError: ...>')
12 truncated = helper.truncated_problem_message(problem) 12 truncated = helper.truncated_problem_message(problem)
13 expect(truncated).to be_html_safe 13 expect(truncated).to be_html_safe
14 expect(truncated).to_not include('&amp;') 14 expect(truncated).to_not include('&amp;')
@@ -28,12 +28,12 @@ describe ProblemsHelper do @@ -28,12 +28,12 @@ describe ProblemsHelper do
28 28
29 it "should render image_tag with correct alt and src" do 29 it "should render image_tag with correct alt and src" do
30 expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&amp;s=48\" />" 30 expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&amp;s=48\" />"
31 - expect(helper.gravatar_tag(email, :s => 48)).to eq(expected) 31 + expect(helper.gravatar_tag(email, s: 48)).to eq(expected)
32 end 32 end
33 33
34 it "should override :d" do 34 it "should override :d" do
35 expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&amp;s=48\" />" 35 expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&amp;s=48\" />"
36 - expect(helper.gravatar_tag(email, :d => 'retro', :s => 48)).to eq(expected) 36 + expect(helper.gravatar_tag(email, d: 'retro', s: 48)).to eq(expected)
37 end 37 end
38 end 38 end
39 39
spec/initializers/action_mailer_spec.rb
@@ -35,12 +35,12 @@ describe &#39;initializers/action_mailer&#39; do @@ -35,12 +35,12 @@ describe &#39;initializers/action_mailer&#39; do
35 load_initializer 35 load_initializer
36 36
37 expect(ActionMailer::Base.smtp_settings).to eq({ 37 expect(ActionMailer::Base.smtp_settings).to eq({
38 - address: 'smtp.somedomain.com',  
39 - port: 998, 38 + address: 'smtp.somedomain.com',
  39 + port: 998,
40 authentication: :login, 40 authentication: :login,
41 - user_name: 'my-username',  
42 - password: 'my-password',  
43 - domain: 'someotherdomain.com' 41 + user_name: 'my-username',
  42 + password: 'my-password',
  43 + domain: 'someotherdomain.com'
44 }) 44 })
45 end 45 end
46 end 46 end
spec/initializers/devise_spec.rb
@@ -15,9 +15,9 @@ describe &#39;initializers/devise&#39; do @@ -15,9 +15,9 @@ describe &#39;initializers/devise&#39; do
15 options = Devise.omniauth_configs[:github].options 15 options = Devise.omniauth_configs[:github].options
16 expect(options).to have_key(:client_options) 16 expect(options).to have_key(:client_options)
17 expect(options[:client_options]).to eq({ 17 expect(options[:client_options]).to eq({
18 - site: 'https://api.github.com', 18 + site: 'https://api.github.com',
19 authorize_url: 'https://github.com/login/oauth/authorize', 19 authorize_url: 'https://github.com/login/oauth/authorize',
20 - token_url: 'https://github.com/login/oauth/access_token' 20 + token_url: 'https://github.com/login/oauth/access_token'
21 }) 21 })
22 end 22 end
23 23
@@ -29,9 +29,9 @@ describe &#39;initializers/devise&#39; do @@ -29,9 +29,9 @@ describe &#39;initializers/devise&#39; do
29 options = Devise.omniauth_configs[:github].options 29 options = Devise.omniauth_configs[:github].options
30 expect(options).to have_key(:client_options) 30 expect(options).to have_key(:client_options)
31 expect(options[:client_options]).to eq({ 31 expect(options[:client_options]).to eq({
32 - site: 'https://github.example.com/api/v3', 32 + site: 'https://github.example.com/api/v3',
33 authorize_url: 'https://github.example.com/login/oauth/authorize', 33 authorize_url: 'https://github.example.com/login/oauth/authorize',
34 - token_url: 'https://github.example.com/login/oauth/access_token' 34 + token_url: 'https://github.example.com/login/oauth/access_token'
35 }) 35 })
36 end 36 end
37 end 37 end
spec/interactors/problem_destroy_spec.rb
@@ -6,8 +6,8 @@ describe ProblemDestroy do @@ -6,8 +6,8 @@ describe ProblemDestroy do
6 context "in unit way" do 6 context "in unit way" do
7 let(:problem) { 7 let(:problem) {
8 problem = Problem.new 8 problem = Problem.new
9 - allow(problem).to receive(:errs).and_return(double(:criteria, :only => [err_1, err_2]))  
10 - allow(problem).to receive(:comments).and_return(double(:criteria, :only => [comment_1, comment_2])) 9 + allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2]))
  10 + allow(problem).to receive(:comments).and_return(double(:criteria, only: [comment_1, comment_2]))
11 allow(problem).to receive(:delete) 11 allow(problem).to receive(:delete)
12 problem 12 problem
13 } 13 }
@@ -30,17 +30,17 @@ describe ProblemDestroy do @@ -30,17 +30,17 @@ describe ProblemDestroy do
30 end 30 end
31 31
32 it 'delete all errs associate' do 32 it 'delete all errs associate' do
33 - expect(Err).to receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) 33 + expect(Err).to receive(:delete_all).with(_id: { '$in' => [err_1.id, err_2.id] })
34 problem_destroy.execute 34 problem_destroy.execute
35 end 35 end
36 36
37 it 'delete all comments associate' do 37 it 'delete all comments associate' do
38 - expect(Comment).to receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) 38 + expect(Comment).to receive(:delete_all).with(_id: { '$in' => [comment_1.id, comment_2.id] })
39 problem_destroy.execute 39 problem_destroy.execute
40 end 40 end
41 41
42 it 'delete all notice of associate to this errs' do 42 it 'delete all notice of associate to this errs' do
43 - expect(Notice).to receive(:delete_all).with({ :err_id => { '$in' => [err_1.id, err_2.id] } }) 43 + expect(Notice).to receive(:delete_all).with({ err_id: { '$in' => [err_1.id, err_2.id] } })
44 problem_destroy.execute 44 problem_destroy.execute
45 end 45 end
46 end 46 end
@@ -48,26 +48,26 @@ describe ProblemDestroy do @@ -48,26 +48,26 @@ describe ProblemDestroy do
48 48
49 context "in integration way" do 49 context "in integration way" do
50 let!(:problem) { Fabricate(:problem) } 50 let!(:problem) { Fabricate(:problem) }
51 - let!(:comment_1) { Fabricate(:comment, :err => problem) }  
52 - let!(:comment_2) { Fabricate(:comment, :err => problem) }  
53 - let!(:err_1) { Fabricate(:err, :problem => problem) }  
54 - let!(:err_2) { Fabricate(:err, :problem => problem) }  
55 - let!(:notice_1_1) { Fabricate(:notice, :err => err_1) }  
56 - let!(:notice_1_2) { Fabricate(:notice, :err => err_1) }  
57 - let!(:notice_2_1) { Fabricate(:notice, :err => err_2) }  
58 - let!(:notice_2_2) { Fabricate(:notice, :err => err_2) } 51 + let!(:comment_1) { Fabricate(:comment, err: problem) }
  52 + let!(:comment_2) { Fabricate(:comment, err: problem) }
  53 + let!(:err_1) { Fabricate(:err, problem: problem) }
  54 + let!(:err_2) { Fabricate(:err, problem: problem) }
  55 + let!(:notice_1_1) { Fabricate(:notice, err: err_1) }
  56 + let!(:notice_1_2) { Fabricate(:notice, err: err_1) }
  57 + let!(:notice_2_1) { Fabricate(:notice, err: err_2) }
  58 + let!(:notice_2_2) { Fabricate(:notice, err: err_2) }
59 59
60 it 'should all destroy' do 60 it 'should all destroy' do
61 problem_destroy.execute 61 problem_destroy.execute
62 - expect(Problem.where(:_id => problem.id).entries).to be_empty  
63 - expect(Err.where(:_id => err_1.id).entries).to be_empty  
64 - expect(Err.where(:_id => err_2.id).entries).to be_empty  
65 - expect(Comment.where(:_id => comment_1.id).entries).to be_empty  
66 - expect(Comment.where(:_id => comment_2.id).entries).to be_empty  
67 - expect(Notice.where(:_id => notice_1_1.id).entries).to be_empty  
68 - expect(Notice.where(:_id => notice_1_2.id).entries).to be_empty  
69 - expect(Notice.where(:_id => notice_2_1.id).entries).to be_empty  
70 - expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty 62 + expect(Problem.where(_id: problem.id).entries).to be_empty
  63 + expect(Err.where(_id: err_1.id).entries).to be_empty
  64 + expect(Err.where(_id: err_2.id).entries).to be_empty
  65 + expect(Comment.where(_id: comment_1.id).entries).to be_empty
  66 + expect(Comment.where(_id: comment_2.id).entries).to be_empty
  67 + expect(Notice.where(_id: notice_1_1.id).entries).to be_empty
  68 + expect(Notice.where(_id: notice_1_2.id).entries).to be_empty
  69 + expect(Notice.where(_id: notice_2_1.id).entries).to be_empty
  70 + expect(Notice.where(_id: notice_2_2.id).entries).to be_empty
71 end 71 end
72 end 72 end
73 end 73 end
spec/interactors/problem_merge_spec.rb
@@ -25,8 +25,8 @@ describe ProblemMerge do @@ -25,8 +25,8 @@ describe ProblemMerge do
25 } 25 }
26 let(:first_errs) { problem.errs } 26 let(:first_errs) { problem.errs }
27 let(:merged_errs) { problem_1.errs } 27 let(:merged_errs) { problem_1.errs }
28 - let!(:notice) { Fabricate(:notice, :err => first_errs.first) }  
29 - let!(:notice_1) { Fabricate(:notice, :err => merged_errs.first) } 28 + let!(:notice) { Fabricate(:notice, err: first_errs.first) }
  29 + let!(:notice_1) { Fabricate(:notice, err: merged_errs.first) }
30 30
31 it 'delete one of problem' do 31 it 'delete one of problem' do
32 expect { 32 expect {
@@ -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/interactors/resolved_problem_clearer_spec.rb
@@ -20,7 +20,7 @@ describe ResolvedProblemClearer do @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do
20 end 20 end
21 it 'not repair database' do 21 it 'not repair database' do
22 allow(Mongoid.default_client).to receive(:command).and_call_original 22 allow(Mongoid.default_client).to receive(:command).and_call_original
23 - expect(Mongoid.default_client).to_not receive(:command).with({ :repairDatabase => 1 }) 23 + expect(Mongoid.default_client).to_not receive(:command).with({ repairDatabase: 1 })
24 resolved_problem_clearer.execute 24 resolved_problem_clearer.execute
25 end 25 end
26 end 26 end
@@ -28,7 +28,7 @@ describe ResolvedProblemClearer do @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do
28 context "with problem resolve" do 28 context "with problem resolve" do
29 before do 29 before do
30 allow(Mongoid.default_client).to receive(:command).and_call_original 30 allow(Mongoid.default_client).to receive(:command).and_call_original
31 - allow(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) 31 + allow(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 })
32 problems.first.resolve! 32 problems.first.resolve!
33 problems.second.resolve! 33 problems.second.resolve!
34 end 34 end
@@ -39,12 +39,12 @@ describe ResolvedProblemClearer do @@ -39,12 +39,12 @@ describe ResolvedProblemClearer do
39 }.to change { 39 }.to change {
40 Problem.count 40 Problem.count
41 }.by(-2) 41 }.by(-2)
42 - expect(Problem.where(:_id => problems.first.id).first).to be_nil  
43 - expect(Problem.where(:_id => problems.second.id).first).to be_nil 42 + expect(Problem.where(_id: problems.first.id).first).to be_nil
  43 + expect(Problem.where(_id: problems.second.id).first).to be_nil
44 end 44 end
45 45
46 it 'repair database' do 46 it 'repair database' do
47 - expect(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) 47 + expect(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 })
48 resolved_problem_clearer.execute 48 resolved_problem_clearer.execute
49 end 49 end
50 end 50 end
spec/interactors/user_destroy_spec.rb
@@ -2,8 +2,8 @@ describe UserDestroy do @@ -2,8 +2,8 @@ describe UserDestroy do
2 let(:app) { 2 let(:app) {
3 Fabricate( 3 Fabricate(
4 :app, 4 :app,
5 - :watchers => [  
6 - Fabricate.build(:user_watcher, :user => user) 5 + watchers: [
  6 + Fabricate.build(:user_watcher, user: user)
7 ]) 7 ])
8 } 8 }
9 9
@@ -19,7 +19,7 @@ describe UserDestroy do @@ -19,7 +19,7 @@ describe UserDestroy do
19 expect { 19 expect {
20 UserDestroy.new(user).destroy 20 UserDestroy.new(user).destroy
21 }.to change { 21 }.to change {
22 - app.reload.watchers.where(:user_id => user.id).count 22 + app.reload.watchers.where(user_id: user.id).count
23 }.from(1).to(0) 23 }.from(1).to(0)
24 end 24 end
25 end 25 end