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
.rubocop.yml
... ... @@ -36,6 +36,9 @@ Style/DotPosition:
36 36 Style/IndentHash:
37 37 EnforcedStyle: consistent
38 38  
  39 +Style/AlignHash:
  40 + EnforcedColonStyle: table
  41 +
39 42 Style/SpaceAroundOperators:
40 43 MultiSpaceAllowedForOperators:
41 44 - '='
... ...
.rubocop_todo.yml
... ... @@ -53,17 +53,6 @@ Rails/Validation:
53 53 - 'app/models/problem.rb'
54 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 56 # Offense count: 105
68 57 # Cop supports --auto-correct.
69 58 # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
... ... @@ -141,12 +130,6 @@ Style/FormatString:
141 130 Style/GuardClause:
142 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 133 # Offense count: 6
151 134 # Cop supports --auto-correct.
152 135 # Configuration parameters: MaxLineLength.
... ...
Gemfile
... ... @@ -29,8 +29,8 @@ gem 'htmlentities'
29 29 gem 'kaminari', '>= 0.14.1'
30 30 gem 'mongoid', '5.0.0'
31 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 34 gem 'rails_autolink'
35 35 gem 'useragent'
36 36  
... ... @@ -44,7 +44,7 @@ gem 'campy'
44 44 # Hipchat
45 45 gem 'hipchat'
46 46 # Google Talk
47   -gem 'xmpp4r', :require => ["xmpp4r", "xmpp4r/muc"]
  47 +gem 'xmpp4r', require: ["xmpp4r", "xmpp4r/muc"]
48 48 # Hoiio (SMS)
49 49 gem 'hoi'
50 50 # Pushover (iOS Push notifications)
... ... @@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby'
64 64 gem 'json', platform: 'jruby'
65 65  
66 66 group :development, :test do
67   - gem 'airbrake', :require => false
  67 + gem 'airbrake', require: false
68 68 gem 'pry-rails'
69 69 gem 'pry-byebug', platforms: [:mri]
70 70 gem 'quiet_assets'
... ... @@ -103,7 +103,7 @@ group :heroku, :production do
103 103 gem 'unicorn', require: false, platform: 'ruby'
104 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 107 gem 'sass-rails'
108 108 gem 'uglifier'
109 109 # We can't upgrade because not compatible to jquery >= 1.9.
... ...
Rakefile
... ... @@ -8,7 +8,7 @@ Rails.application.load_tasks
8 8 begin
9 9 require 'rspec/core/rake_task'
10 10 RSpec::Core::RakeTask.new(:spec)
11   - task :default => :spec
  11 + task default: :spec
12 12 rescue LoadError
13 13 warn "Notice: no rspec tasks available in this environment"
14 14 end
... ...
app/controllers/api/v1/notices_controller.rb
... ... @@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController
8 8 if params.key?(:start_date) && params.key?(:end_date)
9 9 start_date = Time.zone.parse(params[:start_date]).utc
10 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 12 end
13 13  
14 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 16 end
17 17  
18 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 21 end
22 22 end
23 23 end
... ...
app/controllers/api/v1/problems_controller.rb
... ... @@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController
13 13 end
14 14  
15 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 18 end
19 19 end
20 20  
... ... @@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController
24 24 if params.key?(:start_date) && params.key?(:end_date)
25 25 start_date = Time.parse(params[:start_date]).utc
26 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 28 end
29 29  
30 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 32 end
33 33  
34 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 37 end
38 38 end
39 39 end
... ...
app/controllers/api/v1/stats_controller.rb
... ... @@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController
11 11 end
12 12  
13 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 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 23 end
24 24 end
25 25  
26 26 protected def require_api_key_or_authenticate_user!
27 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 29 return true
30 30 end
31 31 end
... ...
app/controllers/api/v3/notices_controller.rb
... ... @@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController
15 15 if report.should_keep?
16 16 report.generate_notice!
17 17 render json: {
18   - id: report.notice.id,
  18 + id: report.notice.id,
19 19 url: app_problem_url(
20 20 report.app,
21 21 report.error.problem_id)
... ...
app/controllers/application_controller.rb
... ... @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
5 5 before_action :authenticate_user!
6 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 10 class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy
11 11 def assign_attributes?
... ...
app/controllers/apps_controller.rb
1 1 class AppsController < ApplicationController
2 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 7 respond_to :html
8 8  
9 9 expose(:app_scope) { App }
... ... @@ -55,7 +55,7 @@ class AppsController &lt; ApplicationController
55 55 def create
56 56 initialize_subclassed_notification_service
57 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 59 else
60 60 flash[:error] = I18n.t('controllers.apps.flash.create.error')
61 61 render :new
... ... @@ -65,7 +65,7 @@ class AppsController &lt; ApplicationController
65 65 def update
66 66 initialize_subclassed_notification_service
67 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 69 else
70 70 flash[:error] = I18n.t('controllers.apps.flash.update.error')
71 71 render :edit
... ... @@ -78,7 +78,7 @@ class AppsController &lt; ApplicationController
78 78  
79 79 def destroy
80 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 82 else
83 83 flash[:error] = I18n.t('controllers.apps.flash.destroy.error')
84 84 render :show
... ...
app/controllers/comments_controller.rb
... ... @@ -3,7 +3,7 @@ class CommentsController &lt; ApplicationController
3 3 before_action :find_problem
4 4  
5 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 7 if @comment.valid?
8 8 @problem.comments << @comment
9 9 @problem.save
... ...
app/controllers/deploys_controller.rb
1 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 7 def create
8 8 @app = App.find_by_api_key!(params[:api_key])
9 9 @deploy = @app.deploys.create!(default_deploy || heroku_deploy)
10   - render :xml => @deploy
  10 + render xml: @deploy
11 11 end
12 12  
13 13 def index
... ... @@ -21,11 +21,11 @@ private
21 21 def default_deploy
22 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 30 end
31 31 end
... ... @@ -33,10 +33,10 @@ private
33 33 # handle Heroku's HTTP post deployhook format
34 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 41 end
42 42 end
... ...
app/controllers/notices_controller.rb
... ... @@ -4,7 +4,7 @@ class NoticesController &lt; ApplicationController
4 4 skip_before_action :authenticate_user!, only: :create
5 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 9 def create
10 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 13 if report.valid?
14 14 if report.should_keep?
15 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 18 end
19   - render :xml => api_xml
  19 + render xml: api_xml
20 20 else
21   - render :text => "Notice for old app version ignored"
  21 + render text: "Notice for old app version ignored"
22 22 end
23 23 else
24   - render :text => "Your API key is unknown", :status => 422
  24 + render text: "Your API key is unknown", status: 422
25 25 end
26 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 28 end
29 29  
30 30 # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem.
... ... @@ -45,6 +45,6 @@ private
45 45 end
46 46  
47 47 def bad_params(exception)
48   - render :text => exception.message, :status => :bad_request
  48 + render text: exception.message, status: :bad_request
49 49 end
50 50 end
... ...
app/controllers/problems_controller.rb
... ... @@ -7,12 +7,12 @@
7 7 class ProblemsController < ApplicationController
8 8 include ProblemsSearcher
9 9  
10   - before_action :need_selected_problem, :only => [
  10 + before_action :need_selected_problem, only: [
11 11 :resolve_several, :unresolve_several, :unmerge_several
12 12 ]
13 13  
14 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 18 expose(:app) {
... ... @@ -80,13 +80,13 @@ class ProblemsController &lt; ApplicationController
80 80  
81 81 def resolve_several
82 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 84 redirect_to :back
85 85 end
86 86  
87 87 def unresolve_several
88 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 90 redirect_to :back
91 91 end
92 92  
... ... @@ -100,26 +100,26 @@ class ProblemsController &lt; ApplicationController
100 100 flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge')
101 101 else
102 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 104 end
105 105 redirect_to :back
106 106 end
107 107  
108 108 def unmerge_several
109 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 111 redirect_to :back
112 112 end
113 113  
114 114 def destroy_several
115 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 117 redirect_to :back
118 118 end
119 119  
120 120 def destroy_all
121 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 123 redirect_to :back
124 124 rescue ActionController::RedirectBackError
125 125 redirect_to app_path(app)
... ...
app/controllers/users/omniauth_callbacks_controller.rb
... ... @@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
2 2 def github
3 3 github_login = env["omniauth.auth"].extra.raw_info.login
4 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 6 github_site_title = Errbit::Config.github_site_title
7 7  
8 8 if github_user.nil? && (github_org_id = Errbit::Config.github_org_id)
... ... @@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
31 31 elsif github_user
32 32 # Store OAuth token
33 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 36 else
37 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 38 redirect_to new_user_session_path
... ... @@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
41 41  
42 42 private def update_user_with_github_attributes(user, login, token)
43 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 47 end
48 48 end
... ...
app/controllers/users_controller.rb
1 1 class UsersController < ApplicationController
2 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 8 expose(:users) {
9 9 User.all.page(params[:page]).per(current_user.per_page)
10 10 }
... ... @@ -24,7 +24,7 @@ class UsersController &lt; ApplicationController
24 24  
25 25 def update
26 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 28 redirect_to user_path(user)
29 29 else
30 30 render :edit
... ... @@ -41,13 +41,13 @@ class UsersController &lt; ApplicationController
41 41 flash[:error] = I18n.t('controllers.users.flash.destroy.error')
42 42 else
43 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 45 end
46 46 redirect_to users_path
47 47 end
48 48  
49 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 51 redirect_to user_path(user)
52 52 end
53 53  
... ...
app/controllers/watchers_controller.rb
... ... @@ -6,7 +6,7 @@ class WatchersController &lt; ApplicationController
6 6 end
7 7  
8 8 def destroy
9   - watcher = app.watchers.where(:user_id => params[:id]).first
  9 + watcher = app.watchers.where(user_id: params[:id]).first
10 10 app.watchers.delete(watcher)
11 11 flash[:success] = t('.success', app: app.name)
12 12 redirect_to app_path(app)
... ...
app/decorators/app_decorator.rb
1 1 class AppDecorator < Draper::Decorator
2 2 decorates_association :watchers
3   - decorates_association :issue_tracker, :with => IssueTrackerDecorator
  3 + decorates_association :issue_tracker, with: IssueTrackerDecorator
4 4 delegate_all
5 5  
6 6 def email_at_notices
... ...
app/decorators/backtrace_line_decorator.rb
... ... @@ -67,25 +67,25 @@ private
67 67  
68 68 def link_to_hosted_javascript(app, text)
69 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 71 end
72 72 end
73 73  
74 74 def link_to_github(app, text = nil)
75 75 return unless app.github_repo?
76 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 78 end
79 79  
80 80 def link_to_bitbucket(app, text = nil)
81 81 return unless app.bitbucket_repo?
82 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 84 end
85 85  
86 86 def link_to_issue_tracker_file(app, text = nil)
87 87 return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file)
88 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 90 end
91 91 end
... ...
app/decorators/issue_tracker_field_decorator.rb
... ... @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator &lt; Draper::Decorator
13 13  
14 14 def input(form, issue_tracker)
15 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 18 end
19 19  
20 20 private def input_field
... ...
app/helpers/application_helper.rb
... ... @@ -13,7 +13,7 @@ module ApplicationHelper
13 13 event.dtend = notice.created_at.utc + 60.minutes
14 14 event.organizer = notice.server_environment && notice.server_environment["hostname"]
15 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 17 end
18 18 end
19 19 end.to_s
... ... @@ -58,7 +58,7 @@ module ApplicationHelper
58 58 percent = 100.0 / total.to_f
59 59 rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \
60 60 sort { |a, b| b[0] <=> a[0] }
61   - render "problems/tally_table", :rows => rows
  61 + render "problems/tally_table", rows: rows
62 62 end
63 63  
64 64 def head(collection)
... ...
app/helpers/apps_helper.rb
... ... @@ -2,11 +2,11 @@ module AppsHelper
2 2 def link_to_copy_attributes_from_other_app
3 3 if App.count > 1
4 4 html = link_to('copy settings from another app', '#',
5   - :class => 'button copy_config')
  5 + class: 'button copy_config')
6 6 html << select("duplicate", "app",
7 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 10 return html
11 11 end
12 12 end
... ...
app/helpers/form_helper.rb
... ... @@ -2,7 +2,7 @@ module FormHelper
2 2 def errors_for(document)
3 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 6 body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.')
7 7 body + content_tag(:ul) do
8 8 document.errors.full_messages.inject('') do |errs, msg|
... ...
app/helpers/notices_helper.rb
1 1 # encoding: utf-8
2 2 module NoticesHelper
3 3 def notice_atom_summary(notice)
4   - render "notices/atom_entry", :notice => notice
  4 + render "notices/atom_entry", notice: notice
5 5 end
6 6 end
... ...
app/helpers/problems_helper.rb
... ... @@ -6,21 +6,21 @@ module ProblemsHelper
6 6 def truncated_problem_message(problem)
7 7 unless (msg = problem.message).blank?
8 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 10 end
11 11 end
12 12  
13 13 def gravatar_tag(email, options = {})
14 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 17 end
18 18  
19 19 def gravatar_url(email, options = {})
20 20 return nil unless email.present?
21 21  
22 22 default_options = {
23   - :d => Errbit::Config.gravatar_default
  23 + d: Errbit::Config.gravatar_default
24 24 }
25 25 options.reverse_merge! default_options
26 26 params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? }
... ...
app/helpers/sort_helper.rb
... ... @@ -6,7 +6,7 @@ module SortHelper
6 6 order = (current && (params_order == "asc")) ? "desc" : "asc"
7 7 url = request.path + "?sort=#{field}&order=#{order}"
8 8 options = {}
9   - options.merge!(:class => "current #{order}") if current
  9 + options.merge!(class: "current #{order}") if current
10 10 link_to(name, url, options)
11 11 end
12 12 end
... ...
app/interactors/problem_destroy.rb
... ... @@ -36,11 +36,11 @@ private
36 36 end
37 37  
38 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 41 end
42 42  
43 43 def delete_comments
44   - Comment.delete_all(:_id => { '$in' => comments_id })
  44 + Comment.delete_all(_id: { '$in' => comments_id })
45 45 end
46 46 end
... ...
app/interactors/resolved_problem_clearer.rb
... ... @@ -26,6 +26,6 @@ private
26 26 end
27 27  
28 28 def repair_database
29   - Mongoid.default_client.command :repairDatabase => 1
  29 + Mongoid.default_client.command repairDatabase: 1
30 30 end
31 31 end
... ...
app/mailers/mailer.rb
... ... @@ -23,8 +23,8 @@ class Mailer &lt; ActionMailer::Base
23 23 'Environment' => @notice.environment_name,
24 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 28 end
29 29  
30 30 def deploy_notification(deploy)
... ... @@ -36,8 +36,8 @@ class Mailer &lt; ActionMailer::Base
36 36 'Deploy-Revision' => @deploy.revision,
37 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 41 end
42 42  
43 43 def comment_notification(comment)
... ... @@ -54,8 +54,8 @@ class Mailer &lt; ActionMailer::Base
54 54 'Problem-Id' => @problem.id,
55 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 59 end
60 60  
61 61 private def errbit_headers(header)
... ...
app/models/app.rb
... ... @@ -3,51 +3,54 @@ class App
3 3 include Mongoid::Document
4 4 include Mongoid::Timestamps
5 5  
6   - field :name, :type => String
  6 + field :name, type: String
7 7 field :api_key
8 8 field :github_repo
9 9 field :bitbucket_repo
10 10 field :asset_host
11 11 field :repository_branch
12 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 19 # Some legacy apps may have string as key instead of BSON::ObjectID
20 20 # identity :type => String
21 21 field :_id,
22   - type: String,
  22 + type: String,
23 23 pre_processed: true,
24   - default: -> { BSON::ObjectId.new.to_s }
  24 + default: -> { BSON::ObjectId.new.to_s }
25 25  
26 26 embeds_many :watchers
27 27 embeds_many :deploys
28   - embeds_one :issue_tracker, :class_name => 'IssueTracker'
  28 + embeds_one :issue_tracker, class_name: 'IssueTracker'
29 29 embeds_one :notification_service
30 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 35 before_save :normalize_github_repo
36 36 after_update :store_cached_attributes_on_problems
37 37  
38 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 41 validates_associated :watchers
42 42 validates_associated :notice_fingerprinter
43 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 54 accepts_nested_attributes_for :notice_fingerprinter
52 55  
53 56 scope :watched_by, ->(user) do
... ... @@ -71,7 +74,7 @@ class App
71 74 problem = problems.create!(
72 75 error_class: attrs[:error_class],
73 76 environment: attrs[:environment],
74   - app_name: name
  77 + app_name: name
75 78 )
76 79 problem.errs.create!(attrs.slice(:fingerprint, :problem_id))
77 80 end
... ... @@ -82,7 +85,7 @@ class App
82 85 end
83 86  
84 87 def self.find_by_api_key!(key)
85   - find_by(:api_key => key)
  88 + find_by(api_key: key)
86 89 end
87 90  
88 91 def last_deploy_at
... ... @@ -151,7 +154,7 @@ class App
151 154  
152 155 # Copy app attributes from another app.
153 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 158 # Copy fields
156 159 (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k|
157 160 send("#{k}=", copy_app.send(k))
... ... @@ -191,7 +194,7 @@ class App
191 194 protected
192 195  
193 196 def store_cached_attributes_on_problems
194   - Problem.where(:app_id => id).update_all(
  197 + Problem.where(app_id: id).update_all(
195 198 app_name: name
196 199 )
197 200 end
... ...
app/models/backtrace.rb
... ... @@ -8,7 +8,7 @@ class Backtrace
8 8 field :fingerprint
9 9 field :lines
10 10  
11   - index :fingerprint => 1
  11 + index fingerprint: 1
12 12  
13 13 def self.find_or_create(lines)
14 14 fingerprint = generate_fingerprint(lines)
... ...
app/models/comment.rb
... ... @@ -5,14 +5,14 @@ class Comment
5 5 after_create :increase_counter_cache
6 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 14 belongs_to :user
15   - delegate :app, :to => :err
  15 + delegate :app, to: :err
16 16  
17 17 validates_presence_of :body
18 18  
... ...
app/models/deploy.rb
... ... @@ -8,11 +8,11 @@ class Deploy
8 8 field :revision
9 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 16 after_create :store_cached_attributes_on_problems
17 17 after_create :deliver_email
18 18  
... ... @@ -33,7 +33,7 @@ protected
33 33 end
34 34  
35 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 37 last_deploy_at: created_at
38 38 )
39 39 end
... ...
app/models/err.rb
... ... @@ -12,9 +12,9 @@ class Err
12 12 index fingerprint: 1
13 13  
14 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 17 validates_presence_of :problem_id, :fingerprint
18 18  
19   - delegate :app, :resolved?, :to => :problem
  19 + delegate :app, :resolved?, to: :problem
20 20 end
... ...
app/models/error_report.rb
... ... @@ -61,15 +61,15 @@ class ErrorReport
61 61  
62 62 def make_notice
63 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 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 74 end
75 75  
... ...
app/models/issue_tracker.rb
... ... @@ -2,10 +2,10 @@ class IssueTracker
2 2 include Mongoid::Document
3 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 10 validate :validate_tracker
11 11  
... ... @@ -15,7 +15,7 @@ class IssueTracker
15 15 klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker
16 16 # TODO: we need to find out a better way to pass those config to the issue tracker
17 17 klass.new(options.merge(
18   - github_repo: app.try(:github_repo),
  18 + github_repo: app.try(:github_repo),
19 19 bitbucket_repo: app.try(:bitbucket_repo)
20 20 ))
21 21 end
... ... @@ -32,7 +32,7 @@ class IssueTracker
32 32 end
33 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 38 end
... ...
app/models/notice.rb
... ... @@ -5,21 +5,21 @@ class Notice
5 5 include Mongoid::Timestamps
6 6  
7 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 12 field :framework
13 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 17 belongs_to :app
18 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 24 before_save :sanitize
25 25 before_destroy :problem_recache
... ...
app/models/notification_service.rb
... ... @@ -5,22 +5,22 @@ class NotificationService
5 5 default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
6 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 18 validate :check_params
19 19  
20 20 if Errbit::Config.per_app_notify_at_notices
21 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 26 else
... ...
app/models/notification_services/campfire_service.rb
... ... @@ -3,16 +3,16 @@ if defined? Campy
3 3 LABEL = "campfire"
4 4 FIELDS += [
5 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 9 [:api_token, {
10   - :label => "API Token",
11   - :placeholder => "123456789abcdef123456789abcdef"
  10 + label: "API Token",
  11 + placeholder: "123456789abcdef123456789abcdef"
12 12 }],
13 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 28  
29 29 def create_notification(problem)
30 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 32 # post the issue to the campfire room
33 33 campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}"
34 34 end
... ...
app/models/notification_services/flowdock_service.rb
... ... @@ -4,8 +4,8 @@ if defined? Flowdock
4 4 FIELDS += [
5 5 [
6 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 21 end
22 22  
23 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 25 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}"
26 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 28 end
29 29  
30 30 private
... ...
app/models/notification_services/gtalk_service.rb
... ... @@ -2,28 +2,28 @@ class NotificationServices::GtalkService &lt; NotificationService
2 2 LABEL = "gtalk"
3 3 FIELDS += [
4 4 [:subdomain, {
5   - :placeholder => "username@example.com",
6   - :label => "Username"
  5 + placeholder: "username@example.com",
  6 + label: "Username"
7 7 }],
8 8 [:api_token, {
9   - :placeholder => "password",
10   - :label => "Password"
  9 + placeholder: "password",
  10 + label: "Password"
11 11 }],
12 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 15 }, :room_id],
16 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 19 }, :user_id],
20 20 [:service, {
21   - :placeholder => "talk.google.com",
22   - :label => "Jabber Service"
  21 + placeholder: "talk.google.com",
  22 + label: "Jabber Service"
23 23 }],
24 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 3 LABEL = 'hipchat'
4 4 FIELDS += [
5 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 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 13 [:api_token, {
14   - :placeholder => "API token",
15   - :label => "API token"
  14 + placeholder: "API token",
  15 + label: "API token"
16 16 }],
17 17 [:room_id, {
18   - :placeholder => "Room name",
19   - :label => "Room name"
  18 + placeholder: "Room name",
  19 + label: "Room name"
20 20 }]
21 21 ]
22 22 MANDATORY_FIELDS = [:service, :api_token, :room_id]
... ... @@ -45,11 +45,11 @@ if defined? HipChat
45 45 &nbsp;&nbsp;Times occurred: #{problem.notices_count}
46 46 MSG
47 47  
48   - options = { :api_version => self[:service] }
  48 + options = { api_version: self[:service] }
49 49 options[:server_url] = self[:service_url] if service_url.present?
50 50  
51 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 53 end
54 54 end
55 55 end
... ...
app/models/notification_services/hoiio_service.rb
... ... @@ -2,16 +2,16 @@ class NotificationServices::HoiioService &lt; NotificationService
2 2 LABEL = "hoiio"
3 3 FIELDS += [
4 4 [:api_token, {
5   - :placeholder => "App ID",
6   - :label => "App ID"
  5 + placeholder: "App ID",
  6 + label: "App ID"
7 7 }],
8 8 [:subdomain, {
9   - :placeholder => "Access Token",
10   - :label => "Access Token"
  9 + placeholder: "Access Token",
  10 + label: "Access Token"
11 11 }],
12 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 35  
36 36 # send sms
37 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 39 end
40 40 end
41 41 end
... ...
app/models/notification_services/hubot_service.rb
... ... @@ -2,12 +2,12 @@ class NotificationServices::HubotService &lt; NotificationService
2 2 LABEL = "hubot"
3 3 FIELDS += [
4 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 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 26 end
27 27  
28 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 30 end
31 31 end
... ...
app/models/notification_services/pushover_service.rb
... ... @@ -2,12 +2,12 @@ class NotificationServices::PushoverService &lt; NotificationService
2 2 LABEL = "pushover"
3 3 FIELDS += [
4 4 [:api_token, {
5   - :placeholder => "User Key",
6   - :label => "User Key"
  5 + placeholder: "User Key",
  6 + label: "User Key"
7 7 }],
8 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 26 notification = Rushover::Client.new(subdomain)
27 27  
28 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 30 end
31 31 end
... ...
app/models/notification_services/slack_service.rb
... ... @@ -2,8 +2,8 @@ class NotificationServices::SlackService &lt; NotificationService
2 2 LABEL = "slack"
3 3 FIELDS += [
4 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 19  
20 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 62 end
63 63  
64 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 66 end
67 67  
68 68 def configured?
... ...
app/models/notification_services/webhook_service.rb
... ... @@ -2,8 +2,8 @@ class NotificationServices::WebhookService &lt; NotificationService
2 2 LABEL = "webhook"
3 3 FIELDS = [
4 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 14 end
15 15  
16 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 18 end
19 19  
20 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 22 end
23 23 end
... ...
app/models/problem.rb
... ... @@ -7,59 +7,59 @@ class Problem
7 7 include Mongoid::Timestamps
8 8  
9 9 CACHED_NOTICE_ATTRIBUTES = {
10   - messages: :message,
11   - hosts: :host,
  10 + messages: :message,
  11 + hosts: :host,
12 12 user_agents: :user_agent_string
13 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 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 26 field :message
27 27 field :environment
28 28 field :error_class
29 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 44 index({
45 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 49 environment: "text"
50 50 }, default_language: "english")
51 51  
52 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 56 validates_presence_of :environment
57 57  
58 58 before_create :cache_app_attributes
59 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 63 scope :ordered, -> { order_by(:last_notice_at.desc) }
64 64 scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) }
65 65  
... ... @@ -69,12 +69,12 @@ class Problem
69 69 if fetch_all
70 70 all
71 71 else
72   - where(:resolved => false)
  72 + where(resolved: false)
73 73 end
74 74 end
75 75  
76 76 def self.in_env(env)
77   - env.present? ? where(:environment => env) : scoped
  77 + env.present? ? where(environment: env) : scoped
78 78 end
79 79  
80 80 def self.cache_notice(id, notice)
... ... @@ -164,8 +164,8 @@ class Problem
164 164 Rails.application.routes.url_helpers.app_problem_url(
165 165 app,
166 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 170 end
171 171  
... ... @@ -174,11 +174,11 @@ class Problem
174 174 end
175 175  
176 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 178 end
179 179  
180 180 def unresolve!
181   - self.update_attributes!(:resolved => false, :resolved_at => nil)
  181 + self.update_attributes!(resolved: false, resolved_at: nil)
182 182 end
183 183  
184 184 def unresolved?
... ... @@ -194,7 +194,7 @@ class Problem
194 194 end
195 195  
196 196 def unmerge!
197   - attrs = { :error_class => error_class, :environment => environment }
  197 + attrs = { error_class: error_class, environment: environment }
198 198 problem_errs = errs.to_a
199 199  
200 200 # associate and return all the problems
... ...
app/models/user.rb
... ... @@ -9,37 +9,37 @@ class User
9 9 field :github_login
10 10 field :github_oauth_token
11 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 16 ## Devise field
17 17 ### Database Authenticatable
18   - field :encrypted_password, :type => String
  18 + field :encrypted_password, type: String
19 19  
20 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 24 ### Rememberable
25   - field :remember_created_at, :type => Time
  25 + field :remember_created_at, type: Time
26 26  
27 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 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 39 before_save :ensure_authentication_token
40 40  
41 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 44 if Errbit::Config.user_has_username
45 45 field :username
... ...
app/models/watcher.rb
... ... @@ -4,7 +4,7 @@ class Watcher
4 4  
5 5 field :email
6 6  
7   - embedded_in :app, :inverse_of => :watchers
  7 + embedded_in :app, inverse_of: :watchers
8 8 belongs_to :user
9 9  
10 10 validate :ensure_user_or_email
... ...
config/application.rb
... ... @@ -39,7 +39,7 @@ module Errbit
39 39 config.generators do |g|
40 40 g.orm :mongoid
41 41 g.template_engine :haml
42   - g.test_framework :rspec, :fixture => false
  42 + g.test_framework :rspec, fixture: false
43 43 g.fixture_replacement :fabrication
44 44 end
45 45  
... ...
config/initializers/action_mailer.rb
... ... @@ -2,12 +2,12 @@
2 2 if Errbit::Config.email_delivery_method == :smtp
3 3 ActionMailer::Base.delivery_method = :smtp
4 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 12 end
13 13  
... ... @@ -23,8 +23,8 @@ end
23 23 # Set config specific values
24 24 (ActionMailer::Base.default_url_options ||= {}).tap do |default|
25 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 28 protocol: Errbit::Config.protocol
29 29 }.select { |_k, v| v }
30 30  
... ...
config/initializers/devise.rb
... ... @@ -237,12 +237,12 @@ Devise.setup do |config|
237 237  
238 238 if Errbit::Config.github_authentication || Rails.env.test?
239 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 1 # Enforce SSL connections, if configured
2 2 if Errbit::Config.enforce_ssl
3 3 require 'rack/ssl-enforcer'
4   - ActionMailer::Base.default_url_options.merge!(:protocol => 'https://')
  4 + ActionMailer::Base.default_url_options.merge!(protocol: 'https://')
5 5 Rails.application.configure do
6   - config.middleware.use Rack::SslEnforcer, :except => %r{^/deploys}
  6 + config.middleware.use Rack::SslEnforcer, except: %r{^/deploys}
7 7 end
8 8 end
... ...
config/routes.rb
1 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 4 # Hoptoad Notifier Routes
5 5 match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post]
6 6 get '/locate/:id' => 'notices#locate', :as => :locate
7 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 11 resources :users do
12 12 member do
13 13 delete :unlink_github
14 14 end
15 15 end
16 16  
17   - resources :site_config, :only => [:index] do
  17 + resources :site_config, only: [:index] do
18 18 collection do
19 19 put :update
20 20 end
21 21 end
22 22  
23   - resources :problems, :only => [:index] do
  23 + resources :problems, only: [:index] do
24 24 collection do
25 25 post :destroy_several
26 26 post :resolve_several
... ... @@ -34,7 +34,7 @@ Rails.application.routes.draw do
34 34 resources :apps do
35 35 resources :problems do
36 36 resources :notices
37   - resources :comments, :only => [:create, :destroy]
  37 + resources :comments, only: [:create, :destroy]
38 38  
39 39 collection do
40 40 post :destroy_all
... ... @@ -47,8 +47,8 @@ Rails.application.routes.draw do
47 47 delete :unlink_issue
48 48 end
49 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 52 member do
53 53 post :regenerate_api_key
54 54 end
... ... @@ -56,9 +56,9 @@ Rails.application.routes.draw do
56 56  
57 57 namespace :api do
58 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 62 collection do
63 63 get :app
64 64 end
... ... @@ -69,5 +69,5 @@ Rails.application.routes.draw do
69 69 match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post]
70 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 73 end
... ...
db/migrate/201510290041_extract_issue_tracker.rb
... ... @@ -35,7 +35,7 @@ class ExtractIssueTracker &lt; Mongoid::Migration
35 35 }
36 36  
37 37 App.where({ _id: app.id }).update({
38   - "$set" => { :issue_tracker => tracker }
  38 + "$set" => { issue_tracker: tracker }
39 39 })
40 40 end
41 41 end
... ...
db/seeds.rb
... ... @@ -15,7 +15,7 @@ puts &quot;-- password: #{admin_pass}&quot;
15 15 puts ""
16 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 20 user.name = 'Errbit Admin'
21 21 user.password = admin_pass
... ...
lib/airbrake_api/v3/notice_parser.rb
... ... @@ -11,14 +11,14 @@ module AirbrakeApi
11 11  
12 12 def report
13 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 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 24 ErrorReport.new(attributes)
... ... @@ -35,7 +35,7 @@ module AirbrakeApi
35 35 (error['backtrace'] || []).map do |backtrace_line|
36 36 {
37 37 method: backtrace_line['function'],
38   - file: backtrace_line['file'],
  38 + file: backtrace_line['file'],
39 39 number: backtrace_line['line'],
40 40 column: backtrace_line['column']
41 41 }
... ...
lib/hoptoad/v2.rb
... ... @@ -53,18 +53,18 @@ module Hoptoad
53 53  
54 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 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 69 end
70 70 end
... ...
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
... ... @@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do
7 7 private def send_notice(notice)
8 8 # Log the error internally if we are not in a development environment.
9 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 11 app.github_repo = "errbit/errbit"
12 12 app.save!
13 13 notice.send("api_key=", app.api_key)
... ...
lib/tasks/errbit/database.rake
1 1 namespace :errbit do
2 2 desc "Updates cached attributes on Problem"
3   - task :problem_recache => :environment do
  3 + task problem_recache: :environment do
4 4 ProblemRecacher.run
5 5 end
6 6  
7 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 9 require 'resolved_problem_clearer'
10 10 puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database."
11 11 end
12 12  
13 13 desc "Regenerate fingerprints"
14   - task :notice_refingerprint => :environment do
  14 + task notice_refingerprint: :environment do
15 15 NoticeRefingerprinter.run
16 16 ProblemRecacher.run
17 17 end
... ...
lib/tasks/errbit/demo.rake
1 1 namespace :errbit do
2 2 desc "Add a demo app & errors to your database (for testing)"
3   - task :demo => :environment do
  3 + task demo: :environment do
4 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 8 # Report a number of errors for the application
9 9 app.problems.delete_all
10 10  
11 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 31 RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8]
... ... @@ -44,28 +44,28 @@ namespace :errbit do
44 44 errors.each do |error_template|
45 45 rand(34).times do
46 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 52 'component' => 'main',
53 53 'action' => 'error',
54 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 64 })).generate_notice!
65 65 end
66 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 69 puts "=== Created demo app: '#{app.name}', with example errors."
70 70 end
71 71 end
... ...
lib/tasks/heroku/cron.rake
1 1 desc "This task is called by the Heroku cron add-on"
2   -task :cron => :environment do
  2 +task cron: :environment do
3 3 Rake::Task["errbit:db:clear_resolved"].invoke
4 4 end
... ...
spec/acceptance/acceptance_helper.rb
... ... @@ -22,7 +22,7 @@ end
22 22  
23 23 def log_in(user)
24 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 27 click_on I18n.t('devise.sessions.new.sign_in')
28 28 end
... ...
spec/acceptance/app_regenerate_api_key_spec.rb
... ... @@ -4,7 +4,7 @@ feature &quot;Regeneration api_Key&quot; do
4 4 let(:app) { Fabricate(:app) }
5 5 let(:admin) { Fabricate(:admin) }
6 6 let(:user) {
7   - Fabricate(:user_watcher, :app => app).user
  7 + Fabricate(:user_watcher, app: app).user
8 8 }
9 9  
10 10 before do
... ... @@ -37,7 +37,7 @@ end
37 37 feature "Create an application" do
38 38 let(:admin) { Fabricate(:admin) }
39 39 let(:user) {
40   - Fabricate(:user_watcher, :app => app).user
  40 + Fabricate(:user_watcher, app: app).user
41 41 }
42 42  
43 43 before do
... ... @@ -48,37 +48,37 @@ feature &quot;Create an application&quot; do
48 48 visit '/'
49 49 log_in admin
50 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 52 click_on I18n.t('apps.new.add_app')
53 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 57 click_on I18n.t('shared.navigation.apps')
58 58 click_on 'My new app'
59 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 61 click_on I18n.t('apps.edit.update')
62 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 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 68 visit '/'
69 69 log_in admin
70 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 72 find('.label_radio.github').click
73 73  
74 74 fill_in 'app_github_repo', with: 'foo/bar'
75 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 78 end
79 79 click_on I18n.t('apps.new.add_app')
80 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 82 expect(app.issue_tracker.type_tracker).to eql 'github'
83 83 expect(app.issue_tracker.options['username']).to eql 'token'
84 84 expect(app.issue_tracker.options['password']).to eql 'pass'
... ... @@ -89,7 +89,7 @@ feature &quot;Create an application&quot; do
89 89 find('.issue_tracker .label_radio.none').click
90 90 click_on I18n.t('apps.edit.update')
91 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 93 expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker
94 94 end
95 95 end
... ...
spec/acceptance/sign_in_with_github_spec.rb
... ... @@ -3,7 +3,7 @@ require &#39;acceptance/acceptance_helper&#39;
3 3 feature 'Sign in with GitHub' do
4 4 background do
5 5 allow(Errbit::Config).to receive(:github_authentication).and_return(true)
6   - Fabricate(:user, :github_login => 'nashby')
  6 + Fabricate(:user, github_login: 'nashby')
7 7 end
8 8  
9 9 scenario 'log in via GitHub with recognized user' do
... ... @@ -11,7 +11,7 @@ feature &#39;Sign in with GitHub&#39; do
11 11  
12 12 visit '/'
13 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 15 end
16 16  
17 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 6  
7 7 describe "GET /api/v1/notices" do
8 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 13 end
14 14  
15 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 17 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
18 18 end
19 19  
20 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 22 expect(Nokogiri::XML(response.body).errors).to be_empty
23 23 end
24 24  
25 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 27 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
28 28 end
29 29  
30 30 describe "given a date range" do
31 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 33 expect(response).to be_success
34 34 notices = JSON.load response.body
35 35 expect(notices.length).to eq 3
... ... @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do
37 37 end
38 38  
39 39 it "should return all notices" do
40   - get :index, { :auth_token => @user.authentication_token }
  40 + get :index, { auth_token: @user.authentication_token }
41 41 expect(response).to be_success
42 42 notices = JSON.load response.body
43 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 7 describe "GET /api/v1/problems/:id" do
8 8 before do
9 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 12 end
13 13  
14 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 16 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError
17 17 end
18 18  
19 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 21 expect(Nokogiri::XML(response.body).errors).to be_empty
22 22 end
23 23  
24 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 26 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
27 27 end
28 28  
29 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 32 returned_problem = JSON.parse(response.body)
33 33 expect(returned_problem["_id"]).to eq(@problem.id.to_s)
34 34 end
35 35  
36 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 38 returned_problem = JSON.parse(response.body)
39 39  
40 40 expect(returned_problem.keys).to match_array(%w(
... ... @@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
52 52 end
53 53  
54 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 56 expect(response.status).to eq(404)
57 57 end
58 58 end
59 59  
60 60 describe "GET /api/v1/problems" do
61 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 66 end
67 67  
68 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 70 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
71 71 end
72 72  
73 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 75 expect(Nokogiri::XML(response.body).errors).to be_empty
76 76 end
77 77  
78 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 80 expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError)
81 81 end
82 82  
83 83 describe "given a date range" do
84 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 86 expect(response).to be_success
87 87 problems = JSON.load response.body
88 88 expect(problems.length).to eq 2
... ... @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
90 90 end
91 91  
92 92 it "should return all problems" do
93   - get :index, { :auth_token => @user.authentication_token }
  93 + get :index, { auth_token: @user.authentication_token }
94 94 expect(response).to be_success
95 95 problems = JSON.load response.body
96 96 expect(problems.length).to eq 4
... ...
spec/controllers/apps_controller_spec.rb
1 1 describe AppsController, type: 'controller' do
2 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 5 let(:admin) { Fabricate(:admin) }
6 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 8 let(:unwatched_app) { Fabricate(:app) }
9 9 let(:app) { unwatched_app }
10 10 let(:watched_app1) do
11 11 a = Fabricate(:app)
12   - Fabricate(:user_watcher, :user => user, :app => a)
  12 + Fabricate(:user_watcher, user: user, app: a)
13 13 a
14 14 end
15 15 let(:watched_app2) do
16 16 a = Fabricate(:app)
17   - Fabricate(:user_watcher, :user => user, :app => a)
  17 + Fabricate(:user_watcher, user: user, app: a)
18 18 a
19 19 end
20 20 let(:err) do
21   - Fabricate(:err, :problem => problem)
  21 + Fabricate(:err, problem: problem)
22 22 end
23 23 let(:notice) do
24   - Fabricate(:notice, :err => err)
  24 + Fabricate(:notice, err: err)
25 25 end
26 26 let(:problem) do
27   - Fabricate(:problem, :app => app)
  27 + Fabricate(:problem, app: app)
28 28 end
29   - let(:problem_resolved) { Fabricate(:problem_resolved, :app => app) }
  29 + let(:problem_resolved) { Fabricate(:problem_resolved, app: app) }
30 30  
31 31 describe "GET /apps" do
32 32 context 'when logged in as an admin' do
... ... @@ -55,43 +55,43 @@ describe AppsController, type: &#39;controller&#39; do
55 55 end
56 56  
57 57 it 'finds the app' do
58   - get :show, :id => app.id
  58 + get :show, id: app.id
59 59 expect(controller.app).to eq app
60 60 end
61 61  
62 62 it "should not raise errors for app with err without notices" do
63 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 65 end
66 66  
67 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 69 expect(response).to be_success
70 70 end
71 71  
72 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 79 expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name))
80 80 end
81 81  
82 82 context "pagination" do
83 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 85 end
86 86  
87 87 it "should have default per_page value for user" do
88   - get :show, :id => app.id
  88 + get :show, id: app.id
89 89 expect(controller.problems.to_a.size).to eq User::PER_PAGE
90 90 end
91 91  
92 92 it "should be able to override default per_page value" do
93 93 admin.update_attribute :per_page, 10
94   - get :show, :id => app.id
  94 + get :show, id: app.id
95 95 expect(controller.problems.to_a.size).to eq 10
96 96 end
97 97 end
... ... @@ -103,14 +103,14 @@ describe AppsController, type: &#39;controller&#39; do
103 103  
104 104 context 'and no params' do
105 105 it 'shows only unresolved problems' do
106   - get :show, :id => app.id
  106 + get :show, id: app.id
107 107 expect(controller.problems.size).to eq 1
108 108 end
109 109 end
110 110  
111 111 context 'and all_problems=true params' do
112 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 114 expect(controller.problems.size).to eq 2
115 115 end
116 116 end
... ... @@ -120,41 +120,41 @@ describe AppsController, type: &#39;controller&#39; do
120 120 before(:each) do
121 121 environments = %w(production test development staging)
122 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 124 end
125 125 end
126 126  
127 127 context 'no params' do
128 128 it 'shows errs for all environments' do
129   - get :show, :id => app.id
  129 + get :show, id: app.id
130 130 expect(controller.problems.size).to eq 20
131 131 end
132 132 end
133 133  
134 134 context 'environment production' do
135 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 137 expect(controller.problems.size).to eq 5
138 138 end
139 139 end
140 140  
141 141 context 'environment staging' do
142 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 144 expect(controller.problems.size).to eq 5
145 145 end
146 146 end
147 147  
148 148 context 'environment development' do
149 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 151 expect(controller.problems.size).to eq 5
152 152 end
153 153 end
154 154  
155 155 context 'environment test' do
156 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 158 expect(controller.problems.size).to eq 5
159 159 end
160 160 end
... ... @@ -166,7 +166,7 @@ describe AppsController, type: &#39;controller&#39; do
166 166 sign_in Fabricate(:user)
167 167 app = Fabricate(:app)
168 168  
169   - get :show, :id => app.id
  169 + get :show, id: app.id
170 170 expect(controller.app).to eq app
171 171 end
172 172 end
... ... @@ -186,9 +186,9 @@ describe AppsController, type: &#39;controller&#39; do
186 186 end
187 187  
188 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 192 expect(controller.app).to be_a(App)
193 193 expect(controller.app).to be_new_record
194 194 expect(controller.app.name).to be_blank
... ... @@ -199,7 +199,7 @@ describe AppsController, type: &#39;controller&#39; do
199 199 describe "GET /apps/:id/edit" do
200 200 it 'finds the correct app' do
201 201 app = Fabricate(:app)
202   - get :edit, :id => app.id
  202 + get :edit, id: app.id
203 203 expect(controller.app).to eq app
204 204 end
205 205 end
... ... @@ -216,12 +216,12 @@ describe AppsController, type: &#39;controller&#39; do
216 216 end
217 217  
218 218 it "should redirect to the app page" do
219   - post :create, :app => {}
  219 + post :create, app: {}
220 220 expect(response).to redirect_to(app_path(@app))
221 221 end
222 222  
223 223 it "should display a message" do
224   - post :create, :app => {}
  224 + post :create, app: {}
225 225 expect(request.flash[:success]).to match(/success/)
226 226 end
227 227 end
... ... @@ -234,12 +234,12 @@ describe AppsController, type: &#39;controller&#39; do
234 234  
235 235 context "when the update is successful" do
236 236 it "should redirect to the app page" do
237   - put :update, :id => @app.id, :app => {}
  237 + put :update, id: @app.id, app: {}
238 238 expect(response).to redirect_to(app_path(@app))
239 239 end
240 240  
241 241 it "should display a message" do
242   - put :update, :id => @app.id, :app => {}
  242 + put :update, id: @app.id, app: {}
243 243 expect(request.flash[:success]).to match(/success/)
244 244 end
245 245 end
... ... @@ -247,14 +247,14 @@ describe AppsController, type: &#39;controller&#39; do
247 247 context "changing name" do
248 248 it "should redirect to app page" do
249 249 id = @app.id
250   - put :update, :id => id, :app => { :name => "new name" }
  250 + put :update, id: id, app: { name: "new name" }
251 251 expect(response).to redirect_to(app_path(id))
252 252 end
253 253 end
254 254  
255 255 context "when the update is unsuccessful" do
256 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 258 expect(response).to render_template(:edit)
259 259 end
260 260 end
... ... @@ -265,30 +265,30 @@ describe AppsController, type: &#39;controller&#39; do
265 265 end
266 266  
267 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 269 @app.reload
270 270 expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10]
271 271 end
272 272 context "failed parsing of CSV" do
273 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 276 @app.reload
277 277 expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices
278 278 end
279 279  
280 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 282 expect(request.flash[:error]).to match(/Couldn't parse/)
283 283 end
284 284 end
285 285 end
286 286  
287   - context "setting up issue tracker", :cur => true do
  287 + context "setting up issue tracker", cur: true do
288 288 context "unknown tracker type" do
289 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 293 @app.reload
294 294 end
... ... @@ -306,24 +306,24 @@ describe AppsController, type: &#39;controller&#39; do
306 306 end
307 307  
308 308 it "should find the app" do
309   - delete :destroy, :id => @app.id
  309 + delete :destroy, id: @app.id
310 310 expect(controller.app).to eq @app
311 311 end
312 312  
313 313 it "should destroy the app" do
314   - delete :destroy, :id => @app.id
  314 + delete :destroy, id: @app.id
315 315 expect {
316 316 @app.reload
317 317 }.to raise_error(Mongoid::Errors::DocumentNotFound)
318 318 end
319 319  
320 320 it "should display a message" do
321   - delete :destroy, :id => @app.id
  321 + delete :destroy, id: @app.id
322 322 expect(request.flash[:success]).to match(/success/)
323 323 end
324 324  
325 325 it "should redirect to the apps page" do
326   - delete :destroy, :id => @app.id
  326 + delete :destroy, id: @app.id
327 327 expect(response).to redirect_to(apps_path)
328 328 end
329 329 end
... ... @@ -336,7 +336,7 @@ describe AppsController, type: &#39;controller&#39; do
336 336 end
337 337  
338 338 it 'redirect to root with flash error' do
339   - post :regenerate_api_key, :id => 'foo'
  339 + post :regenerate_api_key, id: 'foo'
340 340 expect(request).to redirect_to root_path
341 341 end
342 342 end
... ... @@ -348,7 +348,7 @@ describe AppsController, type: &#39;controller&#39; do
348 348  
349 349 it 'redirect_to app view' do
350 350 expect do
351   - post :regenerate_api_key, :id => app.id
  351 + post :regenerate_api_key, id: app.id
352 352 expect(request).to redirect_to edit_app_path(app)
353 353 end.to change { app.reload.api_key }
354 354 end
... ...
spec/controllers/comments_controller_spec.rb
1 1 describe CommentsController, type: 'controller' do
2 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 5 describe "POST /apps/:app_id/errs/:id/comments/create" do
6 6 render_views
... ... @@ -14,8 +14,8 @@ describe CommentsController, type: &#39;controller&#39; do
14 14 let(:user) { Fabricate(:user) }
15 15  
16 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 19 problem.reload
20 20 end
21 21  
... ... @@ -41,7 +41,7 @@ describe CommentsController, type: &#39;controller&#39; do
41 41 let(:comment) { problem.reload.comments.first }
42 42  
43 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 45 problem.reload
46 46 end
47 47  
... ...
spec/controllers/deploys_controller_spec.rb
... ... @@ -10,30 +10,30 @@ describe DeploysController, type: &#39;controller&#39; do
10 10 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5',
11 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 14 end
15 15  
16 16 it 'finds the app via the api key' do
17 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 19 end
20 20  
21 21 it 'creates a deploy' do
22 22 expect(App).to receive(:find_by_api_key!).and_return(@app)
23 23 expect(@app.deploys).to receive(:create!).
24 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 31 }).and_return(Fabricate(:deploy))
32   - post :create, :deploy => @params, :api_key => 'APIKEY'
  32 + post :create, deploy: @params, api_key: 'APIKEY'
33 33 end
34 34  
35 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 37 email = ActionMailer::Base.deliveries.last
38 38 expect(email.to).to include(@app.watchers.first.email)
39 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 44 before(:each) do
45 45 @deploy = Fabricate :deploy
46 46 sign_in Fabricate(:admin)
47   - get :index, :app_id => @deploy.app.id
  47 + get :index, app_id: @deploy.app.id
48 48 end
49 49  
50 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 10 let(:user) { Fabricate(:user) }
11 11  
12 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 14 expect(response).to redirect_to(root_path)
15 15 end
16 16  
17 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 19 expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid')
20 20 end
21 21 end
... ...
spec/controllers/notices_controller_spec.rb
1 1 describe NoticesController, type: 'controller' do
2   - it_requires_authentication :for => { :locate => :get }
  2 + it_requires_authentication for: { locate: :get }
3 3  
4 4 let(:notice) { Fabricate(:notice) }
5 5 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read }
6 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 9 context 'notices API' do
10 10 context "with bogus xml" do
11 11 it "returns an error" do
12 12 expect(request).to receive(:raw_post).and_return('<r><b>notxml</r>')
13   - post :create, :format => :xml
  13 + post :create, format: :xml
14 14 expect(response.status).to eq(422)
15 15 expect(response.body).to eq('The provided XML was not well-formed')
16 16 end
... ... @@ -24,7 +24,7 @@ describe NoticesController, type: &#39;controller&#39; do
24 24 context "with xml pass in raw_port" do
25 25 before do
26 26 expect(request).to receive(:raw_post).and_return(xml)
27   - post :create, :format => :xml
  27 + post :create, format: :xml
28 28 end
29 29  
30 30 it "generates a notice from raw xml [POST]" do
... ... @@ -37,7 +37,7 @@ describe NoticesController, type: &#39;controller&#39; do
37 37 end
38 38  
39 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 41 expect(response).to be_success
42 42 # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53)
43 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 46 end
47 47  
48 48 it "generates a notice from xml [GET]" do
49   - get :create, :data => xml, :format => :xml
  49 + get :create, data: xml, format: :xml
50 50 expect(response).to be_success
51 51 expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>})
52 52 expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>})
53 53 end
54 54 context "with an invalid API_KEY" do
55   - let(:error_report) { double(:valid? => false) }
  55 + let(:error_report) { double(valid?: false) }
56 56 it 'return 422' do
57   - post :create, :format => :xml, :data => xml
  57 + post :create, format: :xml, data: xml
58 58 expect(response.status).to eq 422
59 59 end
60 60 end
... ... @@ -62,7 +62,7 @@ describe NoticesController, type: &#39;controller&#39; do
62 62  
63 63 context "without params needed" do
64 64 it 'return 400' do
65   - post :create, :format => :xml
  65 + post :create, format: :xml
66 66 expect(response.status).to eq 400
67 67 expect(response.body).to eq 'Need a data params in GET or raw post data'
68 68 end
... ... @@ -77,9 +77,9 @@ describe NoticesController, type: &#39;controller&#39; do
77 77 end
78 78  
79 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 83 expect(response).to redirect_to(app_problem_path(problem.app, problem))
84 84 end
85 85 end
... ...
spec/controllers/problems_controller_spec.rb
1 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 7 let(:app) { Fabricate(:app) }
8   - let(:err) { Fabricate(:err, :problem => problem) }
  8 + let(:err) { Fabricate(:err, problem: problem) }
9 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 12 describe "GET /problems" do
13 13 before(:each) do
14 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 16 end
17 17  
18 18 context "pagination" do
... ... @@ -36,7 +36,7 @@ describe ProblemsController, type: &#39;controller&#39; do
36 36 before(:each) do
37 37 environments = %w(production test development staging)
38 38 20.times do |i|
39   - Fabricate(:problem, :environment => environments[i % environments.length])
  39 + Fabricate(:problem, environment: environments[i % environments.length])
40 40 end
41 41 end
42 42  
... ... @@ -49,28 +49,28 @@ describe ProblemsController, type: &#39;controller&#39; do
49 49  
50 50 context 'environment production' do
51 51 it 'shows problems for just production' do
52   - get :index, :environment => 'production'
  52 + get :index, environment: 'production'
53 53 expect(controller.problems.size).to eq 6
54 54 end
55 55 end
56 56  
57 57 context 'environment staging' do
58 58 it 'shows problems for just staging' do
59   - get :index, :environment => 'staging'
  59 + get :index, environment: 'staging'
60 60 expect(controller.problems.size).to eq 5
61 61 end
62 62 end
63 63  
64 64 context 'environment development' do
65 65 it 'shows problems for just development' do
66   - get :index, :environment => 'development'
  66 + get :index, environment: 'development'
67 67 expect(controller.problems.size).to eq 5
68 68 end
69 69 end
70 70  
71 71 context 'environment test' do
72 72 it 'shows problems for just test' do
73   - get :index, :environment => 'test'
  73 + get :index, environment: 'test'
74 74 expect(controller.problems.size).to eq 5
75 75 end
76 76 end
... ... @@ -82,11 +82,11 @@ describe ProblemsController, type: &#39;controller&#39; do
82 82 sign_in Fabricate(:user)
83 83 problems = Kaminari.paginate_array((1..30).to_a)
84 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 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 90 expect(controller.problems).to eq problems
91 91 end
92 92 end
... ... @@ -95,8 +95,8 @@ describe ProblemsController, type: &#39;controller&#39; do
95 95 before do
96 96 sign_in user
97 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 100 end
101 101  
102 102 it "renders successfully" do
... ... @@ -110,7 +110,7 @@ describe ProblemsController, type: &#39;controller&#39; do
110 110 end
111 111  
112 112 it "searches problems for given string" do
113   - get :search, :search => "\"Most important\""
  113 + get :search, search: "\"Most important\""
114 114 expect(controller.problems).to include(@problem1)
115 115 expect(controller.problems).to_not include(@problem2)
116 116 end
... ... @@ -122,35 +122,35 @@ describe ProblemsController, type: &#39;controller&#39; do
122 122 end
123 123  
124 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 126 expect(controller.app).to eq app
127 127 end
128 128  
129 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 131 expect(controller.problem).to eq err.problem
132 132 end
133 133  
134 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 136 expect(response).to be_success
137 137 end
138 138  
139 139 context 'pagination' do
140 140 let!(:notices) do
141 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 143 end
144 144 end
145 145  
146 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 148 expect(assigns(:notices).entries.count).to eq 1
149 149 expect(assigns(:notices)).to include(notices.last)
150 150 end
151 151  
152 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 154 expect(assigns(:notices).entries.count).to eq 1
155 155 expect(assigns(:notices)).to include(notices.first)
156 156 end
... ... @@ -165,29 +165,29 @@ describe ProblemsController, type: &#39;controller&#39; do
165 165 end
166 166  
167 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 169 expect(controller.app).to eq @err.app
170 170 expect(controller.problem).to eq @err.problem
171 171 end
172 172  
173 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 175 expect(@err.problem.reload.resolved).to be(true)
176 176 end
177 177  
178 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 180 expect(request.flash[:success]).to match(/Great news/)
181 181 end
182 182  
183 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 185 expect(response).to redirect_to(app_path(@err.app))
186 186 end
187 187  
188 188 it "should redirect back to problems page" do
189 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 191 expect(response).to redirect_to(problems_path)
192 192 end
193 193 end
... ... @@ -245,7 +245,7 @@ describe ProblemsController, type: &#39;controller&#39; do
245 245  
246 246 it "should render whatever the issue tracker says" do
247 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 249 post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html'
250 250 line = issue_tracker.tracker.output.shift
251 251 expect(line[1]).to eq("one #{problem.id} two")
... ... @@ -268,10 +268,10 @@ describe ProblemsController, type: &#39;controller&#39; do
268 268 end
269 269  
270 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 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 275 err.problem.reload
276 276 end
277 277  
... ... @@ -288,7 +288,7 @@ describe ProblemsController, type: &#39;controller&#39; do
288 288 let(:err) { Fabricate :err }
289 289  
290 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 292 err.problem.reload
293 293 end
294 294  
... ... @@ -301,25 +301,25 @@ describe ProblemsController, type: &#39;controller&#39; do
301 301 describe "Bulk Actions" do
302 302 before(:each) do
303 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 306 end
307 307  
308 308 context "POST /problems/merge_several" do
309 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 311 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge')
312 312 end
313 313  
314 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 317 end
318 318 end
319 319  
320 320 context "POST /problems/unmerge_several" do
321 321 it "should require at least one problem" do
322   - post :unmerge_several, :problems => []
  322 + post :unmerge_several, problems: []
323 323 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
324 324 end
325 325  
... ... @@ -327,7 +327,7 @@ describe ProblemsController, type: &#39;controller&#39; do
327 327 merged_problem = Problem.merge!(@problem1, @problem2)
328 328 expect(merged_problem.errs.length).to eq 2
329 329 expect {
330   - post :unmerge_several, :problems => [merged_problem.id.to_s]
  330 + post :unmerge_several, problems: [merged_problem.id.to_s]
331 331 expect(merged_problem.reload.errs.length).to eq 1
332 332 }.to change(Problem, :count).by(1)
333 333 end
... ... @@ -335,22 +335,22 @@ describe ProblemsController, type: &#39;controller&#39; do
335 335  
336 336 context "POST /problems/resolve_several" do
337 337 it "should require at least one problem" do
338   - post :resolve_several, :problems => []
  338 + post :resolve_several, problems: []
339 339 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
340 340 end
341 341  
342 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 344 expect(@problem2.reload.resolved?).to eq true
345 345 end
346 346  
347 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 349 expect(flash[:success]).to match(/1 error has been resolved/)
350 350 end
351 351  
352 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 354 expect(flash[:success]).to match(/2 errors have been resolved/)
355 355 expect(controller.selected_problems).to eq [@problem1, @problem2]
356 356 end
... ... @@ -358,12 +358,12 @@ describe ProblemsController, type: &#39;controller&#39; do
358 358  
359 359 context "POST /problems/unresolve_several" do
360 360 it "should require at least one problem" do
361   - post :unresolve_several, :problems => []
  361 + post :unresolve_several, problems: []
362 362 expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem')
363 363 end
364 364  
365 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 367 expect(@problem1.reload.resolved?).to eq false
368 368 end
369 369 end
... ... @@ -371,7 +371,7 @@ describe ProblemsController, type: &#39;controller&#39; do
371 371 context "POST /problems/destroy_several" do
372 372 it "should delete the problems" do
373 373 expect {
374   - post :destroy_several, :problems => [@problem1.id.to_s]
  374 + post :destroy_several, problems: [@problem1.id.to_s]
375 375 }.to change(Problem, :count).by(-1)
376 376 end
377 377 end
... ... @@ -380,25 +380,25 @@ describe ProblemsController, type: &#39;controller&#39; do
380 380 before do
381 381 sign_in user
382 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 385 end
386 386  
387 387 it "destroys all problems" do
388 388 expect {
389   - post :destroy_all, :app_id => @app.id
  389 + post :destroy_all, app_id: @app.id
390 390 }.to change(Problem, :count).by(-2)
391 391 expect(controller.app).to eq @app
392 392 end
393 393  
394 394 it "should display a message" do
395   - put :destroy_all, :app_id => @app.id
  395 + put :destroy_all, app_id: @app.id
396 396 expect(request.flash[:success]).to match(/been deleted/)
397 397 end
398 398  
399 399 it "should redirect back to the app page" do
400 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 402 expect(response).to redirect_to(edit_app_path(@app))
403 403 end
404 404 end
... ...
spec/controllers/site_config_controller_spec.rb
1 1 describe SiteConfigController, type: 'controller' do
2 2 it_requires_admin_privileges for: {
3   - index: :get,
  3 + index: :get,
4 4 update: :put
5 5 }
6 6  
... ... @@ -18,7 +18,7 @@ describe SiteConfigController, type: &#39;controller&#39; do
18 18 it 'updates' do
19 19 put :update, site_config: {
20 20 notice_fingerprinter_attributes: {
21   - backtrace_lines: 3,
  21 + backtrace_lines: 3,
22 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 4 request.env["devise.mapping"] = Devise.mappings[:user]
5 5 env = {
6 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 12 allow(@controller).to receive(:env).and_return(env)
... ... @@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do
18 18 end
19 19  
20 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 22 stub_env_for_github_omniauth("existing_user")
23 23 get :github
24 24  
... ...
spec/controllers/users_controller_spec.rb
1 1 describe UsersController, type: 'controller' do
2 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 11 let(:admin) { Fabricate(:admin) }
... ... @@ -23,14 +23,14 @@ describe UsersController, type: &#39;controller&#39; do
23 23  
24 24 context "GET /users/:other_id/edit" do
25 25 it "redirects to the home page" do
26   - get :edit, :id => other_user.id
  26 + get :edit, id: other_user.id
27 27 expect(response).to redirect_to(root_path)
28 28 end
29 29 end
30 30  
31 31 context "GET /users/:my_id/edit" do
32 32 it 'finds the user' do
33   - get :edit, :id => user.id
  33 + get :edit, id: user.id
34 34 expect(controller.user).to eq(user)
35 35 expect(response).to render_template 'edit'
36 36 end
... ... @@ -38,7 +38,7 @@ describe UsersController, type: &#39;controller&#39; do
38 38  
39 39 context "PUT /users/:other_id" do
40 40 it "redirects to the home page" do
41   - put :update, :id => other_user.id
  41 + put :update, id: other_user.id
42 42 expect(response).to redirect_to(root_path)
43 43 end
44 44 end
... ... @@ -46,47 +46,47 @@ describe UsersController, type: &#39;controller&#39; do
46 46 context "PUT /users/:my_id/id" do
47 47 context "when the update is successful" do
48 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 50 expect(request.flash[:success]).to include('updated')
51 51 end
52 52  
53 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 55 expect(response).to redirect_to(user_path(user))
56 56 end
57 57  
58 58 it "should not be able to become an admin" do
59 59 expect {
60   - put :update, :id => user.to_param, :user => { :admin => true }
  60 + put :update, id: user.to_param, user: { admin: true }
61 61 }.to_not change {
62 62 user.reload.admin
63 63 }.from(false)
64 64 end
65 65  
66 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 68 expect(user.reload.per_page).to eq 555
69 69 end
70 70  
71 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 73 expect(user.reload.time_zone).to eq "Warsaw"
74 74 end
75 75  
76 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 78 expect(user.reload.github_login).to eq nil
79 79 end
80 80  
81 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 83 expect(user.reload.github_login).to eq "awesome_name"
84 84 end
85 85 end
86 86  
87 87 context "when the update is unsuccessful" do
88 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 90 expect(response).to render_template(:edit)
91 91 end
92 92 end
... ... @@ -109,7 +109,7 @@ describe UsersController, type: &#39;controller&#39; do
109 109  
110 110 context "GET /users/:id" do
111 111 it 'finds the user' do
112   - get :show, :id => user.id
  112 + get :show, id: user.id
113 113 expect(controller.user).to eq user
114 114 end
115 115 end
... ... @@ -124,14 +124,14 @@ describe UsersController, type: &#39;controller&#39; do
124 124  
125 125 context "GET /users/:id/edit" do
126 126 it 'finds the user' do
127   - get :edit, :id => user.id
  127 + get :edit, id: user.id
128 128 expect(controller.user).to eq user
129 129 end
130 130 end
131 131  
132 132 context "POST /users" do
133 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 136 it "sets a message to display" do
137 137 post :create, attrs
... ... @@ -166,7 +166,7 @@ describe UsersController, type: &#39;controller&#39; do
166 166 end
167 167  
168 168 it "renders the new page" do
169   - post :create, :user => { :username => 'foo' }
  169 + post :create, user: { username: 'foo' }
170 170 expect(response).to render_template(:new)
171 171 end
172 172 end
... ... @@ -175,20 +175,20 @@ describe UsersController, type: &#39;controller&#39; do
175 175 context "PUT /users/:id" do
176 176 context "when the update is successful" do
177 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 181 context "with normal params" do
182   - let(:user_params) { { :name => 'Kermit' } }
  182 + let(:user_params) { { name: 'Kermit' } }
183 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 185 expect(response).to redirect_to(user_path(user))
186 186 end
187 187 end
188 188 end
189 189 context "when the update is unsuccessful" do
190 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 192 expect(response).to render_template(:edit)
193 193 end
194 194 end
... ... @@ -196,15 +196,15 @@ describe UsersController, type: &#39;controller&#39; do
196 196  
197 197 context "DELETE /users/:id" do
198 198 context "with a destroy success" do
199   - let(:user_destroy) { double(:destroy => true) }
  199 + let(:user_destroy) { double(destroy: true) }
200 200  
201 201 before {
202 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 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 208 expect(response).to redirect_to(users_path)
209 209 end
210 210 end
... ... @@ -212,7 +212,7 @@ describe UsersController, type: &#39;controller&#39; do
212 212 context "with trying destroy himself" do
213 213 before {
214 214 expect(UserDestroy).to_not receive(:new)
215   - delete :destroy, :id => admin.id
  215 + delete :destroy, id: admin.id
216 216 }
217 217  
218 218 it 'should not destroy user' do
... ... @@ -230,7 +230,7 @@ describe UsersController, type: &#39;controller&#39; do
230 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 234 it 'not have admin field' do
235 235 expect(controller.send(:user_params)).to eq({ 'name' => 'foo' })
236 236 end
... ...
spec/controllers/watchers_controller_spec.rb
... ... @@ -15,7 +15,7 @@ describe WatchersController, type: &#39;controller&#39; do
15 15 let(:watcher) { app.watchers.first }
16 16  
17 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 19 problem.reload
20 20 end
21 21  
... ... @@ -34,7 +34,7 @@ describe WatchersController, type: &#39;controller&#39; do
34 34  
35 35 context "successful watcher update" do
36 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 38 problem.reload
39 39 end
40 40  
... ...
spec/decorators/app_decorator_spec.rb
1 1 describe AppDecorator do
2 2 describe "#email_at_notices" do
3 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 5 end
6 6 end
7 7  
8 8 describe "#notify_user_display" do
9 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 11 end
12 12  
13 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 15 end
16 16 end
17 17  
18 18 describe "#notify_err_display" do
19 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 21 end
22 22  
23 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 25 end
26 26 end
27 27 end
... ...
spec/decorators/backtrace_decorator_spec.rb
... ... @@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do
3 3 described_class.new(Backtrace.new(
4 4 lines: [
5 5 { number: 131,
6   - file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb',
  6 + file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb',
7 7 method: :update_preferences },
8 8 { number: 61,
9   - file: '[PROJECT_ROOT]app/controllers/application_controller.rb',
  9 + file: '[PROJECT_ROOT]app/controllers/application_controller.rb',
10 10 method: :call },
11 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 13 method: :call },
14 14 { number: 384,
15   - file: '[PROJECT_ROOT]app/models/account.rb',
  15 + file: '[PROJECT_ROOT]app/models/account.rb',
16 16 method: :update_server_tag_scope },
17 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 19 method: :evaluate_method },
20 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 22 method: '<main>' }
23 23 ]
24 24 ))
... ...
spec/decorators/backtrace_line_decorator_spec.rb
... ... @@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do
2 2 let(:backtrace_line) do
3 3 described_class.new(
4 4 number: 884,
5   - file: '/path/to/file/ea315ea4.rb',
  5 + file: '/path/to/file/ea315ea4.rb',
6 6 method: :instance_eval)
7 7 end
8 8 let(:backtrace_line_in_app) do
9 9 described_class.new(
10 10 number: 884,
11   - file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
  11 + file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
12 12 method: :instance_eval)
13 13 end
14 14 let(:app) { Fabricate(:app, github_repo: 'foo/bar') }
... ...
spec/decorators/issue_tracker_decorator_spec.rb
... ... @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do
11 11  
12 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 17 end
18 18  
... ...
spec/decorators/issue_tracker_field_decorator.rb
1 1 describe IssueTrackerFieldDecorator do
2 2 describe "#label" do
3 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 5 end
6 6  
7 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 11  
12 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 17 end
18 18  
... ... @@ -45,7 +45,7 @@ describe IssueTrackerDecorator do
45 45 decorator.fields do |itf|
46 46 expect(itf).to be_a(IssueTrackerFieldDecorator)
47 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 49 end
50 50 end
51 51 end
... ...
spec/decorators/watcher_decorator_spec.rb
... ... @@ -2,13 +2,13 @@ describe WatcherDecorator do
2 2 describe "#email_choosen" do
3 3 context "with email define" do
4 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 6 end
7 7 end
8 8  
9 9 context "without email define" do
10 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 12 end
13 13 end
14 14 end
... ...
spec/errbit_plugin/mock_issue_tracker.rb
... ... @@ -10,8 +10,8 @@ module ErrbitPlugin
10 10  
11 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 16 end
17 17  
... ...
spec/fabricators/app_fabricator.rb
... ... @@ -3,9 +3,9 @@ Fabricator(:app) do
3 3 repository_branch 'master'
4 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 10 end
11 11  
... ... @@ -15,7 +15,7 @@ Fabricator(:watcher) do
15 15 email { sequence(:email) { |n| "email#{n}@example.com" } }
16 16 end
17 17  
18   -Fabricator(:user_watcher, :from => :watcher) do
  18 +Fabricator(:user_watcher, from: :watcher) do
19 19 user
20 20 watcher_type 'user'
21 21 end
... ...
spec/fabricators/backtrace_fabricator.rb
1 1 Fabricator :backtrace do
2   - lines(:count => 99) do
  2 + lines(count: 99) do
3 3 {
4 4 number: rand(999),
5   - file: "/path/to/file/#{SecureRandom.hex(4)}.rb",
  5 + file: "/path/to/file/#{SecureRandom.hex(4)}.rb",
6 6 method: ActiveSupport.methods.sample
7 7 }
8 8 end
... ...
spec/fabricators/comment_fabricator.rb
1 1 Fabricator :comment do
2 2 user
3 3 body 'Test comment'
4   - err(:fabricator => :problem)
  4 + err(fabricator: :problem)
5 5 end
... ...
spec/fabricators/issue_tracker_fabricator.rb
... ... @@ -2,8 +2,8 @@ Fabricator :issue_tracker do
2 2 type_tracker 'mock'
3 3 options {
4 4 {
5   - :foo => 'one',
6   - :bar => 'two'
  5 + foo: 'one',
  6 + bar: 'two'
7 7 }}
8 8 app
9 9 end
... ...
spec/fabricators/notification_service_fabricator.rb
... ... @@ -6,20 +6,20 @@ Fabricator :notification_service do
6 6 notify_at_notices { sequence { |_a| [0] } }
7 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 10 user_id { sequence :word }
11 11 service_url { sequence :word }
12 12 service { sequence :word }
13 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 16 service_url { sequence :word }
17 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 20 service { 'v2' }
21 21 end
22 22  
23 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 25 end
... ...
spec/fabricators/problem_fabricator.rb
... ... @@ -5,25 +5,25 @@ Fabricator(:problem) do
5 5 environment 'production'
6 6 end
7 7  
8   -Fabricator(:problem_with_comments, :from => :problem) do
  8 +Fabricator(:problem_with_comments, from: :problem) do
9 9 after_create { |parent|
10 10 3.times do
11   - Fabricate(:comment, :err => parent)
  11 + Fabricate(:comment, err: parent)
12 12 end
13 13 }
14 14 end
15 15  
16   -Fabricator(:problem_with_errs, :from => :problem) do
  16 +Fabricator(:problem_with_errs, from: :problem) do
17 17 after_create { |parent|
18 18 3.times do
19   - Fabricate(:err, :problem => parent)
  19 + Fabricate(:err, problem: parent)
20 20 end
21 21 }
22 22 end
23 23  
24   -Fabricator(:problem_resolved, :from => :problem) do
  24 +Fabricator(:problem_resolved, from: :problem) do
25 25 after_create do |pr|
26   - Fabricate(:notice, :err => Fabricate(:err, :problem => pr))
  26 + Fabricate(:notice, err: Fabricate(:err, problem: pr))
27 27 pr.resolve!
28 28 end
29 29 end
... ...
spec/fabricators/user_fabricator.rb
... ... @@ -5,6 +5,6 @@ Fabricator :user do
5 5 password_confirmation 'password'
6 6 end
7 7  
8   -Fabricator :admin, :from => :user do
  8 +Fabricator :admin, from: :user do
9 9 admin true
10 10 end
... ...
spec/helpers/problems_helper_spec.rb
1 1 describe ProblemsHelper do
2 2 describe '#truncated_problem_message' do
3 3 it 'is html safe' do
4   - problem = double('problem', :message => '#<NoMethodError: ...>')
  4 + problem = double('problem', message: '#<NoMethodError: ...>')
5 5 truncated = helper.truncated_problem_message(problem)
6 6 expect(truncated).to be_html_safe
7 7 expect(truncated).to_not include('<', '>')
8 8 end
9 9  
10 10 it 'does not double escape html' do
11   - problem = double('problem', :message => '#<NoMethodError: ...>')
  11 + problem = double('problem', message: '#<NoMethodError: ...>')
12 12 truncated = helper.truncated_problem_message(problem)
13 13 expect(truncated).to be_html_safe
14 14 expect(truncated).to_not include('&amp;')
... ... @@ -28,12 +28,12 @@ describe ProblemsHelper do
28 28  
29 29 it "should render image_tag with correct alt and src" do
30 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 32 end
33 33  
34 34 it "should override :d" do
35 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 37 end
38 38 end
39 39  
... ...
spec/initializers/action_mailer_spec.rb
... ... @@ -35,12 +35,12 @@ describe &#39;initializers/action_mailer&#39; do
35 35 load_initializer
36 36  
37 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 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 45 end
46 46 end
... ...
spec/initializers/devise_spec.rb
... ... @@ -15,9 +15,9 @@ describe &#39;initializers/devise&#39; do
15 15 options = Devise.omniauth_configs[:github].options
16 16 expect(options).to have_key(:client_options)
17 17 expect(options[:client_options]).to eq({
18   - site: 'https://api.github.com',
  18 + site: 'https://api.github.com',
19 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 22 end
23 23  
... ... @@ -29,9 +29,9 @@ describe &#39;initializers/devise&#39; do
29 29 options = Devise.omniauth_configs[:github].options
30 30 expect(options).to have_key(:client_options)
31 31 expect(options[:client_options]).to eq({
32   - site: 'https://github.example.com/api/v3',
  32 + site: 'https://github.example.com/api/v3',
33 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 36 end
37 37 end
... ...
spec/interactors/problem_destroy_spec.rb
... ... @@ -6,8 +6,8 @@ describe ProblemDestroy do
6 6 context "in unit way" do
7 7 let(:problem) {
8 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 11 allow(problem).to receive(:delete)
12 12 problem
13 13 }
... ... @@ -30,17 +30,17 @@ describe ProblemDestroy do
30 30 end
31 31  
32 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 34 problem_destroy.execute
35 35 end
36 36  
37 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 39 problem_destroy.execute
40 40 end
41 41  
42 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 44 problem_destroy.execute
45 45 end
46 46 end
... ... @@ -48,26 +48,26 @@ describe ProblemDestroy do
48 48  
49 49 context "in integration way" do
50 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 60 it 'should all destroy' do
61 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 71 end
72 72 end
73 73 end
... ...
spec/interactors/problem_merge_spec.rb
... ... @@ -25,8 +25,8 @@ describe ProblemMerge do
25 25 }
26 26 let(:first_errs) { problem.errs }
27 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 31 it 'delete one of problem' do
32 32 expect {
... ... @@ -52,8 +52,8 @@ describe ProblemMerge do
52 52 end
53 53  
54 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 57 it 'merge comment' do
58 58 expect {
59 59 problem_merge.merge
... ...
spec/interactors/resolved_problem_clearer_spec.rb
... ... @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do
20 20 end
21 21 it 'not repair database' do
22 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 24 resolved_problem_clearer.execute
25 25 end
26 26 end
... ... @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do
28 28 context "with problem resolve" do
29 29 before do
30 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 32 problems.first.resolve!
33 33 problems.second.resolve!
34 34 end
... ... @@ -39,12 +39,12 @@ describe ResolvedProblemClearer do
39 39 }.to change {
40 40 Problem.count
41 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 44 end
45 45  
46 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 48 resolved_problem_clearer.execute
49 49 end
50 50 end
... ...
spec/interactors/user_destroy_spec.rb
... ... @@ -2,8 +2,8 @@ describe UserDestroy do
2 2 let(:app) {
3 3 Fabricate(
4 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 19 expect {
20 20 UserDestroy.new(user).destroy
21 21 }.to change {
22   - app.reload.watchers.where(:user_id => user.id).count
  22 + app.reload.watchers.where(user_id: user.id).count
23 23 }.from(1).to(0)
24 24 end
25 25 end
... ...
spec/lib/configurator_spec.rb
... ... @@ -29,7 +29,7 @@ describe Configurator do
29 29  
30 30 it 'overrides can refer to other values' do
31 31 result = Configurator.run({
32   - one: ['VARONE', ->(values) { values[:one] }],
  32 + one: ['VARONE', ->(values) { values[:one] }],
33 33 three: ['VARTHREE']
34 34 })
35 35 expect(result.one).to eq('zoom')
... ...
spec/mailers/mailer_spec.rb
... ... @@ -41,8 +41,8 @@ describe Mailer do
41 41 let(:app) do
42 42 a = notice.app
43 43 a.update_attributes(
44   - :asset_host => "http://example.com",
45   - :notify_all_users => true
  44 + asset_host: "http://example.com",
  45 + notify_all_users: true
46 46 )
47 47 a
48 48 end
... ... @@ -55,8 +55,8 @@ describe Mailer do
55 55 let(:error_report) do
56 56 instance_double(
57 57 'ErrorReport',
58   - notice: notice,
59   - app: app,
  58 + notice: notice,
  59 + app: app,
60 60 problem: problem
61 61 )
62 62 end
... ... @@ -85,7 +85,7 @@ describe Mailer do
85 85 end
86 86  
87 87 context 'with a very long message' do
88   - let(:notice) { Fabricate(:notice, :message => 6.times.collect { |_a| "0123456789" }.join('')) }
  88 + let(:notice) { Fabricate(:notice, message: 6.times.collect { |_a| "0123456789" }.join('')) }
89 89 it "should truncate the long message" do
90 90 expect(email.subject).to match(/ \d{47}\.{3}$/)
91 91 end
... ... @@ -97,13 +97,13 @@ describe Mailer do
97 97 include EmailSpec::Matchers
98 98  
99 99 let!(:notice) { Fabricate(:notice) }
100   - let!(:comment) { Fabricate(:comment, :err => notice.problem) }
101   - let!(:watcher) { Fabricate(:watcher, :app => comment.app) }
  100 + let!(:comment) { Fabricate(:comment, err: notice.problem) }
  101 + let!(:watcher) { Fabricate(:watcher, app: comment.app) }
102 102 let(:recipients) { ['recipient@example.com', 'another@example.com'] }
103 103  
104 104 before do
105 105 expect(comment).to receive(:notification_recipients).and_return(recipients)
106   - Fabricate(:notice, :err => notice.err)
  106 + Fabricate(:notice, err: notice.err)
107 107 @email = Mailer.comment_notification(comment).deliver_now
108 108 end
109 109  
... ...
spec/models/app_spec.rb
... ... @@ -9,21 +9,21 @@ describe App, type: &#39;model&#39; do
9 9  
10 10 context 'validations' do
11 11 it 'requires a name' do
12   - app = Fabricate.build(:app, :name => nil)
  12 + app = Fabricate.build(:app, name: nil)
13 13 expect(app).to_not be_valid
14 14 expect(app.errors[:name]).to include("can't be blank")
15 15 end
16 16  
17 17 it 'requires unique names' do
18   - Fabricate(:app, :name => 'Errbit')
19   - app = Fabricate.build(:app, :name => 'Errbit')
  18 + Fabricate(:app, name: 'Errbit')
  19 + app = Fabricate.build(:app, name: 'Errbit')
20 20 expect(app).to_not be_valid
21 21 expect(app.errors[:name]).to include('is already taken')
22 22 end
23 23  
24 24 it 'requires unique api_keys' do
25   - Fabricate(:app, :api_key => 'APIKEY')
26   - app = Fabricate.build(:app, :api_key => 'APIKEY')
  25 + Fabricate(:app, api_key: 'APIKEY')
  26 + app = Fabricate.build(:app, api_key: 'APIKEY')
27 27 expect(app).to_not be_valid
28 28 expect(app.errors[:api_key]).to include('is already taken')
29 29 end
... ... @@ -31,24 +31,24 @@ describe App, type: &#39;model&#39; do
31 31  
32 32 describe '<=>' do
33 33 it 'is compared by unresolved count' do
34   - app_0 = stub_model(App, :name => 'app', :unresolved_count => 1, :problem_count => 1)
35   - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1)
  34 + app_0 = stub_model(App, name: 'app', unresolved_count: 1, problem_count: 1)
  35 + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1)
36 36  
37 37 expect(app_0).to be < app_1
38 38 expect(app_1).to be > app_0
39 39 end
40 40  
41 41 it 'is compared by problem count' do
42   - app_0 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1)
43   - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 0)
  42 + app_0 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1)
  43 + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 0)
44 44  
45 45 expect(app_0).to be < app_1
46 46 expect(app_1).to be > app_0
47 47 end
48 48  
49 49 it 'is compared by name' do
50   - app_0 = stub_model(App, :name => 'app_0', :unresolved_count => 0, :problem_count => 0)
51   - app_1 = stub_model(App, :name => 'app_1', :unresolved_count => 0, :problem_count => 0)
  50 + app_0 = stub_model(App, name: 'app_0', unresolved_count: 0, problem_count: 0)
  51 + app_1 = stub_model(App, name: 'app_1', unresolved_count: 0, problem_count: 0)
52 52  
53 53 expect(app_0).to be < app_1
54 54 expect(app_1).to be > app_0
... ... @@ -69,31 +69,31 @@ describe App, type: &#39;model&#39; do
69 69 end
70 70  
71 71 it 'is fine with blank github repos' do
72   - app = Fabricate.build(:app, :github_repo => "")
  72 + app = Fabricate.build(:app, github_repo: "")
73 73 app.save
74 74 expect(app.github_repo).to eq ""
75 75 end
76 76  
77 77 it 'doesnt touch github user/repo' do
78   - app = Fabricate.build(:app, :github_repo => "errbit/errbit")
  78 + app = Fabricate.build(:app, github_repo: "errbit/errbit")
79 79 app.save
80 80 expect(app.github_repo).to eq "errbit/errbit"
81 81 end
82 82  
83 83 it 'removes domain from https github repos' do
84   - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit")
  84 + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit")
85 85 app.save
86 86 expect(app.github_repo).to eq "errbit/errbit"
87 87 end
88 88  
89 89 it 'normalizes public git repo as a github repo' do
90   - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit.git")
  90 + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit.git")
91 91 app.save
92 92 expect(app.github_repo).to eq "errbit/errbit"
93 93 end
94 94  
95 95 it 'normalizes private git repo as a github repo' do
96   - app = Fabricate.build(:app, :github_repo => "git@github.com:errbit/errbit.git")
  96 + app = Fabricate.build(:app, github_repo: "git@github.com:errbit/errbit.git")
97 97 app.save
98 98 expect(app.github_repo).to eq "errbit/errbit"
99 99 end
... ... @@ -101,14 +101,14 @@ describe App, type: &#39;model&#39; do
101 101  
102 102 context '#github_url_to_file' do
103 103 it 'resolves to full path to file' do
104   - app = Fabricate(:app, :github_repo => "errbit/errbit")
  104 + app = Fabricate(:app, github_repo: "errbit/errbit")
105 105 expect(app.github_url_to_file('path/to/file')).to eq "https://github.com/errbit/errbit/blob/master/path/to/file"
106 106 end
107 107 end
108 108  
109 109 context '#github_repo?' do
110 110 it 'is true when there is a github_repo' do
111   - app = Fabricate(:app, :github_repo => "errbit/errbit")
  111 + app = Fabricate(:app, github_repo: "errbit/errbit")
112 112 expect(app.github_repo?).to be(true)
113 113 end
114 114  
... ... @@ -122,7 +122,7 @@ describe App, type: &#39;model&#39; do
122 122 it "should send notices to either all users plus watchers, or the configured watchers" do
123 123 @app = Fabricate(:app)
124 124 3.times { Fabricate(:user) }
125   - 5.times { Fabricate(:watcher, :app => @app) }
  125 + 5.times { Fabricate(:watcher, app: @app) }
126 126 @app.notify_all_users = true
127 127 expect(@app.notification_recipients.size).to eq 8
128 128 @app.notify_all_users = false
... ... @@ -132,19 +132,19 @@ describe App, type: &#39;model&#39; do
132 132  
133 133 context "emailable?" do
134 134 it "should be true if notify on errs and there are notification recipients" do
135   - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false)
136   - 2.times { Fabricate(:watcher, :app => app) }
  135 + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false)
  136 + 2.times { Fabricate(:watcher, app: app) }
137 137 expect(app.emailable?).to be(true)
138 138 end
139 139  
140 140 it "should be false if notify on errs is disabled" do
141   - app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false)
142   - 2.times { Fabricate(:watcher, :app => app) }
  141 + app = Fabricate(:app, notify_on_errs: false, notify_all_users: false)
  142 + 2.times { Fabricate(:watcher, app: app) }
143 143 expect(app.emailable?).to be(false)
144 144 end
145 145  
146 146 it "should be false if there are no notification recipients" do
147   - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false)
  147 + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false)
148 148 expect(app.watchers).to be_empty
149 149 expect(app.emailable?).to be(false)
150 150 end
... ... @@ -152,9 +152,9 @@ describe App, type: &#39;model&#39; do
152 152  
153 153 context "copying attributes from existing app" do
154 154 it "should only copy the necessary fields" do
155   - @app = Fabricate(:app, :name => "app", :github_repo => "url")
156   - @copy_app = Fabricate(:app, :name => "copy_app", :github_repo => "copy url")
157   - @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app)
  155 + @app = Fabricate(:app, name: "app", github_repo: "url")
  156 + @copy_app = Fabricate(:app, name: "copy_app", github_repo: "copy url")
  157 + @copy_watcher = Fabricate(:watcher, email: "copywatcher@example.com", app: @copy_app)
158 158 @app.copy_attributes_from(@copy_app.id)
159 159 expect(@app.name).to eq "app"
160 160 expect(@app.github_repo).to eq "copy url"
... ... @@ -166,18 +166,18 @@ describe App, type: &#39;model&#39; do
166 166 let(:app) { Fabricate(:app) }
167 167 let(:conditions) {
168 168 {
169   - :error_class => 'Whoops',
170   - :environment => 'production',
171   - :fingerprint => 'some-finger-print'
  169 + error_class: 'Whoops',
  170 + environment: 'production',
  171 + fingerprint: 'some-finger-print'
172 172 }
173 173 }
174 174  
175 175 it 'returns the correct err if one already exists' do
176 176 existing = Fabricate(:err, {
177   - :problem => Fabricate(:problem, :app => app),
178   - :fingerprint => conditions[:fingerprint]
  177 + problem: Fabricate(:problem, app: app),
  178 + fingerprint: conditions[:fingerprint]
179 179 })
180   - expect(Err.where(:fingerprint => conditions[:fingerprint]).first).to eq existing
  180 + expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing
181 181 expect(app.find_or_create_err!(conditions)).to eq existing
182 182 end
183 183  
... ... @@ -195,8 +195,8 @@ describe App, type: &#39;model&#39; do
195 195 context "without error_class" do
196 196 let(:conditions) {
197 197 {
198   - :environment => 'production',
199   - :fingerprint => 'some-finger-print'
  198 + environment: 'production',
  199 + fingerprint: 'some-finger-print'
200 200 }
201 201 }
202 202 it 'save the err' do
... ...
spec/models/comment_observer_spec.rb
... ... @@ -8,7 +8,7 @@ describe &quot;Callback on Comment&quot;, type: &#39;model&#39; do
8 8 it 'should send an email notification' do
9 9 expect(Mailer).to receive(:comment_notification).
10 10 with(comment).
11   - and_return(double('email', :deliver_now => true))
  11 + and_return(double('email', deliver_now: true))
12 12 comment.save
13 13 end
14 14 end
... ...
spec/models/comment_spec.rb
1 1 describe Comment, type: 'model' do
2 2 context 'validations' do
3 3 it 'should require a body' do
4   - comment = Fabricate.build(:comment, :body => nil)
  4 + comment = Fabricate.build(:comment, body: nil)
5 5 expect(comment).to_not be_valid
6 6 expect(comment.errors[:body]).to include("can't be blank")
7 7 end
... ... @@ -9,13 +9,13 @@ describe Comment, type: &#39;model&#39; do
9 9  
10 10 context 'notification_recipients' do
11 11 let(:app) { Fabricate(:app) }
12   - let!(:watcher) { Fabricate(:watcher, :app => app) }
13   - let(:err) { Fabricate(:problem, :app => app) }
14   - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') }
15   - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) }
  12 + let!(:watcher) { Fabricate(:watcher, app: app) }
  13 + let(:err) { Fabricate(:problem, app: app) }
  14 + let(:comment_user) { Fabricate(:user, email: 'author@example.com') }
  15 + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) }
16 16  
17 17 before do
18   - Fabricate(:user_watcher, :app => app, :user => comment_user)
  18 + Fabricate(:user_watcher, app: app, user: comment_user)
19 19 end
20 20  
21 21 it 'includes app notification_recipients except user email' do
... ... @@ -24,14 +24,14 @@ describe Comment, type: &#39;model&#39; do
24 24 end
25 25  
26 26 context 'emailable?' do
27   - let(:app) { Fabricate(:app, :notify_on_errs => true) }
28   - let!(:watcher) { Fabricate(:watcher, :app => app) }
29   - let(:err) { Fabricate(:problem, :app => app) }
30   - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') }
31   - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) }
  27 + let(:app) { Fabricate(:app, notify_on_errs: true) }
  28 + let!(:watcher) { Fabricate(:watcher, app: app) }
  29 + let(:err) { Fabricate(:problem, app: app) }
  30 + let(:comment_user) { Fabricate(:user, email: 'author@example.com') }
  31 + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) }
32 32  
33 33 before do
34   - Fabricate(:user_watcher, :app => app, :user => comment_user)
  34 + Fabricate(:user_watcher, app: app, user: comment_user)
35 35 end
36 36  
37 37 it 'should be true if app is emailable? and there are notification recipients' do
... ...
spec/models/deploy_observer_spec.rb
... ... @@ -3,15 +3,15 @@ describe &quot;Callback on Deploy&quot;, type: &#39;model&#39; do
3 3 context 'and the app should notify on deploys' do
4 4 it 'should send an email notification' do
5 5 expect(Mailer).to receive(:deploy_notification).
6   - and_return(double('email', :deliver_now => true))
7   - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true))
  6 + and_return(double('email', deliver_now: true))
  7 + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: true))
8 8 end
9 9 end
10 10  
11 11 context 'and the app is not set to notify on deploys' do
12 12 it 'should not send an email notification' do
13 13 expect(Mailer).to_not receive(:deploy_notification)
14   - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false))
  14 + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: false))
15 15 end
16 16 end
17 17 end
... ...
spec/models/deploy_spec.rb
1 1 describe Deploy, type: 'model' do
2 2 context 'validations' do
3 3 it 'requires a username' do
4   - deploy = Fabricate.build(:deploy, :username => nil)
  4 + deploy = Fabricate.build(:deploy, username: nil)
5 5 expect(deploy).to_not be_valid
6 6 expect(deploy.errors[:username]).to include("can't be blank")
7 7 end
8 8  
9 9 it 'requires an environment' do
10   - deploy = Fabricate.build(:deploy, :environment => nil)
  10 + deploy = Fabricate.build(:deploy, environment: nil)
11 11 expect(deploy).to_not be_valid
12 12 expect(deploy.errors[:environment]).to include("can't be blank")
13 13 end
... ... @@ -16,19 +16,19 @@ describe Deploy, type: &#39;model&#39; do
16 16 context 'being created' do
17 17 context 'when the app has resolve_errs_on_deploy set to false' do
18 18 it 'should not resolve the apps errs' do
19   - app = Fabricate(:app, :resolve_errs_on_deploy => false)
20   - @problems = 3.times.map { Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app)) }
21   - Fabricate(:deploy, :app => app)
  19 + app = Fabricate(:app, resolve_errs_on_deploy: false)
  20 + @problems = 3.times.map { Fabricate(:err, problem: Fabricate(:problem, resolved: false, app: app)) }
  21 + Fabricate(:deploy, app: app)
22 22 expect(app.reload.problems.none?(&:resolved?)).to eq true
23 23 end
24 24 end
25 25  
26 26 context 'when the app has resolve_errs_on_deploy set to true' do
27 27 it 'should resolve the apps errs that were in the same environment' do
28   - app = Fabricate(:app, :resolve_errs_on_deploy => true)
29   - @prod_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'production') }
30   - @staging_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging') }
31   - Fabricate(:deploy, :app => app, :environment => 'production')
  28 + app = Fabricate(:app, resolve_errs_on_deploy: true)
  29 + @prod_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'production') }
  30 + @staging_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'staging') }
  31 + Fabricate(:deploy, app: app, environment: 'production')
32 32 expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true
33 33 expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false
34 34 end
... ... @@ -36,6 +36,6 @@ describe Deploy, type: &#39;model&#39; do
36 36 end
37 37  
38 38 it "should produce a shortened revision with 7 characters" do
39   - expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567"
  39 + expect(Deploy.new(revision: "1234567890abcdef").short_revision).to eq "1234567"
40 40 end
41 41 end
... ...
spec/models/err_spec.rb
1 1 describe Err, type: 'model' do
2 2 context 'validations' do
3 3 it 'requires a fingerprint' do
4   - err = Fabricate.build(:err, :fingerprint => nil)
  4 + err = Fabricate.build(:err, fingerprint: nil)
5 5 expect(err).to_not be_valid
6 6 expect(err.errors[:fingerprint]).to include("can't be blank")
7 7 end
8 8  
9 9 it 'requires a problem' do
10   - err = Fabricate.build(:err, :problem_id => nil, :problem => nil)
  10 + err = Fabricate.build(:err, problem_id: nil, problem: nil)
11 11 expect(err).to_not be_valid
12 12 expect(err.errors[:problem_id]).to include("can't be blank")
13 13 end
... ...
spec/models/error_report_spec.rb
... ... @@ -26,7 +26,7 @@ describe ErrorReport do
26 26 let!(:app) {
27 27 Fabricate(
28 28 :app,
29   - :api_key => 'APIKEY'
  29 + api_key: 'APIKEY'
30 30 )
31 31 }
32 32  
... ... @@ -68,9 +68,9 @@ describe ErrorReport do
68 68 context "with notice generate by Airbrake gem" do
69 69 let(:xml) {
70 70 Airbrake::Notice.new(
71   - :exception => Exception.new,
72   - :api_key => 'APIKEY',
73   - :project_root => Rails.root
  71 + exception: Exception.new,
  72 + api_key: 'APIKEY',
  73 + project_root: Rails.root
74 74 ).to_xml
75 75 }
76 76 it 'save a notice' do
... ... @@ -159,7 +159,7 @@ describe ErrorReport do
159 159 problem = error_report.problem
160 160 problem.update(
161 161 resolved_at: Time.zone.now,
162   - resolved: true
  162 + resolved: true
163 163 )
164 164  
165 165 error_report = ErrorReport.new(xml)
... ... @@ -223,7 +223,7 @@ describe ErrorReport do
223 223 context "with notification service configured" do
224 224 before do
225 225 app.notify_on_errs = true
226   - app.watchers.build(:email => 'foo@example.com')
  226 + app.watchers.build(email: 'foo@example.com')
227 227 app.save
228 228 end
229 229  
... ... @@ -271,7 +271,7 @@ describe ErrorReport do
271 271 end
272 272 context "with not valid api_key" do
273 273 before do
274   - App.where(:api_key => app.api_key).delete_all
  274 + App.where(api_key: app.api_key).delete_all
275 275 end
276 276 it "return false" do
277 277 expect(error_report.valid?).to be false
... ...
spec/models/notice_observer_spec.rb
... ... @@ -2,27 +2,27 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
2 2 let(:notice_attrs_for) do
3 3 lambda do |api_key|
4 4 {
5   - error_class: "HoptoadTestingException",
6   - message: "some message",
7   - backtrace: [
  5 + error_class: "HoptoadTestingException",
  6 + message: "some message",
  7 + backtrace: [
8 8 {
9 9 "number" => "425",
10 10 "file" => "[GEM_ROOT]/callbacks.rb",
11 11 "method" => "__callbacks"
12 12 }
13 13 ],
14   - request: { "component" => "application" },
  14 + request: { "component" => "application" },
15 15 server_environment: {
16 16 "project-root" => "/path/to/sample/project",
17 17 "environment-name" => "development"
18 18 },
19   - api_key: api_key,
20   - notifier: {
  19 + api_key: api_key,
  20 + notifier: {
21 21 "name" => "Hoptoad Notifier",
22 22 "version" => "2.3.2",
23 23 "url" => "http://hoptoadapp.com"
24 24 },
25   - framework: "Rails: 3.2.11"
  25 + framework: "Rails: 3.2.11"
26 26 }
27 27 end
28 28 end
... ... @@ -49,7 +49,7 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
49 49 @problem.update_attributes notices_count: threshold - 1
50 50  
51 51 expect(Mailer).to receive(:err_notification).
52   - and_return(double('email', :deliver_now => true))
  52 + and_return(double('email', deliver_now: true))
53 53  
54 54 error_report = ErrorReport.new(notice_attrs)
55 55 error_report.generate_notice!
... ... @@ -77,7 +77,7 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
77 77 let(:app) do
78 78 Fabricate(
79 79 :app_with_watcher,
80   - notify_on_errs: true,
  80 + notify_on_errs: true,
81 81 email_at_notices: [1, 100]
82 82 )
83 83 end
... ... @@ -95,7 +95,7 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
95 95 err.problem.resolve!
96 96  
97 97 expect(Mailer).to receive(:err_notification).
98   - and_return(double('email', :deliver_now => true))
  98 + and_return(double('email', deliver_now: true))
99 99  
100 100 ErrorReport.new(notice_attrs).generate_notice!
101 101 end
... ... @@ -106,7 +106,7 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
106 106 let(:app) do
107 107 Fabricate(
108 108 :app_with_watcher,
109   - notify_on_errs: true,
  109 + notify_on_errs: true,
110 110 notification_service: notification_service
111 111 )
112 112 end
... ... @@ -121,7 +121,7 @@ describe &quot;Callback on Notice&quot;, type: &#39;model&#39; do
121 121 expect(error_report.app.notification_service).
122 122 to receive(:create_notification).and_raise(ArgumentError)
123 123 expect(Mailer).
124   - to receive(:err_notification).and_return(double(:deliver_now => true))
  124 + to receive(:err_notification).and_return(double(deliver_now: true))
125 125  
126 126 error_report.generate_notice!
127 127 end
... ...
spec/models/notice_spec.rb
1 1 describe Notice, type: 'model' do
2 2 context 'validations' do
3 3 it 'requires a backtrace' do
4   - notice = Fabricate.build(:notice, :backtrace => nil)
  4 + notice = Fabricate.build(:notice, backtrace: nil)
5 5 expect(notice).to_not be_valid
6 6 expect(notice.errors[:backtrace_id]).to include("can't be blank")
7 7 end
8 8  
9 9 it 'requires the server_environment' do
10   - notice = Fabricate.build(:notice, :server_environment => nil)
  10 + notice = Fabricate.build(:notice, server_environment: nil)
11 11 expect(notice).to_not be_valid
12 12 expect(notice.errors[:server_environment]).to include("can't be blank")
13 13 end
14 14  
15 15 it 'requires the notifier' do
16   - notice = Fabricate.build(:notice, :notifier => nil)
  16 + notice = Fabricate.build(:notice, notifier: nil)
17 17 expect(notice).to_not be_valid
18 18 expect(notice.errors[:notifier]).to include("can't be blank")
19 19 end
... ... @@ -57,7 +57,7 @@ describe Notice, type: &#39;model&#39; do
57 57  
58 58 describe "user agent" do
59 59 it "should be parsed and human-readable" do
60   - notice = Fabricate.build(:notice, :request => { 'cgi-data' => {
  60 + notice = Fabricate.build(:notice, request: { 'cgi-data' => {
61 61 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'
62 62 } })
63 63 expect(notice.user_agent.browser).to eq 'Chrome'
... ... @@ -72,7 +72,7 @@ describe Notice, type: &#39;model&#39; do
72 72  
73 73 describe "user agent string" do
74 74 it "should be parsed and human-readable" do
75   - notice = Fabricate.build(:notice, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
  75 + notice = Fabricate.build(:notice, request: { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
76 76 expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)'
77 77 end
78 78  
... ... @@ -84,22 +84,22 @@ describe Notice, type: &#39;model&#39; do
84 84  
85 85 describe "host" do
86 86 it "returns host if url is valid" do
87   - notice = Fabricate.build(:notice, :request => { 'url' => "http://example.com/resource/12" })
  87 + notice = Fabricate.build(:notice, request: { 'url' => "http://example.com/resource/12" })
88 88 expect(notice.host).to eq 'example.com'
89 89 end
90 90  
91 91 it "returns 'N/A' when url is not valid" do
92   - notice = Fabricate.build(:notice, :request => { 'url' => "file:///path/to/some/resource/12" })
  92 + notice = Fabricate.build(:notice, request: { 'url' => "file:///path/to/some/resource/12" })
93 93 expect(notice.host).to eq 'N/A'
94 94 end
95 95  
96 96 it "returns 'N/A' when url is not valid" do
97   - notice = Fabricate.build(:notice, :request => { 'url' => "some string" })
  97 + notice = Fabricate.build(:notice, request: { 'url' => "some string" })
98 98 expect(notice.host).to eq 'N/A'
99 99 end
100 100  
101 101 it "returns 'N/A' when url is empty" do
102   - notice = Fabricate.build(:notice, :request => {})
  102 + notice = Fabricate.build(:notice, request: {})
103 103 expect(notice.host).to eq 'N/A'
104 104 end
105 105 end
... ...
spec/models/notification_service/campfire_service_spec.rb
... ... @@ -2,7 +2,7 @@ describe NotificationServices::CampfireService, type: &#39;model&#39; do
2 2 it "it should send a notification to campfire" do
3 3 # setup
4 4 notice = Fabricate :notice
5   - notification_service = Fabricate :campfire_notification_service, :app => notice.app
  5 + notification_service = Fabricate :campfire_notification_service, app: notice.app
6 6 problem = notice.problem
7 7  
8 8 #campy stubbing
... ...
spec/models/notification_service/flowdock_service_spec.rb
1 1 describe NotificationServices::FlowdockService, type: 'model' do
2 2 let(:service) { Fabricate.build(:flowdock_notification_service) }
3   - let(:app) { Fabricate(:app, :name => 'App #3') }
4   - let(:problem) { Fabricate(:problem, :app => app, :message => '<3') }
  3 + let(:app) { Fabricate(:app, name: 'App #3') }
  4 + let(:problem) { Fabricate(:problem, app: app, message: '<3') }
5 5  
6 6 it 'sends message in appropriate format' do
7 7 allow_any_instance_of(Flowdock::Flow).to receive(:push_to_team_inbox) do |*args|
... ...
spec/models/notification_service/gtalk_service_spec.rb
... ... @@ -3,7 +3,7 @@ describe NotificationServices::GtalkService, type: &#39;model&#39; do
3 3 # setup
4 4 notice = Fabricate :notice
5 5 notice.problem
6   - notification_service = Fabricate :gtalk_notification_service, :app => notice.app
  6 + notification_service = Fabricate :gtalk_notification_service, app: notice.app
7 7 problem = notice.problem
8 8  
9 9 #gtalk stubbing
... ... @@ -35,7 +35,7 @@ describe NotificationServices::GtalkService, type: &#39;model&#39; do
35 35 before(:each) do
36 36 # setup
37 37 @notice = Fabricate :notice
38   - @notification_service = Fabricate :gtalk_notification_service, :app => @notice.app
  38 + @notification_service = Fabricate :gtalk_notification_service, app: @notice.app
39 39 @problem = @notice.problem
40 40 @error_msg = """#{@problem.app.name}
41 41 #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{@problem.app.id}
... ... @@ -94,7 +94,7 @@ describe NotificationServices::GtalkService, type: &#39;model&#39; do
94 94 # setup
95 95 notice = Fabricate :notice
96 96 notice.problem
97   - notification_service = Fabricate :gtalk_notification_service, :app => notice.app
  97 + notification_service = Fabricate :gtalk_notification_service, app: notice.app
98 98 problem = notice.problem
99 99  
100 100 #gtalk stubbing
... ...
spec/models/notification_service/hoiio_service_spec.rb
... ... @@ -2,7 +2,7 @@ describe NotificationServices::HoiioService, type: &#39;model&#39; do
2 2 it "it should send a notification to hoiio" do
3 3 # setup
4 4 notice = Fabricate :notice
5   - notification_service = Fabricate :hoiio_notification_service, :app => notice.app
  5 + notification_service = Fabricate :hoiio_notification_service, app: notice.app
6 6 problem = notice.problem
7 7  
8 8 # hoi stubbing
... ...
spec/models/notification_service/hubot_service_spec.rb
... ... @@ -2,11 +2,11 @@ describe NotificationServices::HubotService, type: &#39;model&#39; do
2 2 it "it should send a notification to Hubot" do
3 3 # setup
4 4 notice = Fabricate :notice
5   - notification_service = Fabricate :hubot_notification_service, :app => notice.app
  5 + notification_service = Fabricate :hubot_notification_service, app: notice.app
6 6 problem = notice.problem
7 7  
8 8 # faraday stubbing
9   - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => { :message => an_instance_of(String), :room => notification_service.room_id }).and_return(true)
  9 + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: { message: an_instance_of(String), room: notification_service.room_id }).and_return(true)
10 10  
11 11 notification_service.create_notification(problem)
12 12 end
... ...
spec/models/notification_service/notification_service_spec.rb
1 1 describe NotificationServices, type: 'model' do
2 2 let(:notice) { Fabricate :notice }
3   - let(:notification_service) { Fabricate :notification_service, :app => notice.app }
  3 + let(:notification_service) { Fabricate :notification_service, app: notice.app }
4 4 let(:problem) { notice.problem }
5 5  
6 6 it "it should use http by default in #problem_url" do
... ...
spec/models/notification_service/pushover_service_spec.rb
... ... @@ -2,7 +2,7 @@ describe NotificationServices::PushoverService, type: &#39;model&#39; do
2 2 it "it should send a notification to Pushover" do
3 3 # setup
4 4 notice = Fabricate :notice
5   - notification_service = Fabricate :pushover_notification_service, :app => notice.app
  5 + notification_service = Fabricate :pushover_notification_service, app: notice.app
6 6 problem = notice.problem
7 7  
8 8 # hoi stubbing
... ...
spec/models/notification_service/slack_service_spec.rb
... ... @@ -2,52 +2,52 @@ describe NotificationServices::SlackService, type: &#39;model&#39; do
2 2 it "it should send a notification to Slack with hook url" do
3 3 # setup
4 4 notice = Fabricate :notice
5   - notification_service = Fabricate :slack_notification_service, :app => notice.app, :service_url => "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX"
  5 + notification_service = Fabricate :slack_notification_service, app: notice.app, service_url: "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX"
6 6 problem = notice.problem
7 7  
8 8 # faraday stubbing
9 9 payload = {
10   - :attachments => [
  10 + attachments: [
11 11 {
12   - :fallback => notification_service.message_for_slack(problem),
13   - :pretext => "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>",
14   - :color => "#D00000",
15   - :fields => [
  12 + fallback: notification_service.message_for_slack(problem),
  13 + pretext: "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>",
  14 + color: "#D00000",
  15 + fields: [
16 16 {
17   - :title => "Environment",
18   - :value => problem.environment,
19   - :short => false
  17 + title: "Environment",
  18 + value: problem.environment,
  19 + short: false
20 20 },
21 21 {
22   - :title => "Location",
23   - :value => problem.where,
24   - :short => false
  22 + title: "Location",
  23 + value: problem.where,
  24 + short: false
25 25 },
26 26 {
27   - :title => "Message",
28   - :value => problem.message.to_s,
29   - :short => false
  27 + title: "Message",
  28 + value: problem.message.to_s,
  29 + short: false
30 30 },
31 31 {
32   - :title => "First Noticed",
33   - :value => problem.first_notice_at,
34   - :short => false
  32 + title: "First Noticed",
  33 + value: problem.first_notice_at,
  34 + short: false
35 35 },
36 36 {
37   - :title => "Last Noticed",
38   - :value => problem.last_notice_at,
39   - :short => false
  37 + title: "Last Noticed",
  38 + value: problem.last_notice_at,
  39 + short: false
40 40 },
41 41 {
42   - :title => "Times Occurred",
43   - :value => problem.notices_count,
44   - :short => false
  42 + title: "Times Occurred",
  43 + value: problem.notices_count,
  44 + short: false
45 45 }
46 46 ]
47 47 }
48 48 ]
49 49 }.to_json
50   - expect(HTTParty).to receive(:post).with(notification_service.service_url, :body => payload, :headers => { "Content-Type" => "application/json" }).and_return(true)
  50 + expect(HTTParty).to receive(:post).with(notification_service.service_url, body: payload, headers: { "Content-Type" => "application/json" }).and_return(true)
51 51  
52 52 notification_service.create_notification(problem)
53 53 end
... ...
spec/models/notification_service/webhook_service_spec.rb
1 1 describe NotificationServices::WebhookService, type: 'model' do
2 2 it "it should send a notification to a user-specified URL" do
3 3 notice = Fabricate :notice
4   - notification_service = Fabricate :webhook_notification_service, :app => notice.app
  4 + notification_service = Fabricate :webhook_notification_service, app: notice.app
5 5 problem = notice.problem
6 6  
7 7 payload = notification_service.message_for_webhook(problem)
8   - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => payload).and_return(true)
  8 + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: payload).and_return(true)
9 9  
10 10 notification_service.create_notification(problem)
11 11 end
... ...
spec/models/problem_spec.rb
1 1 describe Problem, type: 'model' do
2 2 context 'validations' do
3 3 it 'requires an environment' do
4   - err = Fabricate.build(:problem, :environment => nil)
  4 + err = Fabricate.build(:problem, environment: nil)
5 5 expect(err).to_not be_valid
6 6 expect(err.errors[:environment]).to include("can't be blank")
7 7 end
... ... @@ -39,10 +39,10 @@ describe Problem, type: &#39;model&#39; do
39 39 problem = err.problem
40 40 expect(problem).to_not be_nil
41 41  
42   - notice1 = Fabricate(:notice, :err => err)
  42 + notice1 = Fabricate(:notice, err: err)
43 43 expect(problem.last_notice_at).to eq notice1.reload.created_at
44 44  
45   - notice2 = Fabricate(:notice, :err => err)
  45 + notice2 = Fabricate(:notice, err: err)
46 46 expect(problem.last_notice_at).to eq notice2.reload.created_at
47 47 end
48 48 end
... ... @@ -53,10 +53,10 @@ describe Problem, type: &#39;model&#39; do
53 53 problem = err.problem
54 54 expect(problem).to_not be_nil
55 55  
56   - notice1 = Fabricate(:notice, :err => err)
  56 + notice1 = Fabricate(:notice, err: err)
57 57 expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i)
58 58  
59   - Fabricate(:notice, :err => err)
  59 + Fabricate(:notice, err: err)
60 60 expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i)
61 61 end
62 62 end
... ... @@ -66,7 +66,7 @@ describe Problem, type: &#39;model&#39; do
66 66 err = Fabricate(:err)
67 67 problem = err.problem
68 68 expect {
69   - Fabricate(:notice, :err => err, :message => 'ERR 1')
  69 + Fabricate(:notice, err: err, message: 'ERR 1')
70 70 }.to change(problem, :message).from(nil).to('ERR 1')
71 71 end
72 72 end
... ... @@ -74,9 +74,9 @@ describe Problem, type: &#39;model&#39; do
74 74 context 'being created' do
75 75 context 'when the app has err notifications set to false' do
76 76 it 'should not send an email notification' do
77   - app = Fabricate(:app_with_watcher, :notify_on_errs => false)
  77 + app = Fabricate(:app_with_watcher, notify_on_errs: false)
78 78 expect(Mailer).to_not receive(:err_notification)
79   - Fabricate(:problem, :app => app)
  79 + Fabricate(:problem, app: app)
80 80 end
81 81 end
82 82 end
... ... @@ -114,7 +114,7 @@ describe Problem, type: &#39;model&#39; do
114 114 end
115 115  
116 116 it "should not reset notice count" do
117   - problem = Fabricate(:problem, :notices_count => 1)
  117 + problem = Fabricate(:problem, notices_count: 1)
118 118 original_notices_count = problem.notices_count
119 119 expect(original_notices_count).to be > 0
120 120  
... ... @@ -157,8 +157,8 @@ describe Problem, type: &#39;model&#39; do
157 157 context "Scopes" do
158 158 context "resolved" do
159 159 it 'only finds resolved Problems' do
160   - resolved = Fabricate(:problem, :resolved => true)
161   - unresolved = Fabricate(:problem, :resolved => false)
  160 + resolved = Fabricate(:problem, resolved: true)
  161 + unresolved = Fabricate(:problem, resolved: false)
162 162 expect(Problem.resolved.all).to include(resolved)
163 163 expect(Problem.resolved.all).to_not include(unresolved)
164 164 end
... ... @@ -166,8 +166,8 @@ describe Problem, type: &#39;model&#39; do
166 166  
167 167 context "unresolved" do
168 168 it 'only finds unresolved Problems' do
169   - resolved = Fabricate(:problem, :resolved => true)
170   - unresolved = Fabricate(:problem, :resolved => false)
  169 + resolved = Fabricate(:problem, resolved: true)
  170 + unresolved = Fabricate(:problem, resolved: false)
171 171 expect(Problem.unresolved.all).to_not include(resolved)
172 172 expect(Problem.unresolved.all).to include(unresolved)
173 173 end
... ... @@ -175,15 +175,15 @@ describe Problem, type: &#39;model&#39; do
175 175  
176 176 context "searching" do
177 177 it 'finds the correct record' do
178   - find = Fabricate(:problem, :resolved => false, :error_class => 'theErrorclass::other',
179   - :message => "other", :where => 'errorclass', :environment => 'development', :app_name => 'other')
180   - dont_find = Fabricate(:problem, :resolved => false, :error_class => "Batman",
181   - :message => 'todo', :where => 'classerror', :environment => 'development', :app_name => 'other')
  178 + find = Fabricate(:problem, resolved: false, error_class: 'theErrorclass::other',
  179 + message: "other", where: 'errorclass', environment: 'development', app_name: 'other')
  180 + dont_find = Fabricate(:problem, resolved: false, error_class: "Batman",
  181 + message: 'todo', where: 'classerror', environment: 'development', app_name: 'other')
182 182 expect(Problem.search("theErrorClass").unresolved).to include(find)
183 183 expect(Problem.search("theErrorClass").unresolved).to_not include(dont_find)
184 184 end
185 185 it 'find on where message' do
186   - problem = Fabricate(:problem, :where => 'cyril')
  186 + problem = Fabricate(:problem, where: 'cyril')
187 187 expect(Problem.search('cyril').entries).to eq [problem]
188 188 end
189 189 end
... ... @@ -192,8 +192,8 @@ describe Problem, type: &#39;model&#39; do
192 192 context "notice counter cache" do
193 193 before do
194 194 @app = Fabricate(:app)
195   - @problem = Fabricate(:problem, :app => @app)
196   - @err = Fabricate(:err, :problem => @problem)
  195 + @problem = Fabricate(:problem, app: @app)
  196 + @err = Fabricate(:err, problem: @problem)
197 197 end
198 198  
199 199 it "#notices_count returns 0 by default" do
... ... @@ -202,12 +202,12 @@ describe Problem, type: &#39;model&#39; do
202 202  
203 203 it "adding a notice increases #notices_count by 1" do
204 204 expect {
205   - Fabricate(:notice, :err => @err, :message => 'ERR 1')
  205 + Fabricate(:notice, err: @err, message: 'ERR 1')
206 206 }.to change(@problem.reload, :notices_count).from(0).to(1)
207 207 end
208 208  
209 209 it "removing a notice decreases #notices_count by 1" do
210   - Fabricate(:notice, :err => @err, :message => 'ERR 1')
  210 + Fabricate(:notice, err: @err, message: 'ERR 1')
211 211 expect {
212 212 @err.notices.first.destroy
213 213 @problem.reload
... ... @@ -217,7 +217,7 @@ describe Problem, type: &#39;model&#39; do
217 217  
218 218 context "#app_name" do
219 219 let!(:app) { Fabricate(:app) }
220   - let!(:problem) { Fabricate(:problem, :app => app) }
  220 + let!(:problem) { Fabricate(:problem, app: app) }
221 221  
222 222 before { app.reload }
223 223  
... ... @@ -227,7 +227,7 @@ describe Problem, type: &#39;model&#39; do
227 227  
228 228 it "is updated when an app is updated" do
229 229 expect {
230   - app.update_attributes!(:name => "Bar App")
  230 + app.update_attributes!(name: "Bar App")
231 231 problem.reload
232 232 }.to change(problem, :app_name).to("Bar App")
233 233 end
... ... @@ -237,19 +237,19 @@ describe Problem, type: &#39;model&#39; do
237 237 before do
238 238 @app = Fabricate(:app)
239 239 @last_deploy = 10.days.ago
240   - Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production")
  240 + Fabricate(:deploy, app: @app, created_at: @last_deploy, environment: "production")
241 241 end
242 242  
243 243 it "is set when a problem is created" do
244   - problem = Fabricate(:problem, :app => @app, :environment => "production")
  244 + problem = Fabricate(:problem, app: @app, environment: "production")
245 245 assert_equal @last_deploy, problem.last_deploy_at
246 246 end
247 247  
248 248 it "is updated when a deploy is created" do
249   - problem = Fabricate(:problem, :app => @app, :environment => "production")
  249 + problem = Fabricate(:problem, app: @app, environment: "production")
250 250 next_deploy = 5.minutes.ago
251 251 expect {
252   - @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy)
  252 + @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy)
253 253 problem.reload
254 254 }.to change { problem.last_deploy_at.iso8601 }.
255 255 from(@last_deploy.iso8601).
... ... @@ -260,8 +260,8 @@ describe Problem, type: &#39;model&#39; do
260 260 context "notice messages cache" do
261 261 before do
262 262 @app = Fabricate(:app)
263   - @problem = Fabricate(:problem, :app => @app)
264   - @err = Fabricate(:err, :problem => @problem)
  263 + @problem = Fabricate(:problem, app: @app)
  264 + @err = Fabricate(:err, problem: @problem)
265 265 end
266 266  
267 267 it "#messages should be empty by default" do
... ... @@ -269,7 +269,7 @@ describe Problem, type: &#39;model&#39; do
269 269 end
270 270  
271 271 it "removing a notice removes string from #messages" do
272   - Fabricate(:notice, :err => @err, :message => 'ERR 1')
  272 + Fabricate(:notice, err: @err, message: 'ERR 1')
273 273 expect {
274 274 @err.notices.first.destroy
275 275 @problem.reload
... ... @@ -277,7 +277,7 @@ describe Problem, type: &#39;model&#39; do
277 277 end
278 278  
279 279 it "removing a notice from the problem with broken counter should not raise an error" do
280   - Fabricate(:notice, :err => @err, :message => 'ERR 1')
  280 + Fabricate(:notice, err: @err, message: 'ERR 1')
281 281 @problem.messages = {}
282 282 @problem.save!
283 283 expect { @err.notices.first.destroy }.not_to raise_error
... ... @@ -287,8 +287,8 @@ describe Problem, type: &#39;model&#39; do
287 287 context "notice hosts cache" do
288 288 before do
289 289 @app = Fabricate(:app)
290   - @problem = Fabricate(:problem, :app => @app)
291   - @err = Fabricate(:err, :problem => @problem)
  290 + @problem = Fabricate(:problem, app: @app)
  291 + @err = Fabricate(:err, problem: @problem)
292 292 end
293 293  
294 294 it "#hosts should be empty by default" do
... ... @@ -296,7 +296,7 @@ describe Problem, type: &#39;model&#39; do
296 296 end
297 297  
298 298 it "removing a notice removes string from #hosts" do
299   - Fabricate(:notice, :err => @err, :request => { 'url' => "http://example.com/resource/12" })
  299 + Fabricate(:notice, err: @err, request: { 'url' => "http://example.com/resource/12" })
300 300 expect {
301 301 @err.notices.first.destroy
302 302 @problem.reload
... ... @@ -307,8 +307,8 @@ describe Problem, type: &#39;model&#39; do
307 307 context "notice user_agents cache" do
308 308 before do
309 309 @app = Fabricate(:app)
310   - @problem = Fabricate(:problem, :app => @app)
311   - @err = Fabricate(:err, :problem => @problem)
  310 + @problem = Fabricate(:problem, app: @app)
  311 + @err = Fabricate(:err, problem: @problem)
312 312 end
313 313  
314 314 it "#user_agents should be empty by default" do
... ... @@ -316,7 +316,7 @@ describe Problem, type: &#39;model&#39; do
316 316 end
317 317  
318 318 it "removing a notice removes string from #user_agents" do
319   - Fabricate(:notice, :err => @err, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
  319 + Fabricate(:notice, err: @err, request: { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
320 320 expect {
321 321 @err.notices.first.destroy
322 322 @problem.reload
... ... @@ -329,7 +329,7 @@ describe Problem, type: &#39;model&#39; do
329 329 context "comment counter cache" do
330 330 before do
331 331 @app = Fabricate(:app)
332   - @problem = Fabricate(:problem, :app => @app)
  332 + @problem = Fabricate(:problem, app: @app)
333 333 end
334 334  
335 335 it "#comments_count returns 0 by default" do
... ... @@ -338,12 +338,12 @@ describe Problem, type: &#39;model&#39; do
338 338  
339 339 it "adding a comment increases #comments_count by 1" do
340 340 expect {
341   - Fabricate(:comment, :err => @problem)
  341 + Fabricate(:comment, err: @problem)
342 342 }.to change(@problem, :comments_count).from(0).to(1)
343 343 end
344 344  
345 345 it "removing a comment decreases #comments_count by 1" do
346   - Fabricate(:comment, :err => @problem)
  346 + Fabricate(:comment, err: @problem)
347 347 expect {
348 348 @problem.reload.comments.first.destroy
349 349 @problem.reload
... ... @@ -354,11 +354,11 @@ describe Problem, type: &#39;model&#39; do
354 354 describe "#issue_type" do
355 355 context "without issue_type fill in Problem" do
356 356 let(:problem) do
357   - Problem.new(:app => app)
  357 + Problem.new(app: app)
358 358 end
359 359  
360 360 let(:app) do
361   - App.new(:issue_tracker => issue_tracker)
  361 + App.new(issue_tracker: issue_tracker)
362 362 end
363 363  
364 364 context "without issue_tracker associate to app" do
... ... @@ -384,7 +384,7 @@ describe Problem, type: &#39;model&#39; do
384 384  
385 385 context "with issue_tracker not valid associate to app" do
386 386 let(:issue_tracker) do
387   - IssueTracker.new(:type_tracker => 'fake')
  387 + IssueTracker.new(type_tracker: 'fake')
388 388 end
389 389  
390 390 it 'return nil' do
... ... @@ -395,7 +395,7 @@ describe Problem, type: &#39;model&#39; do
395 395  
396 396 context "with issue_type fill in Problem" do
397 397 it 'return the value associate' do
398   - expect(Problem.new(:issue_type => 'foo').issue_type).to eql 'foo'
  398 + expect(Problem.new(issue_type: 'foo').issue_type).to eql 'foo'
399 399 end
400 400 end
401 401 end
... ... @@ -403,7 +403,7 @@ describe Problem, type: &#39;model&#39; do
403 403 describe '#recache' do
404 404 let(:problem) { Fabricate(:problem_with_errs) }
405 405 let(:first_errs) { problem.errs }
406   - let!(:notice) { Fabricate(:notice, :err => first_errs.first) }
  406 + let!(:notice) { Fabricate(:notice, err: first_errs.first) }
407 407  
408 408 before do
409 409 problem.update_attribute(:notices_count, 0)
... ... @@ -419,7 +419,7 @@ describe Problem, type: &#39;model&#39; do
419 419  
420 420 context "with only one notice" do
421 421 before do
422   - problem.update_attributes!(:messages => {})
  422 + problem.update_attributes!(messages: {})
423 423 problem.recache
424 424 end
425 425  
... ... @@ -456,10 +456,10 @@ describe Problem, type: &#39;model&#39; do
456 456 end
457 457  
458 458 context "with several notices" do
459   - let!(:notice_2) { Fabricate(:notice, :err => first_errs.first) }
460   - let!(:notice_3) { Fabricate(:notice, :err => first_errs.first) }
  459 + let!(:notice_2) { Fabricate(:notice, err: first_errs.first) }
  460 + let!(:notice_3) { Fabricate(:notice, err: first_errs.first) }
461 461 before do
462   - problem.update_attributes!(:messages => {})
  462 + problem.update_attributes!(messages: {})
463 463 problem.recache
464 464 end
465 465  
... ...
spec/models/user_spec.rb
1 1 describe User do
2 2 context 'validations' do
3 3 it 'require that a name is present' do
4   - user = Fabricate.build(:user, :name => nil)
  4 + user = Fabricate.build(:user, name: nil)
5 5 expect(user).to_not be_valid
6 6 expect(user.errors[:name]).to include("can't be blank")
7 7 end
8 8  
9 9 it 'requires password without github login' do
10   - user = Fabricate.build(:user, :password => nil)
  10 + user = Fabricate.build(:user, password: nil)
11 11 expect(user).to_not be_valid
12 12 expect(user.errors[:password]).to include("can't be blank")
13 13 end
14 14  
15 15 it "doesn't require password with github login" do
16   - user = Fabricate.build(:user, :password => nil, :github_login => 'nashby')
  16 + user = Fabricate.build(:user, password: nil, github_login: 'nashby')
17 17 expect(user).to be_valid
18 18 end
19 19  
20 20 it 'requires uniq github login' do
21   - user1 = Fabricate(:user, :github_login => 'nashby')
  21 + user1 = Fabricate(:user, github_login: 'nashby')
22 22 expect(user1).to be_valid
23 23  
24   - user2 = Fabricate.build(:user, :github_login => 'nashby')
  24 + user2 = Fabricate.build(:user, github_login: 'nashby')
25 25 user2.save
26 26 expect(user2).to_not be_valid
27 27 expect(user2.errors[:github_login]).to include("is already taken")
28 28 end
29 29  
30 30 it 'allows blank / null github_login' do
31   - user1 = Fabricate(:user, :github_login => ' ')
  31 + user1 = Fabricate(:user, github_login: ' ')
32 32 expect(user1).to be_valid
33 33  
34   - user2 = Fabricate.build(:user, :github_login => ' ')
  34 + user2 = Fabricate.build(:user, github_login: ' ')
35 35 user2.save
36 36 expect(user2).to be_valid
37 37 end
... ... @@ -43,7 +43,7 @@ describe User do
43 43 allow($stdout).to receive(:puts).and_return(true)
44 44 require Rails.root.join('db/seeds.rb')
45 45 }.to change {
46   - User.where(:admin => true).count
  46 + User.where(admin: true).count
47 47 }.from(0).to(1)
48 48 end
49 49 end
... ...
spec/models/watcher_spec.rb
1 1 describe Watcher, type: 'model' do
2 2 context 'validations' do
3 3 it 'requires an email address or an associated user' do
4   - watcher = Fabricate.build(:watcher, :email => nil, :user => nil)
  4 + watcher = Fabricate.build(:watcher, email: nil, user: nil)
5 5 expect(watcher).to_not be_valid
6 6 expect(watcher.errors[:base]).to include("You must specify either a user or an email address")
7 7  
... ... @@ -19,13 +19,13 @@ describe Watcher, type: &#39;model&#39; do
19 19  
20 20 context 'address' do
21 21 it "returns the user's email address if there is a user" do
22   - user = Fabricate(:user, :email => 'foo@bar.com')
23   - watcher = Fabricate(:user_watcher, :user => user)
  22 + user = Fabricate(:user, email: 'foo@bar.com')
  23 + watcher = Fabricate(:user_watcher, user: user)
24 24 expect(watcher.address).to eq 'foo@bar.com'
25 25 end
26 26  
27 27 it "returns the email if there is no user" do
28   - watcher = Fabricate(:watcher, :email => 'widgets@acme.com')
  28 + watcher = Fabricate(:watcher, email: 'widgets@acme.com')
29 29 expect(watcher.address).to eq 'widgets@acme.com'
30 30 end
31 31 end
... ...
spec/requests/notices_controller_spec.rb
1 1 describe "Notices management", type: 'request' do
2   - let(:errbit_app) { Fabricate(:app, :api_key => 'APIKEY') }
  2 + let(:errbit_app) { Fabricate(:app, api_key: 'APIKEY') }
3 3  
4 4 describe "create a new notice" do
5 5 context "with valide notice" do
6 6 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read }
7 7 it 'save a new notice' do
8 8 expect {
9   - post '/notifier_api/v2/notices', :data => xml
  9 + post '/notifier_api/v2/notices', data: xml
10 10 expect(response).to be_success
11 11 }.to change {
12 12 errbit_app.problems.count
... ... @@ -18,7 +18,7 @@ describe &quot;Notices management&quot;, type: &#39;request&#39; do
18 18 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read }
19 19 it 'save a new notice' do
20 20 expect {
21   - post '/notifier_api/v2/notices', :data => xml
  21 + post '/notifier_api/v2/notices', data: xml
22 22 expect(response).to be_success
23 23 }.to change {
24 24 errbit_app.problems.count
... ... @@ -31,7 +31,7 @@ describe &quot;Notices management&quot;, type: &#39;request&#39; do
31 31 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read }
32 32 it 'not save a new notice and return 422' do
33 33 expect {
34   - post '/notifier_api/v2/notices', :data => xml
  34 + post '/notifier_api/v2/notices', data: xml
35 35 expect(response.status).to eq 422
36 36 expect(response.body).to eq "Your API key is unknown"
37 37 }.to_not change(errbit_app.problems, :count)
... ... @@ -42,7 +42,7 @@ describe &quot;Notices management&quot;, type: &#39;request&#39; do
42 42 let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read }
43 43 it 'save a new notice' do
44 44 expect {
45   - get '/notifier_api/v2/notices', :data => xml
  45 + get '/notifier_api/v2/notices', data: xml
46 46 expect(response).to be_success
47 47 }.to change {
48 48 errbit_app.problems.count
... ...
spec/spec_helper.rb
... ... @@ -36,9 +36,9 @@ Mongoid::Tasks::Database.create_indexes
36 36 ActionMailer::Base.delivery_method = :test
37 37  
38 38 RSpec.configure do |config|
39   - config.include Devise::TestHelpers, :type => :controller
40   - config.include Mongoid::Matchers, :type => :model
41   - config.alias_example_to :fit, :focused => true
  39 + config.include Devise::TestHelpers, type: :controller
  40 + config.include Mongoid::Matchers, type: :model
  41 + config.alias_example_to :fit, focused: true
42 42  
43 43 config.before(:each) do
44 44 Mongoid::Config.truncate!
... ...
spec/support/macros.rb
1 1 def it_requires_authentication(options = {})
2 2 default_options = {
3   - :for => {
4   - :index => :get,
5   - :show => :get,
6   - :new => :get,
7   - :create => :post,
8   - :edit => :get,
9   - :update => :put,
10   - :destroy => :delete
  3 + for: {
  4 + index: :get,
  5 + show: :get,
  6 + new: :get,
  7 + create: :post,
  8 + edit: :get,
  9 + update: :put,
  10 + destroy: :delete
11 11 },
12   - :params => { :id => '4c6c760494df2a18cc000015' }
  12 + params: { id: '4c6c760494df2a18cc000015' }
13 13 }
14 14 options.reverse_merge!(default_options)
15 15  
... ... @@ -29,16 +29,16 @@ end
29 29  
30 30 def it_requires_admin_privileges(options = {})
31 31 default_options = {
32   - :for => {
33   - :index => :get,
34   - :show => :get,
35   - :new => :get,
36   - :create => :post,
37   - :edit => :get,
38   - :update => :put,
39   - :destroy => :delete
  32 + for: {
  33 + index: :get,
  34 + show: :get,
  35 + new: :get,
  36 + create: :post,
  37 + edit: :get,
  38 + update: :put,
  39 + destroy: :delete
40 40 },
41   - :params => { :id => 'dummyid' }
  41 + params: { id: 'dummyid' }
42 42 }
43 43 options.reverse_merge!(default_options)
44 44  
... ...
spec/views/apps/index.html.haml_spec.rb
1 1 describe "apps/index.html.haml", type: 'view' do
2 2 before do
3   - app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.zone.now, :revision => "123456789abcdef")])
  3 + app = stub_model(App, deploys: [stub_model(Deploy, created_at: Time.zone.now, revision: "123456789abcdef")])
4 4 allow(view).to receive(:apps).and_return([app])
5 5 allow(controller).to receive(:current_user).and_return(stub_model(User))
6 6 end
... ...
spec/views/apps/new.html.haml_spec.rb
... ... @@ -16,7 +16,7 @@ describe &quot;apps/new.html.haml&quot;, type: &#39;view&#39; do
16 16 it "should confirm the 'cancel' link" do
17 17 render
18 18  
19   - expect(action_bar).to have_selector('a.button', :text => 'cancel')
  19 + expect(action_bar).to have_selector('a.button', text: 'cancel')
20 20 end
21 21 end
22 22  
... ...
spec/views/apps/show.atom.builder_spec.rb
1 1 describe "apps/show.atom.builder", type: 'view' do
2 2 let(:app) { stub_model(App) }
3   - let(:problems) { [stub_model(Problem, :message => 'foo', :app => app)] }
  3 + let(:problems) { [stub_model(Problem, message: 'foo', app: app)] }
4 4  
5 5 before do
6 6 allow(view).to receive(:app).and_return(app)
... ...
spec/views/apps/show.html.haml_spec.rb
... ... @@ -17,7 +17,7 @@ describe &quot;apps/show.html.haml&quot;, type: &#39;view&#39; do
17 17 it "should confirm the 'cancel' link" do
18 18 render
19 19  
20   - expect(action_bar).to have_selector('a.button', :text => 'all errors')
  20 + expect(action_bar).to have_selector('a.button', text: 'all errors')
21 21 end
22 22 end
23 23  
... ...
spec/views/issue_trackers/issue.md.erb_spec.rb
1 1 describe "issue_trackers/issue.md.erb", type: 'view' do
2 2 let(:problem) {
3 3 problem = Fabricate(:problem)
4   - Fabricate(:notice, :err => Fabricate(:err, :problem => problem))
  4 + Fabricate(:notice, err: Fabricate(:err, problem: problem))
5 5 problem
6 6 }
7 7  
... ...
spec/views/issue_trackers/issue.txt.erb_spec.rb
1 1 describe "issue_trackers/issue.txt.erb", type: 'view' do
2 2 let(:problem) {
3 3 problem = Fabricate(:problem)
4   - Fabricate(:notice, :err => Fabricate(:err, :problem => problem))
  4 + Fabricate(:notice, err: Fabricate(:err, problem: problem))
5 5 problem
6 6 }
7 7  
... ...
spec/views/notices/_summary.html.haml_spec.rb
1 1 describe "notices/_summary.html.haml", type: 'view' do
2   - let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') }
  2 + let(:notice) { Fabricate(:notice, framework: 'Rails 3.2.11') }
3 3  
4 4 it "renders application framework" do
5   - render "notices/summary", :notice => notice, :problem => notice.problem
  5 + render "notices/summary", notice: notice, problem: notice.problem
6 6  
7 7 expect(rendered).to have_content('Rails 3.2.11')
8 8 end
... ...
spec/views/notices/_user_attributes.html.haml_spec.rb
... ... @@ -2,13 +2,13 @@ describe &quot;notices/_user_attributes.html.haml&quot;, type: &#39;view&#39; do
2 2 describe 'autolink' do
3 3 let(:notice) do
4 4 user_attributes = { 'foo' => { 'bar' => 'http://example.com' } }
5   - Fabricate(:notice, :user_attributes => user_attributes)
  5 + Fabricate(:notice, user_attributes: user_attributes)
6 6 end
7 7  
8 8 it "renders table with user attributes" do
9 9 assign :app, notice.err.app
10 10  
11   - render "notices/user_attributes", :user => notice.user_attributes
  11 + render "notices/user_attributes", user: notice.user_attributes
12 12 expect(rendered).to have_link('http://example.com')
13 13 end
14 14 end
... ...
spec/views/problems/index.atom.builder_spec.rb
1 1 describe "problems/index.atom.builder", type: 'view' do
2 2 it 'display problem message' do
3   - app = App.new(:new_record => false)
  3 + app = App.new(new_record: false)
4 4 allow(view).to receive(:problems).and_return([Problem.new(
5   - :message => 'foo',
6   - :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)])
  5 + message: 'foo',
  6 + new_record: false, app: app), Problem.new(new_record: false, app: app)])
7 7 render
8 8 expect(rendered).to match('foo')
9 9 end
... ...
spec/views/problems/index.html.haml_spec.rb
1 1 describe "problems/index.html.haml", type: 'view' do
2 2 let(:problem_1) { Fabricate(:problem) }
3   - let(:problem_2) { Fabricate(:problem, :app => problem_1.app) }
  3 + let(:problem_2) { Fabricate(:problem, app: problem_1.app) }
4 4  
5 5 before do
6 6 allow(view).to receive(:selected_problems).and_return([])
... ...
spec/views/problems/show.html.haml_spec.rb
... ... @@ -53,9 +53,9 @@ describe &quot;problems/show.html.haml&quot;, type: &#39;view&#39; do
53 53 def with_issue_tracker(tracker, _problem)
54 54 allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(trackers)
55 55 app.issue_tracker = IssueTrackerDecorator.new(
56   - IssueTracker.new :type_tracker => tracker, :options => {
57   - :api_token => "token token token",
58   - :project_id => "1234"
  56 + IssueTracker.new type_tracker: tracker, options: {
  57 + api_token: "token token token",
  58 + project_id: "1234"
59 59 })
60 60 end
61 61  
... ... @@ -85,7 +85,7 @@ describe &quot;problems/show.html.haml&quot;, type: &#39;view&#39; do
85 85 url = 'http://localhost:3000/problems'
86 86 controller.request.env['HTTP_REFERER'] = url
87 87 render
88   - expect(action_bar).to have_selector("span a.up[href='#{url}']", :text => 'up')
  88 + expect(action_bar).to have_selector("span a.up[href='#{url}']", text: 'up')
89 89 end
90 90  
91 91 it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do
... ... @@ -96,11 +96,11 @@ describe &quot;problems/show.html.haml&quot;, type: &#39;view&#39; do
96 96 allow(view).to receive(:app).and_return(problem.app)
97 97 render
98 98  
99   - expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up')
  99 + expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", text: 'up')
100 100 end
101 101  
102 102 context 'create issue links' do
103   - let(:app) { Fabricate(:app, :github_repo => "test_user/test_repo") }
  103 + let(:app) { Fabricate(:app, github_repo: "test_user/test_repo") }
104 104  
105 105 it 'should allow creating issue for github if application has a github tracker' do
106 106 problem = Fabricate(:problem_with_comments, app: app)
... ... @@ -113,8 +113,8 @@ describe &quot;problems/show.html.haml&quot;, type: &#39;view&#39; do
113 113 end
114 114  
115 115 context "without issue tracker associate on app" do
116   - let(:problem) { Problem.new(:new_record => false, :app => app) }
117   - let(:app) { App.new(:new_record => false) }
  116 + let(:problem) { Problem.new(new_record: false, app: app) }
  117 + let(:app) { App.new(new_record: false) }
118 118  
119 119 it 'not see link to create issue' do
120 120 render
... ... @@ -128,12 +128,12 @@ describe &quot;problems/show.html.haml&quot;, type: &#39;view&#39; do
128 128 end
129 129  
130 130 context "with app having github_repo" do
131   - let(:app) { App.new(:new_record => false, :github_repo => 'foo/bar') }
132   - let(:problem) { Problem.new(:new_record => false, :app => app) }
  131 + let(:app) { App.new(new_record: false, github_repo: 'foo/bar') }
  132 + let(:problem) { Problem.new(new_record: false, app: app) }
133 133  
134 134 before do
135 135 problem.issue_link = nil
136   - user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef')
  136 + user = Fabricate(:user, github_login: 'test_user', github_oauth_token: 'abcdef')
137 137  
138 138 allow(controller).to receive(:current_user).and_return(user)
139 139 end
... ...
spec/views/problems/show.ics.haml_spec.rb
... ... @@ -6,6 +6,6 @@ describe &quot;problems/show.html.ics&quot;, type: &#39;view&#39; do
6 6 end
7 7  
8 8 it 'works' do
9   - render :template => 'problems/show', :formats => [:ics], :handlers => [:haml]
  9 + render template: 'problems/show', formats: [:ics], handlers: [:haml]
10 10 end
11 11 end
... ...
spec/views/users/edit.html.haml_spec.rb
1 1 describe 'users/edit.html.haml', type: 'view' do
2   - let(:user) { stub_model(User, :name => 'shingara') }
  2 + let(:user) { stub_model(User, name: 'shingara') }
3 3 before {
4 4 allow(view).to receive(:current_user).and_return(user)
5 5 allow(view).to receive(:user).and_return(user)
... ...
spec/views/users/index.html.haml_spec.rb
... ... @@ -3,7 +3,7 @@ describe &#39;users/index.html.haml&#39;, type: &#39;view&#39; do
3 3 before {
4 4 allow(view).to receive(:current_user).and_return(user)
5 5 allow(view).to receive(:users).and_return(
6   - Kaminari.paginate_array([user], :total_count => 1).page(1)
  6 + Kaminari.paginate_array([user], total_count: 1).page(1)
7 7 )
8 8 }
9 9 it 'should see users option' do
... ...
spec/views/users/show.html.haml_spec.rb
1 1 describe 'users/show.html.haml', type: 'view' do
2 2 let(:user) do
3   - stub_model(User, :created_at => Time.zone.now, :email => "test@example.com")
  3 + stub_model(User, created_at: Time.zone.now, email: "test@example.com")
4 4 end
5 5  
6 6 before do
... ...