From 46aadb58946834b93a708890227ab93579041014 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 22:33:03 +0100 Subject: [PATCH] Rubocop: hashes: format neatly with symbols for keys and aligned values --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 17 ----------------- Gemfile | 10 +++++----- Rakefile | 2 +- app/controllers/api/v1/notices_controller.rb | 8 ++++---- app/controllers/api/v1/problems_controller.rb | 12 ++++++------ app/controllers/api/v1/stats_controller.rb | 14 +++++++------- app/controllers/api/v3/notices_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/apps_controller.rb | 12 ++++++------ app/controllers/comments_controller.rb | 2 +- app/controllers/deploys_controller.rb | 26 +++++++++++++------------- app/controllers/notices_controller.rb | 16 ++++++++-------- app/controllers/problems_controller.rb | 16 ++++++++-------- app/controllers/users/omniauth_callbacks_controller.rb | 10 +++++----- app/controllers/users_controller.rb | 12 ++++++------ app/controllers/watchers_controller.rb | 2 +- app/decorators/app_decorator.rb | 2 +- app/decorators/backtrace_line_decorator.rb | 8 ++++---- app/decorators/issue_tracker_field_decorator.rb | 4 ++-- app/helpers/application_helper.rb | 4 ++-- app/helpers/apps_helper.rb | 6 +++--- app/helpers/form_helper.rb | 2 +- app/helpers/notices_helper.rb | 2 +- app/helpers/problems_helper.rb | 6 +++--- app/helpers/sort_helper.rb | 2 +- app/interactors/problem_destroy.rb | 6 +++--- app/interactors/resolved_problem_clearer.rb | 2 +- app/mailers/mailer.rb | 12 ++++++------ app/models/app.rb | 49 ++++++++++++++++++++++++++----------------------- app/models/backtrace.rb | 2 +- app/models/comment.rb | 10 +++++----- app/models/deploy.rb | 8 ++++---- app/models/err.rb | 4 ++-- app/models/error_report.rb | 16 ++++++++-------- app/models/issue_tracker.rb | 14 +++++++------- app/models/notice.rb | 18 +++++++++--------- app/models/notification_service.rb | 22 +++++++++++----------- app/models/notification_services/campfire_service.rb | 14 +++++++------- app/models/notification_services/flowdock_service.rb | 8 ++++---- app/models/notification_services/gtalk_service.rb | 24 ++++++++++++------------ app/models/notification_services/hipchat_service.rb | 20 ++++++++++---------- app/models/notification_services/hoiio_service.rb | 14 +++++++------- app/models/notification_services/hubot_service.rb | 10 +++++----- app/models/notification_services/pushover_service.rb | 10 +++++----- app/models/notification_services/slack_service.rb | 52 ++++++++++++++++++++++++++-------------------------- app/models/notification_services/webhook_service.rb | 8 ++++---- app/models/problem.rb | 76 ++++++++++++++++++++++++++++++++++++++-------------------------------------- app/models/user.rb | 30 +++++++++++++++--------------- app/models/watcher.rb | 2 +- config/application.rb | 2 +- config/initializers/action_mailer.rb | 16 ++++++++-------- config/initializers/devise.rb | 12 ++++++------ config/initializers/ssl_enforcer.rb | 4 ++-- config/routes.rb | 24 ++++++++++++------------ db/migrate/201510290041_extract_issue_tracker.rb | 2 +- db/seeds.rb | 2 +- lib/airbrake_api/v3/notice_parser.rb | 16 ++++++++-------- lib/hoptoad/v2.rb | 18 +++++++++--------- lib/overrides/hoptoad_notifier/hoptoad_notifier.rb | 2 +- lib/tasks/errbit/database.rake | 6 +++--- lib/tasks/errbit/demo.rake | 54 +++++++++++++++++++++++++++--------------------------- lib/tasks/heroku/cron.rake | 2 +- spec/acceptance/acceptance_helper.rb | 4 ++-- spec/acceptance/app_regenerate_api_key_spec.rb | 28 ++++++++++++++-------------- spec/acceptance/sign_in_with_github_spec.rb | 4 ++-- spec/controllers/api/v1/notices_controller_spec.rb | 18 +++++++++--------- spec/controllers/api/v1/problems_controller_spec.rb | 34 +++++++++++++++++----------------- spec/controllers/apps_controller_spec.rb | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- spec/controllers/comments_controller_spec.rb | 8 ++++---- spec/controllers/deploys_controller_spec.rb | 20 ++++++++++---------- spec/controllers/devise_sessions_controller_spec.rb | 4 ++-- spec/controllers/notices_controller_spec.rb | 24 ++++++++++++------------ spec/controllers/problems_controller_spec.rb | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------- spec/controllers/site_config_controller_spec.rb | 4 ++-- spec/controllers/users/omniauth_callbacks_controller_spec.rb | 8 ++++---- spec/controllers/users_controller_spec.rb | 60 ++++++++++++++++++++++++++++++------------------------------ spec/controllers/watchers_controller_spec.rb | 4 ++-- spec/decorators/app_decorator_spec.rb | 10 +++++----- spec/decorators/backtrace_decorator_spec.rb | 12 ++++++------ spec/decorators/backtrace_line_decorator_spec.rb | 4 ++-- spec/decorators/issue_tracker_decorator_spec.rb | 4 ++-- spec/decorators/issue_tracker_field_decorator.rb | 2 +- spec/decorators/issue_tracker_type_decorator_spec.rb | 6 +++--- spec/decorators/watcher_decorator_spec.rb | 4 ++-- spec/errbit_plugin/mock_issue_tracker.rb | 4 ++-- spec/fabricators/app_fabricator.rb | 8 ++++---- spec/fabricators/backtrace_fabricator.rb | 4 ++-- spec/fabricators/comment_fabricator.rb | 2 +- spec/fabricators/issue_tracker_fabricator.rb | 4 ++-- spec/fabricators/notification_service_fabricator.rb | 8 ++++---- spec/fabricators/problem_fabricator.rb | 12 ++++++------ spec/fabricators/user_fabricator.rb | 2 +- spec/helpers/problems_helper_spec.rb | 8 ++++---- spec/initializers/action_mailer_spec.rb | 10 +++++----- spec/initializers/devise_spec.rb | 8 ++++---- spec/interactors/problem_destroy_spec.rb | 44 ++++++++++++++++++++++---------------------- spec/interactors/problem_merge_spec.rb | 8 ++++---- spec/interactors/resolved_problem_clearer_spec.rb | 10 +++++----- spec/interactors/user_destroy_spec.rb | 6 +++--- spec/lib/configurator_spec.rb | 2 +- spec/mailers/mailer_spec.rb | 16 ++++++++-------- spec/models/app_spec.rb | 70 +++++++++++++++++++++++++++++++++++----------------------------------- spec/models/comment_observer_spec.rb | 2 +- spec/models/comment_spec.rb | 24 ++++++++++++------------ spec/models/deploy_observer_spec.rb | 6 +++--- spec/models/deploy_spec.rb | 20 ++++++++++---------- spec/models/err_spec.rb | 4 ++-- spec/models/error_report_spec.rb | 14 +++++++------- spec/models/notice_observer_spec.rb | 24 ++++++++++++------------ spec/models/notice_spec.rb | 18 +++++++++--------- spec/models/notification_service/campfire_service_spec.rb | 2 +- spec/models/notification_service/flowdock_service_spec.rb | 4 ++-- spec/models/notification_service/gtalk_service_spec.rb | 6 +++--- spec/models/notification_service/hoiio_service_spec.rb | 2 +- spec/models/notification_service/hubot_service_spec.rb | 4 ++-- spec/models/notification_service/notification_service_spec.rb | 2 +- spec/models/notification_service/pushover_service_spec.rb | 2 +- spec/models/notification_service/slack_service_spec.rb | 50 +++++++++++++++++++++++++------------------------- spec/models/notification_service/webhook_service_spec.rb | 4 ++-- spec/models/problem_spec.rb | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- spec/models/user_spec.rb | 16 ++++++++-------- spec/models/watcher_spec.rb | 8 ++++---- spec/requests/notices_controller_spec.rb | 10 +++++----- spec/spec_helper.rb | 6 +++--- spec/support/macros.rb | 36 ++++++++++++++++++------------------ spec/views/apps/index.html.haml_spec.rb | 2 +- spec/views/apps/new.html.haml_spec.rb | 2 +- spec/views/apps/show.atom.builder_spec.rb | 2 +- spec/views/apps/show.html.haml_spec.rb | 2 +- spec/views/issue_trackers/issue.md.erb_spec.rb | 2 +- spec/views/issue_trackers/issue.txt.erb_spec.rb | 2 +- spec/views/notices/_summary.html.haml_spec.rb | 4 ++-- spec/views/notices/_user_attributes.html.haml_spec.rb | 4 ++-- spec/views/problems/index.atom.builder_spec.rb | 6 +++--- spec/views/problems/index.html.haml_spec.rb | 2 +- spec/views/problems/show.html.haml_spec.rb | 22 +++++++++++----------- spec/views/problems/show.ics.haml_spec.rb | 2 +- spec/views/users/edit.html.haml_spec.rb | 2 +- spec/views/users/index.html.haml_spec.rb | 2 +- spec/views/users/show.html.haml_spec.rb | 2 +- 141 files changed, 947 insertions(+), 958 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1699a46..e1b437b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -36,6 +36,9 @@ Style/DotPosition: Style/IndentHash: EnforcedStyle: consistent +Style/AlignHash: + EnforcedColonStyle: table + Style/SpaceAroundOperators: MultiSpaceAllowedForOperators: - '=' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7dac329..6debcd1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -53,17 +53,6 @@ Rails/Validation: - 'app/models/problem.rb' - 'app/models/user.rb' -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -Style/AlignHash: - Exclude: - - 'app/models/app.rb' - - 'spec/controllers/apps_controller_spec.rb' - - 'spec/controllers/comments_controller_spec.rb' - - 'spec/controllers/problems_controller_spec.rb' - - 'spec/models/problem_spec.rb' - # Offense count: 105 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. @@ -141,12 +130,6 @@ Style/FormatString: Style/GuardClause: Enabled: false -# Offense count: 1168 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. -Style/HashSyntax: - Enabled: false - # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. diff --git a/Gemfile b/Gemfile index 50eb6dc..e386759 100644 --- a/Gemfile +++ b/Gemfile @@ -29,8 +29,8 @@ gem 'htmlentities' gem 'kaminari', '>= 0.14.1' gem 'mongoid', '5.0.0' gem 'mongoid_rails_migrations' -gem 'rack-ssl', :require => 'rack/ssl' # force SSL -gem 'rack-ssl-enforcer', :require => false +gem 'rack-ssl', require: 'rack/ssl' # force SSL +gem 'rack-ssl-enforcer', require: false gem 'rails_autolink' gem 'useragent' @@ -44,7 +44,7 @@ gem 'campy' # Hipchat gem 'hipchat' # Google Talk -gem 'xmpp4r', :require => ["xmpp4r", "xmpp4r/muc"] +gem 'xmpp4r', require: ["xmpp4r", "xmpp4r/muc"] # Hoiio (SMS) gem 'hoi' # Pushover (iOS Push notifications) @@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby' gem 'json', platform: 'jruby' group :development, :test do - gem 'airbrake', :require => false + gem 'airbrake', require: false gem 'pry-rails' gem 'pry-byebug', platforms: [:mri] gem 'quiet_assets' @@ -103,7 +103,7 @@ group :heroku, :production do gem 'unicorn', require: false, platform: 'ruby' end -gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows +gem 'therubyracer', platform: :ruby # C Ruby (MRI) or Rubinius, but NOT Windows gem 'sass-rails' gem 'uglifier' # We can't upgrade because not compatible to jquery >= 1.9. diff --git a/Rakefile b/Rakefile index 478a3f2..33231be 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ Rails.application.load_tasks begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) - task :default => :spec + task default: :spec rescue LoadError warn "Notice: no rspec tasks available in this environment" end diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index c6df8ba..e9a82cf 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController if params.key?(:start_date) && params.key?(:end_date) start_date = Time.zone.parse(params[:start_date]).utc end_date = Time.zone.parse(params[:end_date]).utc - query = { :created_at => { "$lte" => end_date, "$gte" => start_date } } + query = { created_at: { "$lte" => end_date, "$gte" => start_date } } end results = benchmark("[api/v1/notices_controller] query time") do - Notice.where(query).with(:consistency => :strong).only(fields).to_a + Notice.where(query).with(consistency: :strong).only(fields).to_a end respond_to do |format| - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path - format.xml { render :xml => results } + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path + format.xml { render xml: results } end end end diff --git a/app/controllers/api/v1/problems_controller.rb b/app/controllers/api/v1/problems_controller.rb index 8d15a83..5a94033 100644 --- a/app/controllers/api/v1/problems_controller.rb +++ b/app/controllers/api/v1/problems_controller.rb @@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController end respond_to do |format| - format.any(:html, :json) { render :json => result } # render JSON if no extension specified on path - format.xml { render :xml => result } + format.any(:html, :json) { render json: result } # render JSON if no extension specified on path + format.xml { render xml: result } end end @@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController if params.key?(:start_date) && params.key?(:end_date) start_date = Time.parse(params[:start_date]).utc end_date = Time.parse(params[:end_date]).utc - query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ :resolved_at => nil }, { :resolved_at => { "$gte" => start_date } }] } + query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ resolved_at: nil }, { resolved_at: { "$gte" => start_date } }] } end results = benchmark("[api/v1/problems_controller/index] query time") do - Problem.where(query).with(:consistency => :strong).only(FIELDS).to_a + Problem.where(query).with(consistency: :strong).only(FIELDS).to_a end respond_to do |format| - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path - format.xml { render :xml => results } + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path + format.xml { render xml: results } end end end diff --git a/app/controllers/api/v1/stats_controller.rb b/app/controllers/api/v1/stats_controller.rb index 081ccd1..ed8f977 100644 --- a/app/controllers/api/v1/stats_controller.rb +++ b/app/controllers/api/v1/stats_controller.rb @@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController end stats = { - :name => @app.name, - :id => @app.id, - :last_error_time => @last_error_time, - :unresolved_errors => @app.unresolved_count + name: @app.name, + id: @app.id, + last_error_time: @last_error_time, + unresolved_errors: @app.unresolved_count } respond_to do |format| - format.any(:html, :json) { render :json => JSON.dump(stats) } # render JSON if no extension specified on path - format.xml { render :xml => stats } + format.any(:html, :json) { render json: JSON.dump(stats) } # render JSON if no extension specified on path + format.xml { render xml: stats } end end protected def require_api_key_or_authenticate_user! if params[:api_key].present? - if (@app = App.where(:api_key => params[:api_key]).first) + if (@app = App.where(api_key: params[:api_key]).first) return true end end diff --git a/app/controllers/api/v3/notices_controller.rb b/app/controllers/api/v3/notices_controller.rb index ab3f4f5..74743f4 100644 --- a/app/controllers/api/v3/notices_controller.rb +++ b/app/controllers/api/v3/notices_controller.rb @@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController if report.should_keep? report.generate_notice! render json: { - id: report.notice.id, + id: report.notice.id, url: app_problem_url( report.app, report.error.problem_id) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8f72c89..00c03ac 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base before_action :authenticate_user! before_action :set_time_zone - rescue_from ActionController::RedirectBackError, :with => :redirect_to_root + rescue_from ActionController::RedirectBackError, with: :redirect_to_root class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy def assign_attributes? diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 2457e54..167a04d 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -1,9 +1,9 @@ class AppsController < ApplicationController include ProblemsSearcher - before_action :require_admin!, :except => [:index, :show] - before_action :parse_email_at_notices_or_set_default, :only => [:create, :update] - before_action :parse_notice_at_notices_or_set_default, :only => [:create, :update] + before_action :require_admin!, except: [:index, :show] + before_action :parse_email_at_notices_or_set_default, only: [:create, :update] + before_action :parse_notice_at_notices_or_set_default, only: [:create, :update] respond_to :html expose(:app_scope) { App } @@ -55,7 +55,7 @@ class AppsController < ApplicationController def create initialize_subclassed_notification_service if app.save - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.create.success') } + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.create.success') } else flash[:error] = I18n.t('controllers.apps.flash.create.error') render :new @@ -65,7 +65,7 @@ class AppsController < ApplicationController def update initialize_subclassed_notification_service if app.save - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.update.success') } + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.update.success') } else flash[:error] = I18n.t('controllers.apps.flash.update.error') render :edit @@ -78,7 +78,7 @@ class AppsController < ApplicationController def destroy if app.destroy - redirect_to apps_url, :flash => { :success => I18n.t('controllers.apps.flash.destroy.success') } + redirect_to apps_url, flash: { success: I18n.t('controllers.apps.flash.destroy.success') } else flash[:error] = I18n.t('controllers.apps.flash.destroy.error') render :show diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index af97ffa..92f5a9a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -3,7 +3,7 @@ class CommentsController < ApplicationController before_action :find_problem def create - @comment = Comment.new(comment_params.merge(:user_id => current_user.id)) + @comment = Comment.new(comment_params.merge(user_id: current_user.id)) if @comment.valid? @problem.comments << @comment @problem.save diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb index 17130c9..3a22d0d 100644 --- a/app/controllers/deploys_controller.rb +++ b/app/controllers/deploys_controller.rb @@ -1,13 +1,13 @@ class DeploysController < ApplicationController - protect_from_forgery :except => :create + protect_from_forgery except: :create - skip_before_action :verify_authenticity_token, :only => :create - skip_before_action :authenticate_user!, :only => :create + skip_before_action :verify_authenticity_token, only: :create + skip_before_action :authenticate_user!, only: :create def create @app = App.find_by_api_key!(params[:api_key]) @deploy = @app.deploys.create!(default_deploy || heroku_deploy) - render :xml => @deploy + render xml: @deploy end def index @@ -21,11 +21,11 @@ private def default_deploy if params[:deploy] { - :username => params[:deploy][:local_username], - :environment => params[:deploy][:rails_env], - :repository => params[:deploy][:scm_repository], - :revision => params[:deploy][:scm_revision], - :message => params[:deploy][:message] + username: params[:deploy][:local_username], + environment: params[:deploy][:rails_env], + repository: params[:deploy][:scm_repository], + revision: params[:deploy][:scm_revision], + message: params[:deploy][:message] } end end @@ -33,10 +33,10 @@ private # handle Heroku's HTTP post deployhook format def heroku_deploy { - :username => params[:user], - :environment => params[:rack_env].try(:downcase) || params[:app], - :repository => "git@heroku.com:#{params[:app]}.git", - :revision => params[:head] + username: params[:user], + environment: params[:rack_env].try(:downcase) || params[:app], + repository: "git@heroku.com:#{params[:app]}.git", + revision: params[:head] } end end diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index e66a1b6..d7b18df 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -4,7 +4,7 @@ class NoticesController < ApplicationController skip_before_action :authenticate_user!, only: :create skip_before_action :verify_authenticity_token, only: :create - rescue_from ParamsError, :with => :bad_params + rescue_from ParamsError, with: :bad_params def create # params[:data] if the notice came from a GET request, raw_post if it came via POST @@ -13,18 +13,18 @@ class NoticesController < ApplicationController if report.valid? if report.should_keep? report.generate_notice! - api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| - xml.url locate_url(report.notice.id, :host => Errbit::Config.host) + api_xml = report.notice.to_xml(only: false, methods: [:id]) do |xml| + xml.url locate_url(report.notice.id, host: Errbit::Config.host) end - render :xml => api_xml + render xml: api_xml else - render :text => "Notice for old app version ignored" + render text: "Notice for old app version ignored" end else - render :text => "Your API key is unknown", :status => 422 + render text: "Your API key is unknown", status: 422 end rescue Nokogiri::XML::SyntaxError - render :text => 'The provided XML was not well-formed', :status => 422 + render text: 'The provided XML was not well-formed', status: 422 end # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem. @@ -45,6 +45,6 @@ private end def bad_params(exception) - render :text => exception.message, :status => :bad_request + render text: exception.message, status: :bad_request end end diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index 6d31ab0..75cf81b 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -7,12 +7,12 @@ class ProblemsController < ApplicationController include ProblemsSearcher - before_action :need_selected_problem, :only => [ + before_action :need_selected_problem, only: [ :resolve_several, :unresolve_several, :unmerge_several ] expose(:app_scope) { - params[:app_id] ? App.where(:_id => params[:app_id]) : App.all + params[:app_id] ? App.where(_id: params[:app_id]) : App.all } expose(:app) { @@ -80,13 +80,13 @@ class ProblemsController < ApplicationController def resolve_several selected_problems.each(&:resolve!) - flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, :count => selected_problems.count)} been resolved." + flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, count: selected_problems.count)} been resolved." redirect_to :back end def unresolve_several selected_problems.each(&:unresolve!) - flash[:success] = "#{I18n.t(:n_errs_have, :count => selected_problems.count)} been unresolved." + flash[:success] = "#{I18n.t(:n_errs_have, count: selected_problems.count)} been unresolved." redirect_to :back end @@ -100,26 +100,26 @@ class ProblemsController < ApplicationController flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge') else ProblemMerge.new(selected_problems).merge - flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', :nb => selected_problems.count) + flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', nb: selected_problems.count) end redirect_to :back end def unmerge_several all = selected_problems.map(&:unmerge!).flatten - flash[:success] = "#{I18n.t(:n_errs_have, :count => all.length)} been unmerged." + flash[:success] = "#{I18n.t(:n_errs_have, count: all.length)} been unmerged." redirect_to :back end def destroy_several nb_problem_destroy = ProblemDestroy.execute(selected_problems) - flash[:notice] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." + flash[:notice] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted." redirect_to :back end def destroy_all nb_problem_destroy = ProblemDestroy.execute(app.problems) - flash[:success] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." + flash[:success] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted." redirect_to :back rescue ActionController::RedirectBackError redirect_to app_path(app) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 1c3d50f..d5d560e 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def github github_login = env["omniauth.auth"].extra.raw_info.login github_token = env["omniauth.auth"].credentials.token - github_user = User.where(:github_login => github_login).first + github_user = User.where(github_login: github_login).first github_site_title = Errbit::Config.github_site_title if github_user.nil? && (github_org_id = Errbit::Config.github_org_id) @@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController elsif github_user # Store OAuth token update_user_with_github_attributes(github_user, github_login, github_token) - flash[:success] = I18n.t "devise.omniauth_callbacks.success", :kind => github_site_title - sign_in_and_redirect github_user, :event => :authentication + flash[:success] = I18n.t "devise.omniauth_callbacks.success", kind: github_site_title + sign_in_and_redirect github_user, event: :authentication else flash[:error] = "There are no authorized users with #{github_site_title} login '#{github_login}'. Please ask an administrator to register your user account." redirect_to new_user_session_path @@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController private def update_user_with_github_attributes(user, login, token) user.update_attributes( - :github_login => login, - :github_oauth_token => token + github_login: login, + github_oauth_token: token ) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0fe7805..22fe852 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,10 +1,10 @@ class UsersController < ApplicationController respond_to :html - before_action :require_admin!, :except => [:edit, :update] - before_action :require_user_edit_priviledges, :only => [:edit, :update] + before_action :require_admin!, except: [:edit, :update] + before_action :require_user_edit_priviledges, only: [:edit, :update] - expose(:user, :attributes => :user_params) + expose(:user, attributes: :user_params) expose(:users) { User.all.page(params[:page]).per(current_user.per_page) } @@ -24,7 +24,7 @@ class UsersController < ApplicationController def update if user.update_attributes(user_params) - flash[:success] = I18n.t('controllers.users.flash.update.success', :name => user.name) + flash[:success] = I18n.t('controllers.users.flash.update.success', name: user.name) redirect_to user_path(user) else render :edit @@ -41,13 +41,13 @@ class UsersController < ApplicationController flash[:error] = I18n.t('controllers.users.flash.destroy.error') else UserDestroy.new(user).destroy - flash[:success] = I18n.t('controllers.users.flash.destroy.success', :name => user.name) + flash[:success] = I18n.t('controllers.users.flash.destroy.success', name: user.name) end redirect_to users_path end def unlink_github - user.update_attributes :github_login => nil, :github_oauth_token => nil + user.update_attributes github_login: nil, github_oauth_token: nil redirect_to user_path(user) end diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 3fb8f32..b7f0b68 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -6,7 +6,7 @@ class WatchersController < ApplicationController end def destroy - watcher = app.watchers.where(:user_id => params[:id]).first + watcher = app.watchers.where(user_id: params[:id]).first app.watchers.delete(watcher) flash[:success] = t('.success', app: app.name) redirect_to app_path(app) diff --git a/app/decorators/app_decorator.rb b/app/decorators/app_decorator.rb index 4f662cb..b9100ac 100644 --- a/app/decorators/app_decorator.rb +++ b/app/decorators/app_decorator.rb @@ -1,6 +1,6 @@ class AppDecorator < Draper::Decorator decorates_association :watchers - decorates_association :issue_tracker, :with => IssueTrackerDecorator + decorates_association :issue_tracker, with: IssueTrackerDecorator delegate_all def email_at_notices diff --git a/app/decorators/backtrace_line_decorator.rb b/app/decorators/backtrace_line_decorator.rb index dc91169..3fad36a 100644 --- a/app/decorators/backtrace_line_decorator.rb +++ b/app/decorators/backtrace_line_decorator.rb @@ -67,25 +67,25 @@ private def link_to_hosted_javascript(app, text) if app.asset_host? - h.link_to(text, "#{app.asset_host}/#{file_relative}", :target => '_blank') + h.link_to(text, "#{app.asset_host}/#{file_relative}", target: '_blank') end end def link_to_github(app, text = nil) return unless app.github_repo? href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] - h.link_to(text || file_name, href, :target => '_blank') + h.link_to(text || file_name, href, target: '_blank') end def link_to_bitbucket(app, text = nil) return unless app.bitbucket_repo? href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] - h.link_to(text || file_name, href, :target => '_blank') + h.link_to(text || file_name, href, target: '_blank') end def link_to_issue_tracker_file(app, text = nil) return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file) href = app.issue_tracker.url_to_file(file_relative, number) - h.link_to(text || file_name, href, :target => '_blank') + h.link_to(text || file_name, href, target: '_blank') end end diff --git a/app/decorators/issue_tracker_field_decorator.rb b/app/decorators/issue_tracker_field_decorator.rb index ca7efa6..0e8e002 100644 --- a/app/decorators/issue_tracker_field_decorator.rb +++ b/app/decorators/issue_tracker_field_decorator.rb @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator < Draper::Decorator def input(form, issue_tracker) form.send(input_field, key.to_s, - :placeholder => field_info[:placeholder], - :value => issue_tracker.options[key.to_s]) + placeholder: field_info[:placeholder], + value: issue_tracker.options[key.to_s]) end private def input_field diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1925fc5..e8b38c3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,7 @@ module ApplicationHelper event.dtend = notice.created_at.utc + 60.minutes event.organizer = notice.server_environment && notice.server_environment["hostname"] event.location = notice.project_root - event.url = app_problem_url(:app_id => notice.problem.app.id, :id => notice.problem) + event.url = app_problem_url(app_id: notice.problem.app.id, id: notice.problem) end end end.to_s @@ -58,7 +58,7 @@ module ApplicationHelper percent = 100.0 / total.to_f rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \ sort { |a, b| b[0] <=> a[0] } - render "problems/tally_table", :rows => rows + render "problems/tally_table", rows: rows end def head(collection) diff --git a/app/helpers/apps_helper.rb b/app/helpers/apps_helper.rb index de3ed43..3efea3e 100644 --- a/app/helpers/apps_helper.rb +++ b/app/helpers/apps_helper.rb @@ -2,11 +2,11 @@ module AppsHelper def link_to_copy_attributes_from_other_app if App.count > 1 html = link_to('copy settings from another app', '#', - :class => 'button copy_config') + class: 'button copy_config') html << select("duplicate", "app", App.all.asc(:name).reject { |a| a == @app }. - collect { |p| [p.name, p.id] }, { :include_blank => "[choose app]" }, - { :class => "choose_other_app", :style => "display: none;" }) + collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" }, + { class: "choose_other_app", style: "display: none;" }) return html end end diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 66aadc8..2de6b5b 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -2,7 +2,7 @@ module FormHelper def errors_for(document) return unless document.errors.any? - content_tag(:div, :class => 'error-messages') do + content_tag(:div, class: 'error-messages') do body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.') body + content_tag(:ul) do document.errors.full_messages.inject('') do |errs, msg| diff --git a/app/helpers/notices_helper.rb b/app/helpers/notices_helper.rb index d4a326c..052aca0 100644 --- a/app/helpers/notices_helper.rb +++ b/app/helpers/notices_helper.rb @@ -1,6 +1,6 @@ # encoding: utf-8 module NoticesHelper def notice_atom_summary(notice) - render "notices/atom_entry", :notice => notice + render "notices/atom_entry", notice: notice end end diff --git a/app/helpers/problems_helper.rb b/app/helpers/problems_helper.rb index c96ae55..f14fb03 100644 --- a/app/helpers/problems_helper.rb +++ b/app/helpers/problems_helper.rb @@ -6,21 +6,21 @@ module ProblemsHelper def truncated_problem_message(problem) unless (msg = problem.message).blank? # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule - truncate(msg, :length => 300, :escape => false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe + truncate(msg, length: 300, escape: false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe end end def gravatar_tag(email, options = {}) return nil unless email.present? - image_tag gravatar_url(email, options), :alt => email, :class => 'gravatar' + image_tag gravatar_url(email, options), alt: email, class: 'gravatar' end def gravatar_url(email, options = {}) return nil unless email.present? default_options = { - :d => Errbit::Config.gravatar_default + d: Errbit::Config.gravatar_default } options.reverse_merge! default_options params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? } diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb index 0561eef..1b7f75b 100644 --- a/app/helpers/sort_helper.rb +++ b/app/helpers/sort_helper.rb @@ -6,7 +6,7 @@ module SortHelper order = (current && (params_order == "asc")) ? "desc" : "asc" url = request.path + "?sort=#{field}&order=#{order}" options = {} - options.merge!(:class => "current #{order}") if current + options.merge!(class: "current #{order}") if current link_to(name, url, options) end end diff --git a/app/interactors/problem_destroy.rb b/app/interactors/problem_destroy.rb index f8d89e4..21abafe 100644 --- a/app/interactors/problem_destroy.rb +++ b/app/interactors/problem_destroy.rb @@ -36,11 +36,11 @@ private end def delete_errs - Notice.delete_all(:err_id => { '$in' => errs_id }) - Err.delete_all(:_id => { '$in' => errs_id }) + Notice.delete_all(err_id: { '$in' => errs_id }) + Err.delete_all(_id: { '$in' => errs_id }) end def delete_comments - Comment.delete_all(:_id => { '$in' => comments_id }) + Comment.delete_all(_id: { '$in' => comments_id }) end end diff --git a/app/interactors/resolved_problem_clearer.rb b/app/interactors/resolved_problem_clearer.rb index fffe1ca..9a7a029 100644 --- a/app/interactors/resolved_problem_clearer.rb +++ b/app/interactors/resolved_problem_clearer.rb @@ -26,6 +26,6 @@ private end def repair_database - Mongoid.default_client.command :repairDatabase => 1 + Mongoid.default_client.command repairDatabase: 1 end end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index e8108d3..a8a745f 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -23,8 +23,8 @@ class Mailer < ActionMailer::Base 'Environment' => @notice.environment_name, 'Error-Id' => @notice.err_id - mail :to => @app.notification_recipients, - :subject => "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" + mail to: @app.notification_recipients, + subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" end def deploy_notification(deploy) @@ -36,8 +36,8 @@ class Mailer < ActionMailer::Base 'Deploy-Revision' => @deploy.revision, 'Deploy-User' => @deploy.username - mail :to => @app.notification_recipients, - :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" + mail to: @app.notification_recipients, + subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" end def comment_notification(comment) @@ -54,8 +54,8 @@ class Mailer < ActionMailer::Base 'Problem-Id' => @problem.id, 'Comment-Author' => @user.name - mail :to => recipients, - :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" + mail to: recipients, + subject: "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" end private def errbit_headers(header) diff --git a/app/models/app.rb b/app/models/app.rb index 6de9262..801c426 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -3,51 +3,54 @@ class App include Mongoid::Document include Mongoid::Timestamps - field :name, :type => String + field :name, type: String field :api_key field :github_repo field :bitbucket_repo field :asset_host field :repository_branch field :current_app_version - field :resolve_errs_on_deploy, :type => Boolean, :default => false - field :notify_all_users, :type => Boolean, :default => false - field :notify_on_errs, :type => Boolean, :default => true - field :notify_on_deploys, :type => Boolean, :default => false - field :email_at_notices, :type => Array, :default => Errbit::Config.email_at_notices + field :resolve_errs_on_deploy, type: Boolean, default: false + field :notify_all_users, type: Boolean, default: false + field :notify_on_errs, type: Boolean, default: true + field :notify_on_deploys, type: Boolean, default: false + field :email_at_notices, type: Array, default: Errbit::Config.email_at_notices # Some legacy apps may have string as key instead of BSON::ObjectID # identity :type => String field :_id, - type: String, + type: String, pre_processed: true, - default: -> { BSON::ObjectId.new.to_s } + default: -> { BSON::ObjectId.new.to_s } embeds_many :watchers embeds_many :deploys - embeds_one :issue_tracker, :class_name => 'IssueTracker' + embeds_one :issue_tracker, class_name: 'IssueTracker' embeds_one :notification_service embeds_one :notice_fingerprinter, autobuild: true - has_many :problems, :inverse_of => :app, :dependent => :destroy + has_many :problems, inverse_of: :app, dependent: :destroy - before_validation :generate_api_key, :on => :create + before_validation :generate_api_key, on: :create before_save :normalize_github_repo after_update :store_cached_attributes_on_problems validates_presence_of :name, :api_key - validates_uniqueness_of :name, :allow_blank => true - validates_uniqueness_of :api_key, :allow_blank => true + validates_uniqueness_of :name, allow_blank: true + validates_uniqueness_of :api_key, allow_blank: true validates_associated :watchers validates_associated :notice_fingerprinter validate :check_issue_tracker - accepts_nested_attributes_for :watchers, :allow_destroy => true, - :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } - accepts_nested_attributes_for :issue_tracker, :allow_destroy => true, - :reject_if => proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) } - accepts_nested_attributes_for :notification_service, :allow_destroy => true, - :reject_if => proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } + accepts_nested_attributes_for :watchers, + allow_destroy: true, + reject_if: proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } + accepts_nested_attributes_for :issue_tracker, + allow_destroy: true, + reject_if: proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) } + accepts_nested_attributes_for :notification_service, + allow_destroy: true, + reject_if: proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } accepts_nested_attributes_for :notice_fingerprinter scope :watched_by, ->(user) do @@ -71,7 +74,7 @@ class App problem = problems.create!( error_class: attrs[:error_class], environment: attrs[:environment], - app_name: name + app_name: name ) problem.errs.create!(attrs.slice(:fingerprint, :problem_id)) end @@ -82,7 +85,7 @@ class App end def self.find_by_api_key!(key) - find_by(:api_key => key) + find_by(api_key: key) end def last_deploy_at @@ -151,7 +154,7 @@ class App # Copy app attributes from another app. def copy_attributes_from(app_id) - if (copy_app = App.where(:_id => app_id).first) + if (copy_app = App.where(_id: app_id).first) # Copy fields (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| send("#{k}=", copy_app.send(k)) @@ -191,7 +194,7 @@ class App protected def store_cached_attributes_on_problems - Problem.where(:app_id => id).update_all( + Problem.where(app_id: id).update_all( app_name: name ) end diff --git a/app/models/backtrace.rb b/app/models/backtrace.rb index e155bc5..fae8b95 100644 --- a/app/models/backtrace.rb +++ b/app/models/backtrace.rb @@ -8,7 +8,7 @@ class Backtrace field :fingerprint field :lines - index :fingerprint => 1 + index fingerprint: 1 def self.find_or_create(lines) fingerprint = generate_fingerprint(lines) diff --git a/app/models/comment.rb b/app/models/comment.rb index e639afe..b2a0def 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -5,14 +5,14 @@ class Comment after_create :increase_counter_cache before_destroy :decrease_counter_cache - after_create :deliver_email, :if => :emailable? + after_create :deliver_email, if: :emailable? - field :body, :type => String - index(:user_id => 1) + field :body, type: String + index(user_id: 1) - belongs_to :err, :class_name => "Problem" + belongs_to :err, class_name: "Problem" belongs_to :user - delegate :app, :to => :err + delegate :app, to: :err validates_presence_of :body diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 545af1a..38b05f1 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -8,11 +8,11 @@ class Deploy field :revision field :message - index(:created_at => -1) + index(created_at: -1) - embedded_in :app, :inverse_of => :deploys + embedded_in :app, inverse_of: :deploys - after_create :resolve_app_errs, :if => :should_resolve_app_errs? + after_create :resolve_app_errs, if: :should_resolve_app_errs? after_create :store_cached_attributes_on_problems after_create :deliver_email @@ -33,7 +33,7 @@ protected end def store_cached_attributes_on_problems - Problem.where(:app_id => app.id).update_all( + Problem.where(app_id: app.id).update_all( last_deploy_at: created_at ) end diff --git a/app/models/err.rb b/app/models/err.rb index 4be899a..572f58c 100644 --- a/app/models/err.rb +++ b/app/models/err.rb @@ -12,9 +12,9 @@ class Err index fingerprint: 1 belongs_to :problem - has_many :notices, :inverse_of => :err, :dependent => :destroy + has_many :notices, inverse_of: :err, dependent: :destroy validates_presence_of :problem_id, :fingerprint - delegate :app, :resolved?, :to => :problem + delegate :app, :resolved?, to: :problem end diff --git a/app/models/error_report.rb b/app/models/error_report.rb index 037d22a..9ae2b1a 100644 --- a/app/models/error_report.rb +++ b/app/models/error_report.rb @@ -61,15 +61,15 @@ class ErrorReport def make_notice @notice = Notice.new( - app: app, - message: message, - error_class: error_class, - backtrace: backtrace, - request: request, + app: app, + message: message, + error_class: error_class, + backtrace: backtrace, + request: request, server_environment: server_environment, - notifier: notifier, - user_attributes: user_attributes, - framework: framework + notifier: notifier, + user_attributes: user_attributes, + framework: framework ) end diff --git a/app/models/issue_tracker.rb b/app/models/issue_tracker.rb index bc74a7d..7d0a43e 100644 --- a/app/models/issue_tracker.rb +++ b/app/models/issue_tracker.rb @@ -2,10 +2,10 @@ class IssueTracker include Mongoid::Document include Mongoid::Timestamps - embedded_in :app, :inverse_of => :issue_tracker + embedded_in :app, inverse_of: :issue_tracker - field :type_tracker, :type => String - field :options, :type => Hash, :default => {} + field :type_tracker, type: String + field :options, type: Hash, default: {} validate :validate_tracker @@ -15,7 +15,7 @@ class IssueTracker klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker # TODO: we need to find out a better way to pass those config to the issue tracker klass.new(options.merge( - github_repo: app.try(:github_repo), + github_repo: app.try(:github_repo), bitbucket_repo: app.try(:bitbucket_repo) )) end @@ -32,7 +32,7 @@ class IssueTracker end end - delegate :configured?, :to => :tracker - delegate :create_issue, :to => :tracker - delegate :url, :to => :tracker + delegate :configured?, to: :tracker + delegate :create_issue, to: :tracker + delegate :url, to: :tracker end diff --git a/app/models/notice.rb b/app/models/notice.rb index b4dd7a5..fe539e0 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -5,21 +5,21 @@ class Notice include Mongoid::Timestamps field :message - field :server_environment, :type => Hash - field :request, :type => Hash - field :notifier, :type => Hash - field :user_attributes, :type => Hash + field :server_environment, type: Hash + field :request, type: Hash + field :notifier, type: Hash + field :user_attributes, type: Hash field :framework field :error_class - delegate :lines, :to => :backtrace, :prefix => true - delegate :problem, :to => :err + delegate :lines, to: :backtrace, prefix: true + delegate :problem, to: :err belongs_to :app belongs_to :err - belongs_to :backtrace, :index => true + belongs_to :backtrace, index: true - index(:created_at => 1) - index(:err_id => 1, :created_at => 1, :_id => 1) + index(created_at: 1) + index(err_id: 1, created_at: 1, _id: 1) before_save :sanitize before_destroy :problem_recache diff --git a/app/models/notification_service.rb b/app/models/notification_service.rb index 8cb3877..6f0386d 100644 --- a/app/models/notification_service.rb +++ b/app/models/notification_service.rb @@ -5,22 +5,22 @@ class NotificationService default_url_options[:host] = ActionMailer::Base.default_url_options[:host] default_url_options[:port] = ActionMailer::Base.default_url_options[:port] - field :room_id, :type => String - field :user_id, :type => String - field :service_url, :type => String - field :service, :type => String - field :api_token, :type => String - field :subdomain, :type => String - field :sender_name, :type => String - field :notify_at_notices, :type => Array, :default => Errbit::Config.notify_at_notices - embedded_in :app, :inverse_of => :notification_service + field :room_id, type: String + field :user_id, type: String + field :service_url, type: String + field :service, type: String + field :api_token, type: String + field :subdomain, type: String + field :sender_name, type: String + field :notify_at_notices, type: Array, default: Errbit::Config.notify_at_notices + embedded_in :app, inverse_of: :notification_service validate :check_params if Errbit::Config.per_app_notify_at_notices FIELDS = [[:notify_at_notices, - { :placeholder => 'comma separated numbers or simply 0 for every notice', - :label => 'notify on errors (0 for all errors)' + { placeholder: 'comma separated numbers or simply 0 for every notice', + label: 'notify on errors (0 for all errors)' } ]] else diff --git a/app/models/notification_services/campfire_service.rb b/app/models/notification_services/campfire_service.rb index 7bdc078..e918d1d 100644 --- a/app/models/notification_services/campfire_service.rb +++ b/app/models/notification_services/campfire_service.rb @@ -3,16 +3,16 @@ if defined? Campy LABEL = "campfire" FIELDS += [ [:subdomain, { - :label => "Subdomain", - :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" + label: "Subdomain", + placeholder: "subdomain from http://{{subdomain}}.campfirenow.com" }], [:api_token, { - :label => "API Token", - :placeholder => "123456789abcdef123456789abcdef" + label: "API Token", + placeholder: "123456789abcdef123456789abcdef" }], [:room_id, { - :label => "Room ID", - :placeholder => "123456" + label: "Room ID", + placeholder: "123456" }] ] @@ -28,7 +28,7 @@ if defined? Campy def create_notification(problem) # build the campfire client - campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id) + campy = Campy::Room.new(account: subdomain, token: api_token, room_id: room_id) # post the issue to the campfire room campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" end diff --git a/app/models/notification_services/flowdock_service.rb b/app/models/notification_services/flowdock_service.rb index a63ebbd..9efe667 100644 --- a/app/models/notification_services/flowdock_service.rb +++ b/app/models/notification_services/flowdock_service.rb @@ -4,8 +4,8 @@ if defined? Flowdock FIELDS += [ [ :api_token, { - :label => 'Flow API Token', - :placeholder => '123456789abcdef123456789abcdefgh' + label: 'Flow API Token', + placeholder: '123456789abcdef123456789abcdefgh' } ] ] @@ -21,10 +21,10 @@ if defined? Flowdock end def create_notification(problem) - flow = Flowdock::Flow.new(:api_token => api_token, :source => "Errbit", :from => { :name => "Errbit", :address => ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' }) + flow = Flowdock::Flow.new(api_token: api_token, source: "Errbit", from: { name: "Errbit", address: ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' }) subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}" url = app_problem_url problem.app, problem - flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) + flow.push_to_team_inbox(subject: subject, content: content(problem, url), project: project_name(problem), link: url) end private diff --git a/app/models/notification_services/gtalk_service.rb b/app/models/notification_services/gtalk_service.rb index b8daa0f..e68f719 100644 --- a/app/models/notification_services/gtalk_service.rb +++ b/app/models/notification_services/gtalk_service.rb @@ -2,28 +2,28 @@ class NotificationServices::GtalkService < NotificationService LABEL = "gtalk" FIELDS += [ [:subdomain, { - :placeholder => "username@example.com", - :label => "Username" + placeholder: "username@example.com", + label: "Username" }], [:api_token, { - :placeholder => "password", - :label => "Password" + placeholder: "password", + label: "Password" }], [:user_id, { - :placeholder => "touser@example.com, anotheruser@example.com", - :label => "Send To User(s)" + placeholder: "touser@example.com, anotheruser@example.com", + label: "Send To User(s)" }, :room_id], [:room_id, { - :placeholder => "toroom@conference.example.com", - :label => "Send To Room (one only)" + placeholder: "toroom@conference.example.com", + label: "Send To Room (one only)" }, :user_id], [:service, { - :placeholder => "talk.google.com", - :label => "Jabber Service" + placeholder: "talk.google.com", + label: "Jabber Service" }], [:service_url, { - :placeholder => "http://www.google.com/talk/", - :label => "Link To Jabber Service" + placeholder: "http://www.google.com/talk/", + label: "Link To Jabber Service" }] ] diff --git a/app/models/notification_services/hipchat_service.rb b/app/models/notification_services/hipchat_service.rb index 4852c7f..f17fa04 100644 --- a/app/models/notification_services/hipchat_service.rb +++ b/app/models/notification_services/hipchat_service.rb @@ -3,20 +3,20 @@ if defined? HipChat LABEL = 'hipchat' FIELDS += [ [:service, { - :placeholder => "'v1' (admin API token) or 'v2' (account API token)", - :label => "HipChat API version" + placeholder: "'v1' (admin API token) or 'v2' (account API token)", + label: "HipChat API version" }], [:service_url, { - :placeholder => "Optional, leave empty for HipChat.com", - :label => "Custom HipChat Server URL" + placeholder: "Optional, leave empty for HipChat.com", + label: "Custom HipChat Server URL" }], [:api_token, { - :placeholder => "API token", - :label => "API token" + placeholder: "API token", + label: "API token" }], [:room_id, { - :placeholder => "Room name", - :label => "Room name" + placeholder: "Room name", + label: "Room name" }] ] MANDATORY_FIELDS = [:service, :api_token, :room_id] @@ -45,11 +45,11 @@ if defined? HipChat   Times occurred: #{problem.notices_count} MSG - options = { :api_version => self[:service] } + options = { api_version: self[:service] } options[:server_url] = self[:service_url] if service_url.present? client = HipChat::Client.new(api_token, options) - client[room_id].send('Errbit', message, :color => 'red', :notify => true) + client[room_id].send('Errbit', message, color: 'red', notify: true) end end end diff --git a/app/models/notification_services/hoiio_service.rb b/app/models/notification_services/hoiio_service.rb index 4cd369b..0aee007 100644 --- a/app/models/notification_services/hoiio_service.rb +++ b/app/models/notification_services/hoiio_service.rb @@ -2,16 +2,16 @@ class NotificationServices::HoiioService < NotificationService LABEL = "hoiio" FIELDS += [ [:api_token, { - :placeholder => "App ID", - :label => "App ID" + placeholder: "App ID", + label: "App ID" }], [:subdomain, { - :placeholder => "Access Token", - :label => "Access Token" + placeholder: "Access Token", + label: "Access Token" }], [:room_id, { - :placeholder => "+6511111111, +6511111111", - :label => "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code." + placeholder: "+6511111111, +6511111111", + label: "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code." }] ] @@ -35,7 +35,7 @@ class NotificationServices::HoiioService < NotificationService # send sms room_id.split(',').each do |number| - sms.send :dest => number, :msg => "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}" + sms.send dest: number, msg: "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}" end end end diff --git a/app/models/notification_services/hubot_service.rb b/app/models/notification_services/hubot_service.rb index a6c0336..83f8023 100644 --- a/app/models/notification_services/hubot_service.rb +++ b/app/models/notification_services/hubot_service.rb @@ -2,12 +2,12 @@ class NotificationServices::HubotService < NotificationService LABEL = "hubot" FIELDS += [ [:api_token, { - :placeholder => 'http://hubot.example.org:8080/hubot/say', - :label => 'Hubot URL' + placeholder: 'http://hubot.example.org:8080/hubot/say', + label: 'Hubot URL' }], [:room_id, { - :placeholder => '#dev', - :label => 'Room where Hubot should notify' + placeholder: '#dev', + label: 'Room where Hubot should notify' }] ] @@ -26,6 +26,6 @@ class NotificationServices::HubotService < NotificationService end def create_notification(problem) - HTTParty.post(url, :body => { :message => message_for_hubot(problem), :room => room_id }) + HTTParty.post(url, body: { message: message_for_hubot(problem), room: room_id }) end end diff --git a/app/models/notification_services/pushover_service.rb b/app/models/notification_services/pushover_service.rb index 52ca738..be6a55e 100644 --- a/app/models/notification_services/pushover_service.rb +++ b/app/models/notification_services/pushover_service.rb @@ -2,12 +2,12 @@ class NotificationServices::PushoverService < NotificationService LABEL = "pushover" FIELDS += [ [:api_token, { - :placeholder => "User Key", - :label => "User Key" + placeholder: "User Key", + label: "User Key" }], [:subdomain, { - :placeholder => "Application API Token", - :label => "Application API Token" + placeholder: "Application API Token", + label: "Application API Token" }] ] @@ -26,6 +26,6 @@ class NotificationServices::PushoverService < NotificationService notification = Rushover::Client.new(subdomain) # send push notification to pushover - 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") + 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") end end diff --git a/app/models/notification_services/slack_service.rb b/app/models/notification_services/slack_service.rb index 571f278..5f3d68e 100644 --- a/app/models/notification_services/slack_service.rb +++ b/app/models/notification_services/slack_service.rb @@ -2,8 +2,8 @@ class NotificationServices::SlackService < NotificationService LABEL = "slack" FIELDS += [ [:service_url, { - :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', - :label => 'Hook URL' + placeholder: 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', + label: 'Hook URL' }] ] @@ -19,41 +19,41 @@ class NotificationServices::SlackService < NotificationService def post_payload(problem) { - :attachments => [ + attachments: [ { - :fallback => message_for_slack(problem), - :pretext => "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", - :color => "#D00000", - :fields => [ + fallback: message_for_slack(problem), + pretext: "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", + color: "#D00000", + fields: [ { - :title => "Environment", - :value => problem.environment, - :short => false + title: "Environment", + value: problem.environment, + short: false }, { - :title => "Location", - :value => problem.where, - :short => false + title: "Location", + value: problem.where, + short: false }, { - :title => "Message", - :value => problem.message.to_s, - :short => false + title: "Message", + value: problem.message.to_s, + short: false }, { - :title => "First Noticed", - :value => problem.first_notice_at, - :short => false + title: "First Noticed", + value: problem.first_notice_at, + short: false }, { - :title => "Last Noticed", - :value => problem.last_notice_at, - :short => false + title: "Last Noticed", + value: problem.last_notice_at, + short: false }, { - :title => "Times Occurred", - :value => problem.notices_count, - :short => false + title: "Times Occurred", + value: problem.notices_count, + short: false } ] } @@ -62,7 +62,7 @@ class NotificationServices::SlackService < NotificationService end def create_notification(problem) - HTTParty.post(service_url, :body => post_payload(problem), :headers => { 'Content-Type' => 'application/json' }) + HTTParty.post(service_url, body: post_payload(problem), headers: { 'Content-Type' => 'application/json' }) end def configured? diff --git a/app/models/notification_services/webhook_service.rb b/app/models/notification_services/webhook_service.rb index f28ce08..8f749ca 100644 --- a/app/models/notification_services/webhook_service.rb +++ b/app/models/notification_services/webhook_service.rb @@ -2,8 +2,8 @@ class NotificationServices::WebhookService < NotificationService LABEL = "webhook" FIELDS = [ [:api_token, { - :placeholder => 'URL to receive a POST request when an error occurs', - :label => 'URL' + placeholder: 'URL to receive a POST request when an error occurs', + label: 'URL' }] ] @@ -14,10 +14,10 @@ class NotificationServices::WebhookService < NotificationService end def message_for_webhook(problem) - { :problem => { :url => problem_url(problem) }.merge(problem.as_json).to_json } + { problem: { url: problem_url(problem) }.merge(problem.as_json).to_json } end def create_notification(problem) - HTTParty.post(api_token, :body => message_for_webhook(problem)) + HTTParty.post(api_token, body: message_for_webhook(problem)) end end diff --git a/app/models/problem.rb b/app/models/problem.rb index c7c5ef2..4f52eab 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -7,59 +7,59 @@ class Problem include Mongoid::Timestamps CACHED_NOTICE_ATTRIBUTES = { - messages: :message, - hosts: :host, + messages: :message, + hosts: :host, user_agents: :user_agent_string }.freeze - field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => proc { Time.zone.now } - field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => proc { Time.zone.now } - field :last_deploy_at, :type => Time - field :resolved, :type => Boolean, :default => false - field :resolved_at, :type => Time - field :issue_link, :type => String - field :issue_type, :type => String + field :last_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } + field :first_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } + field :last_deploy_at, type: Time + field :resolved, type: Boolean, default: false + field :resolved_at, type: Time + field :issue_link, type: String + field :issue_type, type: String # Cached fields - field :app_name, :type => String - field :notices_count, :type => Integer, :default => 0 + field :app_name, type: String + field :notices_count, type: Integer, default: 0 field :message field :environment field :error_class field :where - field :user_agents, :type => Hash, :default => {} - field :messages, :type => Hash, :default => {} - field :hosts, :type => Hash, :default => {} - field :comments_count, :type => Integer, :default => 0 - - index :app_id => 1 - index :app_name => 1 - index :message => 1 - index :last_notice_at => 1 - index :first_notice_at => 1 - index :last_deploy_at => 1 - index :resolved_at => 1 - index :notices_count => 1 + field :user_agents, type: Hash, default: {} + field :messages, type: Hash, default: {} + field :hosts, type: Hash, default: {} + field :comments_count, type: Integer, default: 0 + + index app_id: 1 + index app_name: 1 + index message: 1 + index last_notice_at: 1 + index first_notice_at: 1 + index last_deploy_at: 1 + index resolved_at: 1 + index notices_count: 1 index({ error_class: "text", - where: "text", - message: "text", - app_name: "text", + where: "text", + message: "text", + app_name: "text", environment: "text" }, default_language: "english") belongs_to :app - has_many :errs, :inverse_of => :problem, :dependent => :destroy - has_many :comments, :inverse_of => :err, :dependent => :destroy + has_many :errs, inverse_of: :problem, dependent: :destroy + has_many :comments, inverse_of: :err, dependent: :destroy validates_presence_of :environment before_create :cache_app_attributes before_save :truncate_message - scope :resolved, -> { where(:resolved => true) } - scope :unresolved, -> { where(:resolved => false) } + scope :resolved, -> { where(resolved: true) } + scope :unresolved, -> { where(resolved: false) } scope :ordered, -> { order_by(:last_notice_at.desc) } scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } @@ -69,12 +69,12 @@ class Problem if fetch_all all else - where(:resolved => false) + where(resolved: false) end end def self.in_env(env) - env.present? ? where(:environment => env) : scoped + env.present? ? where(environment: env) : scoped end def self.cache_notice(id, notice) @@ -164,8 +164,8 @@ class Problem Rails.application.routes.url_helpers.app_problem_url( app, self, - :host => Errbit::Config.host, - :port => Errbit::Config.port + host: Errbit::Config.host, + port: Errbit::Config.port ) end @@ -174,11 +174,11 @@ class Problem end def resolve! - self.update_attributes!(:resolved => true, :resolved_at => Time.zone.now) + self.update_attributes!(resolved: true, resolved_at: Time.zone.now) end def unresolve! - self.update_attributes!(:resolved => false, :resolved_at => nil) + self.update_attributes!(resolved: false, resolved_at: nil) end def unresolved? @@ -194,7 +194,7 @@ class Problem end def unmerge! - attrs = { :error_class => error_class, :environment => environment } + attrs = { error_class: error_class, environment: environment } problem_errs = errs.to_a # associate and return all the problems diff --git a/app/models/user.rb b/app/models/user.rb index e7f559c..eaaa56a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,37 +9,37 @@ class User field :github_login field :github_oauth_token field :name - field :admin, :type => Boolean, :default => false - field :per_page, :type => Fixnum, :default => PER_PAGE - field :time_zone, :default => "UTC" + field :admin, type: Boolean, default: false + field :per_page, type: Fixnum, default: PER_PAGE + field :time_zone, default: "UTC" ## Devise field ### Database Authenticatable - field :encrypted_password, :type => String + field :encrypted_password, type: String ### Recoverable - field :reset_password_token, :type => String - field :reset_password_sent_at, :type => Time + field :reset_password_token, type: String + field :reset_password_sent_at, type: Time ### Rememberable - field :remember_created_at, :type => Time + field :remember_created_at, type: Time ### Trackable - field :sign_in_count, :type => Integer - field :current_sign_in_at, :type => Time - field :last_sign_in_at, :type => Time - field :current_sign_in_ip, :type => String - field :last_sign_in_ip, :type => String + field :sign_in_count, type: Integer + field :current_sign_in_at, type: Time + field :last_sign_in_at, type: Time + field :current_sign_in_ip, type: String + field :last_sign_in_ip, type: String ### Token_authenticatable - field :authentication_token, :type => String + field :authentication_token, type: String - index :authentication_token => 1 + index authentication_token: 1 before_save :ensure_authentication_token validates_presence_of :name - validates_uniqueness_of :github_login, :allow_nil => true + validates_uniqueness_of :github_login, allow_nil: true if Errbit::Config.user_has_username field :username diff --git a/app/models/watcher.rb b/app/models/watcher.rb index 1a4bcdb..f155e32 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -4,7 +4,7 @@ class Watcher field :email - embedded_in :app, :inverse_of => :watchers + embedded_in :app, inverse_of: :watchers belongs_to :user validate :ensure_user_or_email diff --git a/config/application.rb b/config/application.rb index cc0f182..e67375a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,7 +39,7 @@ module Errbit config.generators do |g| g.orm :mongoid g.template_engine :haml - g.test_framework :rspec, :fixture => false + g.test_framework :rspec, fixture: false g.fixture_replacement :fabrication end diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb index af08dc9..036d07e 100644 --- a/config/initializers/action_mailer.rb +++ b/config/initializers/action_mailer.rb @@ -2,12 +2,12 @@ if Errbit::Config.email_delivery_method == :smtp ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { - :address => Errbit::Config.smtp_address, - :port => Errbit::Config.smtp_port, - :authentication => Errbit::Config.smtp_authentication, - :user_name => Errbit::Config.smtp_user_name, - :password => Errbit::Config.smtp_password, - :domain => Errbit::Config.smtp_domain + address: Errbit::Config.smtp_address, + port: Errbit::Config.smtp_port, + authentication: Errbit::Config.smtp_authentication, + user_name: Errbit::Config.smtp_user_name, + password: Errbit::Config.smtp_password, + domain: Errbit::Config.smtp_domain } end @@ -23,8 +23,8 @@ end # Set config specific values (ActionMailer::Base.default_url_options ||= {}).tap do |default| options_from_config = { - host: Errbit::Config.host, - port: Errbit::Config.port, + host: Errbit::Config.host, + port: Errbit::Config.port, protocol: Errbit::Config.protocol }.select { |_k, v| v } diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d30f961..a29d24f 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -237,12 +237,12 @@ Devise.setup do |config| if Errbit::Config.github_authentication || Rails.env.test? github_options = { - :scope => Errbit::Config.github_access_scope.join(','), - :skip_info => true, - :client_options => { - :site => Errbit::Config.github_api_url, - :authorize_url => "#{Errbit::Config.github_url}/login/oauth/authorize", - :token_url => "#{Errbit::Config.github_url}/login/oauth/access_token" + scope: Errbit::Config.github_access_scope.join(','), + skip_info: true, + client_options: { + site: Errbit::Config.github_api_url, + authorize_url: "#{Errbit::Config.github_url}/login/oauth/authorize", + token_url: "#{Errbit::Config.github_url}/login/oauth/access_token" } } diff --git a/config/initializers/ssl_enforcer.rb b/config/initializers/ssl_enforcer.rb index 6ce44ed..d064638 100644 --- a/config/initializers/ssl_enforcer.rb +++ b/config/initializers/ssl_enforcer.rb @@ -1,8 +1,8 @@ # Enforce SSL connections, if configured if Errbit::Config.enforce_ssl require 'rack/ssl-enforcer' - ActionMailer::Base.default_url_options.merge!(:protocol => 'https://') + ActionMailer::Base.default_url_options.merge!(protocol: 'https://') Rails.application.configure do - config.middleware.use Rack::SslEnforcer, :except => %r{^/deploys} + config.middleware.use Rack::SslEnforcer, except: %r{^/deploys} end end diff --git a/config/routes.rb b/config/routes.rb index 5603eb5..2464fdd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,26 +1,26 @@ Rails.application.routes.draw do - devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } + devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" } # Hoptoad Notifier Routes match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] get '/locate/:id' => 'notices#locate', :as => :locate post '/deploys.txt' => 'deploys#create' - resources :notices, :only => [:show] - resources :deploys, :only => [:show] + resources :notices, only: [:show] + resources :deploys, only: [:show] resources :users do member do delete :unlink_github end end - resources :site_config, :only => [:index] do + resources :site_config, only: [:index] do collection do put :update end end - resources :problems, :only => [:index] do + resources :problems, only: [:index] do collection do post :destroy_several post :resolve_several @@ -34,7 +34,7 @@ Rails.application.routes.draw do resources :apps do resources :problems do resources :notices - resources :comments, :only => [:create, :destroy] + resources :comments, only: [:create, :destroy] collection do post :destroy_all @@ -47,8 +47,8 @@ Rails.application.routes.draw do delete :unlink_issue end end - resources :deploys, :only => [:index] - resources :watchers, :only => [:destroy, :update] + resources :deploys, only: [:index] + resources :watchers, only: [:destroy, :update] member do post :regenerate_api_key end @@ -56,9 +56,9 @@ Rails.application.routes.draw do namespace :api do namespace :v1 do - resources :problems, :only => [:index, :show], :defaults => { :format => 'json' } - resources :notices, :only => [:index], :defaults => { :format => 'json' } - resources :stats, :only => [], :defaults => { :format => 'json' } do + resources :problems, only: [:index, :show], defaults: { format: 'json' } + resources :notices, only: [:index], defaults: { format: 'json' } + resources :stats, only: [], defaults: { format: 'json' } do collection do get :app end @@ -69,5 +69,5 @@ Rails.application.routes.draw do match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post] match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post] - root :to => 'apps#index' + root to: 'apps#index' end diff --git a/db/migrate/201510290041_extract_issue_tracker.rb b/db/migrate/201510290041_extract_issue_tracker.rb index 4d2a74d..b18efc4 100644 --- a/db/migrate/201510290041_extract_issue_tracker.rb +++ b/db/migrate/201510290041_extract_issue_tracker.rb @@ -35,7 +35,7 @@ class ExtractIssueTracker < Mongoid::Migration } App.where({ _id: app.id }).update({ - "$set" => { :issue_tracker => tracker } + "$set" => { issue_tracker: tracker } }) end end diff --git a/db/seeds.rb b/db/seeds.rb index 159b13b..31e861c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -15,7 +15,7 @@ puts "-- password: #{admin_pass}" puts "" puts "Be sure to note down these credentials now!" -user = User.find_or_initialize_by(:email => admin_email) +user = User.find_or_initialize_by(email: admin_email) user.name = 'Errbit Admin' user.password = admin_pass diff --git a/lib/airbrake_api/v3/notice_parser.rb b/lib/airbrake_api/v3/notice_parser.rb index 5eae5ac..b53fb0c 100644 --- a/lib/airbrake_api/v3/notice_parser.rb +++ b/lib/airbrake_api/v3/notice_parser.rb @@ -11,14 +11,14 @@ module AirbrakeApi def report attributes = { - error_class: error['type'], - message: error['message'], - backtrace: backtrace, - request: request, + error_class: error['type'], + message: error['message'], + backtrace: backtrace, + request: request, server_environment: server_environment, - api_key: params['key'].present? ? params['key'] : params['project_id'], - notifier: params['notifier'], - user_attributes: user_attributes + api_key: params['key'].present? ? params['key'] : params['project_id'], + notifier: params['notifier'], + user_attributes: user_attributes } ErrorReport.new(attributes) @@ -35,7 +35,7 @@ module AirbrakeApi (error['backtrace'] || []).map do |backtrace_line| { method: backtrace_line['function'], - file: backtrace_line['file'], + file: backtrace_line['file'], number: backtrace_line['line'], column: backtrace_line['column'] } diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index efcb19f..e326c3b 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -53,18 +53,18 @@ module Hoptoad def self.for_errbit_api(notice) { - :error_class => notice['error']['class'] || notice['error']['key'], - :message => notice['error']['message'], - :backtrace => notice['error']['backtrace']['line'], + error_class: notice['error']['class'] || notice['error']['key'], + message: notice['error']['message'], + backtrace: notice['error']['backtrace']['line'], - :request => notice['request'], - :server_environment => notice['server-environment'], + request: notice['request'], + server_environment: notice['server-environment'], - :api_key => notice['api-key'], - :notifier => notice['notifier'], + api_key: notice['api-key'], + notifier: notice['notifier'], # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem - :user_attributes => notice['current-user'] || notice['user-attributes'] || {}, - :framework => notice['framework'] + user_attributes: notice['current-user'] || notice['user-attributes'] || {}, + framework: notice['framework'] } end end diff --git a/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb b/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb index 516b0ac..594db63 100644 --- a/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb +++ b/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb @@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do private def send_notice(notice) # Log the error internally if we are not in a development environment. if configuration.public? - app = App.find_or_initialize_by(:name => "Self.Errbit") + app = App.find_or_initialize_by(name: "Self.Errbit") app.github_repo = "errbit/errbit" app.save! notice.send("api_key=", app.api_key) diff --git a/lib/tasks/errbit/database.rake b/lib/tasks/errbit/database.rake index 6d30d7c..6f1d727 100644 --- a/lib/tasks/errbit/database.rake +++ b/lib/tasks/errbit/database.rake @@ -1,17 +1,17 @@ namespace :errbit do desc "Updates cached attributes on Problem" - task :problem_recache => :environment do + task problem_recache: :environment do ProblemRecacher.run end desc "Delete resolved errors from the database. (Useful for limited heroku databases)" - task :clear_resolved => :environment do + task clear_resolved: :environment do require 'resolved_problem_clearer' puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database." end desc "Regenerate fingerprints" - task :notice_refingerprint => :environment do + task notice_refingerprint: :environment do NoticeRefingerprinter.run ProblemRecacher.run end diff --git a/lib/tasks/errbit/demo.rake b/lib/tasks/errbit/demo.rake index 142acc0..8712cdd 100644 --- a/lib/tasks/errbit/demo.rake +++ b/lib/tasks/errbit/demo.rake @@ -1,31 +1,31 @@ namespace :errbit do desc "Add a demo app & errors to your database (for testing)" - task :demo => :environment do + task demo: :environment do require 'fabrication' - app = Fabricate(:app, :name => "Demo App #{Time.zone.now.strftime('%N')}") + app = Fabricate(:app, name: "Demo App #{Time.zone.now.strftime('%N')}") # Report a number of errors for the application app.problems.delete_all errors = [{ - :error_class => "ArgumentError", - :message => "wrong number of arguments (3 for 0)" + error_class: "ArgumentError", + message: "wrong number of arguments (3 for 0)" }, { - :error_class => "RuntimeError", - :message => "Could not find Red October" + error_class: "RuntimeError", + message: "Could not find Red October" }, { - :error_class => "TypeError", - :message => "can't convert Symbol into Integer" + error_class: "TypeError", + message: "can't convert Symbol into Integer" }, { - :error_class => "ActiveRecord::RecordNotFound", - :message => "could not find a record with the id 5" + error_class: "ActiveRecord::RecordNotFound", + message: "could not find a record with the id 5" }, { - :error_class => "NameError", - :message => "uninitialized constant Tag" + error_class: "NameError", + message: "uninitialized constant Tag" }, { - :error_class => "SyntaxError", - :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" + error_class: "SyntaxError", + message: "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" }] RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8] @@ -44,28 +44,28 @@ namespace :errbit do errors.each do |error_template| rand(34).times do ErrorReport.new(error_template.reverse_merge({ - :api_key => app.api_key, - :error_class => "StandardError", - :message => "Oops. Something went wrong!", - :backtrace => random_backtrace, - :request => { + api_key: app.api_key, + error_class: "StandardError", + message: "Oops. Something went wrong!", + backtrace: random_backtrace, + request: { 'component' => 'main', 'action' => 'error', 'url' => "http://example.com/post/#{[111, 222, 333].sample}" }, - :server_environment => { 'environment-name' => Rails.env.to_s }, - :notifier => { :name => "seeds.rb" }, - :app_user => { - :id => "1234", - :username => "jsmith", - :name => "John Smith", - :url => "http://www.example.com/users/jsmith" + server_environment: { 'environment-name' => Rails.env.to_s }, + notifier: { name: "seeds.rb" }, + app_user: { + id: "1234", + username: "jsmith", + name: "John Smith", + url: "http://www.example.com/users/jsmith" } })).generate_notice! end end - Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app))) + Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app))) puts "=== Created demo app: '#{app.name}', with example errors." end end diff --git a/lib/tasks/heroku/cron.rake b/lib/tasks/heroku/cron.rake index 2be802f..1a7f1a9 100644 --- a/lib/tasks/heroku/cron.rake +++ b/lib/tasks/heroku/cron.rake @@ -1,4 +1,4 @@ desc "This task is called by the Heroku cron add-on" -task :cron => :environment do +task cron: :environment do Rake::Task["errbit:db:clear_resolved"].invoke end diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb index 30321d2..044993c 100644 --- a/spec/acceptance/acceptance_helper.rb +++ b/spec/acceptance/acceptance_helper.rb @@ -22,7 +22,7 @@ end def log_in(user) visit '/' - fill_in :user_email, :with => user.email - fill_in :user_password, :with => 'password' + fill_in :user_email, with: user.email + fill_in :user_password, with: 'password' click_on I18n.t('devise.sessions.new.sign_in') end diff --git a/spec/acceptance/app_regenerate_api_key_spec.rb b/spec/acceptance/app_regenerate_api_key_spec.rb index 7ed482c..f3eb7c9 100644 --- a/spec/acceptance/app_regenerate_api_key_spec.rb +++ b/spec/acceptance/app_regenerate_api_key_spec.rb @@ -4,7 +4,7 @@ feature "Regeneration api_Key" do let(:app) { Fabricate(:app) } let(:admin) { Fabricate(:admin) } let(:user) { - Fabricate(:user_watcher, :app => app).user + Fabricate(:user_watcher, app: app).user } before do @@ -37,7 +37,7 @@ end feature "Create an application" do let(:admin) { Fabricate(:admin) } let(:user) { - Fabricate(:user_watcher, :app => app).user + Fabricate(:user_watcher, app: app).user } before do @@ -48,37 +48,37 @@ feature "Create an application" do visit '/' log_in admin click_on I18n.t('apps.index.new_app') - fill_in 'app_name', :with => 'My new app' + fill_in 'app_name', with: 'My new app' click_on I18n.t('apps.new.add_app') page.has_content?(I18n.t('controllers.apps.flash.create.success')) - expect(App.where(:name => 'My new app').count).to eq 1 - expect(App.where(:name => 'My new app 2').count).to eq 0 + expect(App.where(name: 'My new app').count).to eq 1 + expect(App.where(name: 'My new app 2').count).to eq 0 click_on I18n.t('shared.navigation.apps') click_on 'My new app' click_link I18n.t('apps.show.edit') - fill_in 'app_name', :with => 'My new app 2' + fill_in 'app_name', with: 'My new app 2' click_on I18n.t('apps.edit.update') page.has_content?(I18n.t('controllers.apps.flash.update.success')) - expect(App.where(:name => 'My new app').count).to eq 0 - expect(App.where(:name => 'My new app 2').count).to eq 1 + expect(App.where(name: 'My new app').count).to eq 0 + expect(App.where(name: 'My new app 2').count).to eq 1 end - scenario "create an apps with issue tracker and edit it", :js => true do + scenario "create an apps with issue tracker and edit it", js: true do visit '/' log_in admin click_on I18n.t('apps.index.new_app') - fill_in 'app_name', :with => 'My new app' + fill_in 'app_name', with: 'My new app' find('.label_radio.github').click fill_in 'app_github_repo', with: 'foo/bar' within ".github.tracker_params" do - fill_in 'app_issue_tracker_attributes_options_username', :with => 'token' - fill_in 'app_issue_tracker_attributes_options_password', :with => 'pass' + fill_in 'app_issue_tracker_attributes_options_username', with: 'token' + fill_in 'app_issue_tracker_attributes_options_password', with: 'pass' end click_on I18n.t('apps.new.add_app') expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true - app = App.where(:name => 'My new app').first + app = App.where(name: 'My new app').first expect(app.issue_tracker.type_tracker).to eql 'github' expect(app.issue_tracker.options['username']).to eql 'token' expect(app.issue_tracker.options['password']).to eql 'pass' @@ -89,7 +89,7 @@ feature "Create an application" do find('.issue_tracker .label_radio.none').click click_on I18n.t('apps.edit.update') expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true - app = App.where(:name => 'My new app').first + app = App.where(name: 'My new app').first expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker end end diff --git a/spec/acceptance/sign_in_with_github_spec.rb b/spec/acceptance/sign_in_with_github_spec.rb index 8e88313..5ba849b 100644 --- a/spec/acceptance/sign_in_with_github_spec.rb +++ b/spec/acceptance/sign_in_with_github_spec.rb @@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper' feature 'Sign in with GitHub' do background do allow(Errbit::Config).to receive(:github_authentication).and_return(true) - Fabricate(:user, :github_login => 'nashby') + Fabricate(:user, github_login: 'nashby') end scenario 'log in via GitHub with recognized user' do @@ -11,7 +11,7 @@ feature 'Sign in with GitHub' do visit '/' click_link 'Sign in with GitHub' - expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", :kind => 'GitHub') + expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", kind: 'GitHub') end scenario 'reject unrecognized user if authenticating via GitHub' do diff --git a/spec/controllers/api/v1/notices_controller_spec.rb b/spec/controllers/api/v1/notices_controller_spec.rb index 46db92e..6f0b2d0 100644 --- a/spec/controllers/api/v1/notices_controller_spec.rb +++ b/spec/controllers/api/v1/notices_controller_spec.rb @@ -6,30 +6,30 @@ describe Api::V1::NoticesController, type: 'controller' do describe "GET /api/v1/notices" do before do - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-21')) - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-30')) + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01')) + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01')) + Fabricate(:notice, created_at: Time.zone.parse('2012-08-21')) + Fabricate(:notice, created_at: Time.zone.parse('2012-08-30')) end it "should return JSON if JSON is requested" do - get :index, :auth_token => @user.authentication_token, :format => "json" + get :index, auth_token: @user.authentication_token, format: "json" expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) end it "should return XML if XML is requested" do - get :index, :auth_token => @user.authentication_token, :format => "xml" + get :index, auth_token: @user.authentication_token, format: "xml" expect(Nokogiri::XML(response.body).errors).to be_empty end it "should return JSON by default" do - get :index, :auth_token => @user.authentication_token + get :index, auth_token: @user.authentication_token expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) end describe "given a date range" do it "should return only the notices created during the date range" do - get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27" } + get :index, { auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27" } expect(response).to be_success notices = JSON.load response.body expect(notices.length).to eq 3 @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: 'controller' do end it "should return all notices" do - get :index, { :auth_token => @user.authentication_token } + get :index, { auth_token: @user.authentication_token } expect(response).to be_success notices = JSON.load response.body expect(notices.length).to eq 4 diff --git a/spec/controllers/api/v1/problems_controller_spec.rb b/spec/controllers/api/v1/problems_controller_spec.rb index 0bbc478..079987c 100644 --- a/spec/controllers/api/v1/problems_controller_spec.rb +++ b/spec/controllers/api/v1/problems_controller_spec.rb @@ -7,34 +7,34 @@ describe Api::V1::ProblemsController, type: 'controller' do describe "GET /api/v1/problems/:id" do before do notice = Fabricate(:notice) - err = Fabricate(:err, :notices => [notice]) - @problem = Fabricate(:problem, :errs => [err]) + err = Fabricate(:err, notices: [notice]) + @problem = Fabricate(:problem, errs: [err]) end it "should return JSON if JSON is requested" do - get :show, :auth_token => @user.authentication_token, :format => "json", :id => Problem.first.id + get :show, auth_token: @user.authentication_token, format: "json", id: Problem.first.id expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError end it "should return XML if XML is requested" do - get :index, :auth_token => @user.authentication_token, :format => "xml", :id => @problem.id + get :index, auth_token: @user.authentication_token, format: "xml", id: @problem.id expect(Nokogiri::XML(response.body).errors).to be_empty end it "should return JSON by default" do - get :show, :auth_token => @user.authentication_token, :id => @problem.id + get :show, auth_token: @user.authentication_token, id: @problem.id expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) end it "should return the correct problem" do - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id returned_problem = JSON.parse(response.body) expect(returned_problem["_id"]).to eq(@problem.id.to_s) end it "should return only the correct fields" do - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id returned_problem = JSON.parse(response.body) expect(returned_problem.keys).to match_array(%w( @@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: 'controller' do end it "returns a 404 if the problem cannot be found" do - get :show, :auth_token => @user.authentication_token, :format => "json", :id => 'IdontExist' + get :show, auth_token: @user.authentication_token, format: "json", id: 'IdontExist' expect(response.status).to eq(404) end end describe "GET /api/v1/problems" do before do - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 02)) - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 21)) - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 21)) - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 02)) + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 21)) + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 21)) + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 30)) end it "should return JSON if JSON is requested" do - get :index, :auth_token => @user.authentication_token, :format => "json" + get :index, auth_token: @user.authentication_token, format: "json" expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) end it "should return XML if XML is requested" do - get :index, :auth_token => @user.authentication_token, :format => "xml" + get :index, auth_token: @user.authentication_token, format: "xml" expect(Nokogiri::XML(response.body).errors).to be_empty end it "should return JSON by default" do - get :index, :auth_token => @user.authentication_token + get :index, auth_token: @user.authentication_token expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) end describe "given a date range" do it "should return only the problems open during the date range" do - get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27" } + get :index, { auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27" } expect(response).to be_success problems = JSON.load response.body expect(problems.length).to eq 2 @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: 'controller' do end it "should return all problems" do - get :index, { :auth_token => @user.authentication_token } + get :index, { auth_token: @user.authentication_token } expect(response).to be_success problems = JSON.load response.body expect(problems.length).to eq 4 diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb index 40e3f1f..7cf2583 100644 --- a/spec/controllers/apps_controller_spec.rb +++ b/spec/controllers/apps_controller_spec.rb @@ -1,32 +1,32 @@ describe AppsController, type: 'controller' do it_requires_authentication - it_requires_admin_privileges :for => { :new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete } + it_requires_admin_privileges for: { new: :get, edit: :get, create: :post, update: :put, destroy: :delete } let(:admin) { Fabricate(:admin) } let(:user) { Fabricate(:user) } - let(:watcher) { Fabricate(:user_watcher, :app => app, :user => user) } + let(:watcher) { Fabricate(:user_watcher, app: app, user: user) } let(:unwatched_app) { Fabricate(:app) } let(:app) { unwatched_app } let(:watched_app1) do a = Fabricate(:app) - Fabricate(:user_watcher, :user => user, :app => a) + Fabricate(:user_watcher, user: user, app: a) a end let(:watched_app2) do a = Fabricate(:app) - Fabricate(:user_watcher, :user => user, :app => a) + Fabricate(:user_watcher, user: user, app: a) a end let(:err) do - Fabricate(:err, :problem => problem) + Fabricate(:err, problem: problem) end let(:notice) do - Fabricate(:notice, :err => err) + Fabricate(:notice, err: err) end let(:problem) do - Fabricate(:problem, :app => app) + Fabricate(:problem, app: app) end - let(:problem_resolved) { Fabricate(:problem_resolved, :app => app) } + let(:problem_resolved) { Fabricate(:problem_resolved, app: app) } describe "GET /apps" do context 'when logged in as an admin' do @@ -55,43 +55,43 @@ describe AppsController, type: 'controller' do end it 'finds the app' do - get :show, :id => app.id + get :show, id: app.id expect(controller.app).to eq app end it "should not raise errors for app with err without notices" do err - expect { get :show, :id => app.id }.to_not raise_error + expect { get :show, id: app.id }.to_not raise_error end it "should list atom feed successfully" do - get :show, :id => app.id, :format => "atom" + get :show, id: app.id, format: "atom" expect(response).to be_success end it "should list available watchers by name" do - Fabricate(:user, :name => "Carol") - Fabricate(:user, :name => "Alice") - Fabricate(:user, :name => "Betty") + Fabricate(:user, name: "Carol") + Fabricate(:user, name: "Alice") + Fabricate(:user, name: "Betty") - get :show, :id => app.id + get :show, id: app.id expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name)) end context "pagination" do before(:each) do - 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } + 35.times { Fabricate(:err, problem: Fabricate(:problem, app: app)) } end it "should have default per_page value for user" do - get :show, :id => app.id + get :show, id: app.id expect(controller.problems.to_a.size).to eq User::PER_PAGE end it "should be able to override default per_page value" do admin.update_attribute :per_page, 10 - get :show, :id => app.id + get :show, id: app.id expect(controller.problems.to_a.size).to eq 10 end end @@ -103,14 +103,14 @@ describe AppsController, type: 'controller' do context 'and no params' do it 'shows only unresolved problems' do - get :show, :id => app.id + get :show, id: app.id expect(controller.problems.size).to eq 1 end end context 'and all_problems=true params' do it 'shows all errors' do - get :show, :id => app.id, :all_errs => true + get :show, id: app.id, all_errs: true expect(controller.problems.size).to eq 2 end end @@ -120,41 +120,41 @@ describe AppsController, type: 'controller' do before(:each) do environments = %w(production test development staging) 20.times do |i| - Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) + Fabricate(:problem, app: app, environment: environments[i % environments.length]) end end context 'no params' do it 'shows errs for all environments' do - get :show, :id => app.id + get :show, id: app.id expect(controller.problems.size).to eq 20 end end context 'environment production' do it 'shows errs for just production' do - get :show, :id => app.id, :environment => 'production' + get :show, id: app.id, environment: 'production' expect(controller.problems.size).to eq 5 end end context 'environment staging' do it 'shows errs for just staging' do - get :show, :id => app.id, :environment => 'staging' + get :show, id: app.id, environment: 'staging' expect(controller.problems.size).to eq 5 end end context 'environment development' do it 'shows errs for just development' do - get :show, :id => app.id, :environment => 'development' + get :show, id: app.id, environment: 'development' expect(controller.problems.size).to eq 5 end end context 'environment test' do it 'shows errs for just test' do - get :show, :id => app.id, :environment => 'test' + get :show, id: app.id, environment: 'test' expect(controller.problems.size).to eq 5 end end @@ -166,7 +166,7 @@ describe AppsController, type: 'controller' do sign_in Fabricate(:user) app = Fabricate(:app) - get :show, :id => app.id + get :show, id: app.id expect(controller.app).to eq app end end @@ -186,9 +186,9 @@ describe AppsController, type: 'controller' do end it "should copy attributes from an existing app" do - @app = Fabricate(:app, :name => "do not copy", - :github_repo => "test/example") - get :new, :copy_attributes_from => @app.id + @app = Fabricate(:app, name: "do not copy", + github_repo: "test/example") + get :new, copy_attributes_from: @app.id expect(controller.app).to be_a(App) expect(controller.app).to be_new_record expect(controller.app.name).to be_blank @@ -199,7 +199,7 @@ describe AppsController, type: 'controller' do describe "GET /apps/:id/edit" do it 'finds the correct app' do app = Fabricate(:app) - get :edit, :id => app.id + get :edit, id: app.id expect(controller.app).to eq app end end @@ -216,12 +216,12 @@ describe AppsController, type: 'controller' do end it "should redirect to the app page" do - post :create, :app => {} + post :create, app: {} expect(response).to redirect_to(app_path(@app)) end it "should display a message" do - post :create, :app => {} + post :create, app: {} expect(request.flash[:success]).to match(/success/) end end @@ -234,12 +234,12 @@ describe AppsController, type: 'controller' do context "when the update is successful" do it "should redirect to the app page" do - put :update, :id => @app.id, :app => {} + put :update, id: @app.id, app: {} expect(response).to redirect_to(app_path(@app)) end it "should display a message" do - put :update, :id => @app.id, :app => {} + put :update, id: @app.id, app: {} expect(request.flash[:success]).to match(/success/) end end @@ -247,14 +247,14 @@ describe AppsController, type: 'controller' do context "changing name" do it "should redirect to app page" do id = @app.id - put :update, :id => id, :app => { :name => "new name" } + put :update, id: id, app: { name: "new name" } expect(response).to redirect_to(app_path(id)) end end context "when the update is unsuccessful" do it "should render the edit page" do - put :update, :id => @app.id, :app => { :name => '' } + put :update, id: @app.id, app: { name: '' } expect(response).to render_template(:edit) end end @@ -265,30 +265,30 @@ describe AppsController, type: 'controller' do end it "should parse legal csv values" do - put :update, :id => @app.id, :app => { :email_at_notices => '1, 4, 7,8, 10' } + put :update, id: @app.id, app: { email_at_notices: '1, 4, 7,8, 10' } @app.reload expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10] end context "failed parsing of CSV" do it "should set the default value" do - @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4]) - put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } + @app = Fabricate(:app, email_at_notices: [1, 2, 3, 4]) + put :update, id: @app.id, app: { email_at_notices: 'asdf, -1,0,foobar,gd00,0,abc' } @app.reload expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices end it "should display a message" do - put :update, :id => @app.id, :app => { :email_at_notices => 'qwertyuiop' } + put :update, id: @app.id, app: { email_at_notices: 'qwertyuiop' } expect(request.flash[:error]).to match(/Couldn't parse/) end end end - context "setting up issue tracker", :cur => true do + context "setting up issue tracker", cur: true do context "unknown tracker type" do before(:each) do - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { - :type_tracker => 'unknown', :options => { :project_id => '1234', :api_token => '123123', :account => 'myapp' } + put :update, id: @app.id, app: { issue_tracker_attributes: { + type_tracker: 'unknown', options: { project_id: '1234', api_token: '123123', account: 'myapp' } } } @app.reload end @@ -306,24 +306,24 @@ describe AppsController, type: 'controller' do end it "should find the app" do - delete :destroy, :id => @app.id + delete :destroy, id: @app.id expect(controller.app).to eq @app end it "should destroy the app" do - delete :destroy, :id => @app.id + delete :destroy, id: @app.id expect { @app.reload }.to raise_error(Mongoid::Errors::DocumentNotFound) end it "should display a message" do - delete :destroy, :id => @app.id + delete :destroy, id: @app.id expect(request.flash[:success]).to match(/success/) end it "should redirect to the apps page" do - delete :destroy, :id => @app.id + delete :destroy, id: @app.id expect(response).to redirect_to(apps_path) end end @@ -336,7 +336,7 @@ describe AppsController, type: 'controller' do end it 'redirect to root with flash error' do - post :regenerate_api_key, :id => 'foo' + post :regenerate_api_key, id: 'foo' expect(request).to redirect_to root_path end end @@ -348,7 +348,7 @@ describe AppsController, type: 'controller' do it 'redirect_to app view' do expect do - post :regenerate_api_key, :id => app.id + post :regenerate_api_key, id: app.id expect(request).to redirect_to edit_app_path(app) end.to change { app.reload.api_key } end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index fe62d6d..01226d1 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,6 +1,6 @@ describe CommentsController, type: 'controller' do let(:app) { Fabricate(:app) } - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } + let(:err) { Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production")) } describe "POST /apps/:app_id/errs/:id/comments/create" do render_views @@ -14,8 +14,8 @@ describe CommentsController, type: 'controller' do let(:user) { Fabricate(:user) } before(:each) do - post :create, :app_id => problem.app.id, :problem_id => problem.id, - :comment => { :body => "One test comment", :user_id => user.id } + post :create, app_id: problem.app.id, problem_id: problem.id, + comment: { body: "One test comment", user_id: user.id } problem.reload end @@ -41,7 +41,7 @@ describe CommentsController, type: 'controller' do let(:comment) { problem.reload.comments.first } before(:each) do - delete :destroy, :app_id => problem.app.id, :problem_id => problem.id, :id => comment.id.to_s + delete :destroy, app_id: problem.app.id, problem_id: problem.id, id: comment.id.to_s problem.reload end diff --git a/spec/controllers/deploys_controller_spec.rb b/spec/controllers/deploys_controller_spec.rb index 7937fa6..621cf5c 100644 --- a/spec/controllers/deploys_controller_spec.rb +++ b/spec/controllers/deploys_controller_spec.rb @@ -10,30 +10,30 @@ describe DeploysController, type: 'controller' do 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', 'message' => 'johns first deploy' } - @app = Fabricate(:app_with_watcher, :notify_on_deploys => true, :api_key => 'APIKEY') + @app = Fabricate(:app_with_watcher, notify_on_deploys: true, api_key: 'APIKEY') end it 'finds the app via the api key' do expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) - post :create, :deploy => @params, :api_key => 'APIKEY' + post :create, deploy: @params, api_key: 'APIKEY' end it 'creates a deploy' do expect(App).to receive(:find_by_api_key!).and_return(@app) expect(@app.deploys).to receive(:create!). with({ - :username => 'john.doe', - :environment => 'production', - :repository => 'git@github.com/errbit/errbit.git', - :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', - :message => 'johns first deploy' + username: 'john.doe', + environment: 'production', + repository: 'git@github.com/errbit/errbit.git', + revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', + message: 'johns first deploy' }).and_return(Fabricate(:deploy)) - post :create, :deploy => @params, :api_key => 'APIKEY' + post :create, deploy: @params, api_key: 'APIKEY' end it 'sends an email notification when configured to do so' do - post :create, :deploy => @params, :api_key => 'APIKEY' + post :create, deploy: @params, api_key: 'APIKEY' email = ActionMailer::Base.deliveries.last expect(email.to).to include(@app.watchers.first.email) expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" @@ -44,7 +44,7 @@ describe DeploysController, type: 'controller' do before(:each) do @deploy = Fabricate :deploy sign_in Fabricate(:admin) - get :index, :app_id => @deploy.app.id + get :index, app_id: @deploy.app.id end it "should render successfully" do diff --git a/spec/controllers/devise_sessions_controller_spec.rb b/spec/controllers/devise_sessions_controller_spec.rb index 4bf53a0..bf31d24 100644 --- a/spec/controllers/devise_sessions_controller_spec.rb +++ b/spec/controllers/devise_sessions_controller_spec.rb @@ -10,12 +10,12 @@ describe Devise::SessionsController, type: 'controller' do let(:user) { Fabricate(:user) } it 'redirects to app index page if there are no apps for the user' do - post :create, { :user => { 'email' => user.email, 'password' => user.password } } + post :create, { user: { 'email' => user.email, 'password' => user.password } } expect(response).to redirect_to(root_path) end it 'displays a friendly error when credentials are invalid' do - post :create, { :user => { 'email' => 'whatever', 'password' => 'somethinginvalid' } } + post :create, { user: { 'email' => 'whatever', 'password' => 'somethinginvalid' } } expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') end end diff --git a/spec/controllers/notices_controller_spec.rb b/spec/controllers/notices_controller_spec.rb index 57bf019..808ac4d 100644 --- a/spec/controllers/notices_controller_spec.rb +++ b/spec/controllers/notices_controller_spec.rb @@ -1,16 +1,16 @@ describe NoticesController, type: 'controller' do - it_requires_authentication :for => { :locate => :get } + it_requires_authentication for: { locate: :get } let(:notice) { Fabricate(:notice) } let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } let(:app) { Fabricate(:app) } - let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice, :should_keep? => true) } + let(:error_report) { double(valid?: true, generate_notice!: true, notice: notice, should_keep?: true) } context 'notices API' do context "with bogus xml" do it "returns an error" do expect(request).to receive(:raw_post).and_return('notxml') - post :create, :format => :xml + post :create, format: :xml expect(response.status).to eq(422) expect(response.body).to eq('The provided XML was not well-formed') end @@ -24,7 +24,7 @@ describe NoticesController, type: 'controller' do context "with xml pass in raw_port" do before do expect(request).to receive(:raw_post).and_return(xml) - post :create, :format => :xml + post :create, format: :xml end it "generates a notice from raw xml [POST]" do @@ -37,7 +37,7 @@ describe NoticesController, type: 'controller' do end it "generates a notice from xml in a data param [POST]" do - post :create, :data => xml, :format => :xml + post :create, data: xml, format: :xml expect(response).to be_success # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb @@ -46,15 +46,15 @@ describe NoticesController, type: 'controller' do end it "generates a notice from xml [GET]" do - get :create, :data => xml, :format => :xml + get :create, data: xml, format: :xml expect(response).to be_success expect(response.body).to match(%r{]*>#{notice.id}}) expect(response.body).to match(%r{]*>(.+)#{locate_path(notice.id)}}) end context "with an invalid API_KEY" do - let(:error_report) { double(:valid? => false) } + let(:error_report) { double(valid?: false) } it 'return 422' do - post :create, :format => :xml, :data => xml + post :create, format: :xml, data: xml expect(response.status).to eq 422 end end @@ -62,7 +62,7 @@ describe NoticesController, type: 'controller' do context "without params needed" do it 'return 400' do - post :create, :format => :xml + post :create, format: :xml expect(response.status).to eq 400 expect(response.body).to eq 'Need a data params in GET or raw post data' end @@ -77,9 +77,9 @@ describe NoticesController, type: 'controller' do end it "should locate notice and redirect to problem" do - problem = Fabricate(:problem, :app => app, :environment => "production") - notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) - get :locate, :id => notice.id + problem = Fabricate(:problem, app: app, environment: "production") + notice = Fabricate(:notice, err: Fabricate(:err, problem: problem)) + get :locate, id: notice.id expect(response).to redirect_to(app_problem_path(problem.app, problem)) end end diff --git a/spec/controllers/problems_controller_spec.rb b/spec/controllers/problems_controller_spec.rb index 18b0a7e..b116606 100644 --- a/spec/controllers/problems_controller_spec.rb +++ b/spec/controllers/problems_controller_spec.rb @@ -1,18 +1,18 @@ describe ProblemsController, type: 'controller' do - it_requires_authentication :for => { - :index => :get, :show => :get, :resolve => :put, :search => :get + it_requires_authentication for: { + index: :get, show: :get, resolve: :put, search: :get }, - :params => { :app_id => 'dummyid', :id => 'dummyid' } + params: { app_id: 'dummyid', id: 'dummyid' } let(:app) { Fabricate(:app) } - let(:err) { Fabricate(:err, :problem => problem) } + let(:err) { Fabricate(:err, problem: problem) } let(:user) { Fabricate(:user) } - let(:problem) { Fabricate(:problem, :app => app, :environment => "production") } + let(:problem) { Fabricate(:problem, app: app, environment: "production") } describe "GET /problems" do before(:each) do sign_in user - @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production"))).problem + @problem = Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production"))).problem end context "pagination" do @@ -36,7 +36,7 @@ describe ProblemsController, type: 'controller' do before(:each) do environments = %w(production test development staging) 20.times do |i| - Fabricate(:problem, :environment => environments[i % environments.length]) + Fabricate(:problem, environment: environments[i % environments.length]) end end @@ -49,28 +49,28 @@ describe ProblemsController, type: 'controller' do context 'environment production' do it 'shows problems for just production' do - get :index, :environment => 'production' + get :index, environment: 'production' expect(controller.problems.size).to eq 6 end end context 'environment staging' do it 'shows problems for just staging' do - get :index, :environment => 'staging' + get :index, environment: 'staging' expect(controller.problems.size).to eq 5 end end context 'environment development' do it 'shows problems for just development' do - get :index, :environment => 'development' + get :index, environment: 'development' expect(controller.problems.size).to eq 5 end end context 'environment test' do it 'shows problems for just test' do - get :index, :environment => 'test' + get :index, environment: 'test' expect(controller.problems.size).to eq 5 end end @@ -82,11 +82,11 @@ describe ProblemsController, type: 'controller' do sign_in Fabricate(:user) problems = Kaminari.paginate_array((1..30).to_a) 3.times { problems << Fabricate(:err).problem } - 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } + 3.times { problems << Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem } expect(Problem).to receive(:ordered_by).and_return( - double('proxy', :page => double('other_proxy', :per => problems)) + double('proxy', page: double('other_proxy', per: problems)) ) - get :index, :all_errs => true + get :index, all_errs: true expect(controller.problems).to eq problems end end @@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' do before do sign_in user @app = Fabricate(:app) - @problem1 = Fabricate(:problem, :app => @app, message: "Most important") - @problem2 = Fabricate(:problem, :app => @app, message: "Very very important") + @problem1 = Fabricate(:problem, app: @app, message: "Most important") + @problem2 = Fabricate(:problem, app: @app, message: "Very very important") end it "renders successfully" do @@ -110,7 +110,7 @@ describe ProblemsController, type: 'controller' do end it "searches problems for given string" do - get :search, :search => "\"Most important\"" + get :search, search: "\"Most important\"" expect(controller.problems).to include(@problem1) expect(controller.problems).to_not include(@problem2) end @@ -122,35 +122,35 @@ describe ProblemsController, type: 'controller' do end it "finds the app" do - get :show, :app_id => app.id, :id => err.problem.id + get :show, app_id: app.id, id: err.problem.id expect(controller.app).to eq app end it "finds the problem" do - get :show, :app_id => app.id, :id => err.problem.id + get :show, app_id: app.id, id: err.problem.id expect(controller.problem).to eq err.problem end it "successfully render page" do - get :show, :app_id => app.id, :id => err.problem.id + get :show, app_id: app.id, id: err.problem.id expect(response).to be_success end context 'pagination' do let!(:notices) do 3.times.reduce([]) do |coll, i| - coll << Fabricate(:notice, :err => err, :created_at => (i.seconds.from_now)) + coll << Fabricate(:notice, err: err, created_at: (i.seconds.from_now)) end end it "paginates the notices 1 at a time, starting with the most recent" do - get :show, :app_id => app.id, :id => err.problem.id + get :show, app_id: app.id, id: err.problem.id expect(assigns(:notices).entries.count).to eq 1 expect(assigns(:notices)).to include(notices.last) end it "paginates the notices 1 at a time, based on then notice param" do - get :show, :app_id => app.id, :id => err.problem.id, :notice => 3 + get :show, app_id: app.id, id: err.problem.id, notice: 3 expect(assigns(:notices).entries.count).to eq 1 expect(assigns(:notices)).to include(notices.first) end @@ -165,29 +165,29 @@ describe ProblemsController, type: 'controller' do end it 'finds the app and the problem' do - put :resolve, :app_id => @err.app.id, :id => @err.problem.id + put :resolve, app_id: @err.app.id, id: @err.problem.id expect(controller.app).to eq @err.app expect(controller.problem).to eq @err.problem end it "should resolve the issue" do - put :resolve, :app_id => @err.app.id, :id => @err.problem.id + put :resolve, app_id: @err.app.id, id: @err.problem.id expect(@err.problem.reload.resolved).to be(true) end it "should display a message" do - put :resolve, :app_id => @err.app.id, :id => @err.problem.id + put :resolve, app_id: @err.app.id, id: @err.problem.id expect(request.flash[:success]).to match(/Great news/) end it "should redirect to the app page" do - put :resolve, :app_id => @err.app.id, :id => @err.problem.id + put :resolve, app_id: @err.app.id, id: @err.problem.id expect(response).to redirect_to(app_path(@err.app)) end it "should redirect back to problems page" do request.env["HTTP_REFERER"] = problems_path - put :resolve, :app_id => @err.app.id, :id => @err.problem.id + put :resolve, app_id: @err.app.id, id: @err.problem.id expect(response).to redirect_to(problems_path) end end @@ -245,7 +245,7 @@ describe ProblemsController, type: 'controller' do it "should render whatever the issue tracker says" do allow_any_instance_of(Issue).to receive(:render_body_args).and_return( - [{ :inline => 'one <%= problem.id %> two' }]) + [{ inline: 'one <%= problem.id %> two' }]) post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' line = issue_tracker.tracker.output.shift expect(line[1]).to eq("one #{problem.id} two") @@ -268,10 +268,10 @@ describe ProblemsController, type: 'controller' do end context "problem with issue" do - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :issue_link => "http://some.host")) } + let(:err) { Fabricate(:err, problem: Fabricate(:problem, issue_link: "http://some.host")) } before(:each) do - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id + delete :unlink_issue, app_id: err.app.id, id: err.problem.id err.problem.reload end @@ -288,7 +288,7 @@ describe ProblemsController, type: 'controller' do let(:err) { Fabricate :err } before(:each) do - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id + delete :unlink_issue, app_id: err.app.id, id: err.problem.id err.problem.reload end @@ -301,25 +301,25 @@ describe ProblemsController, type: 'controller' do describe "Bulk Actions" do before(:each) do sign_in user - @problem1 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem - @problem2 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => false)).problem + @problem1 = Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem + @problem2 = Fabricate(:err, problem: Fabricate(:problem, resolved: false)).problem end context "POST /problems/merge_several" do it "should require at least two problems" do - post :merge_several, :problems => [@problem1.id.to_s] + post :merge_several, problems: [@problem1.id.to_s] expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge') end it "should merge the problems" do - expect(ProblemMerge).to receive(:new).and_return(double(:merge => true)) - post :merge_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] + expect(ProblemMerge).to receive(:new).and_return(double(merge: true)) + post :merge_several, problems: [@problem1.id.to_s, @problem2.id.to_s] end end context "POST /problems/unmerge_several" do it "should require at least one problem" do - post :unmerge_several, :problems => [] + post :unmerge_several, problems: [] expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') end @@ -327,7 +327,7 @@ describe ProblemsController, type: 'controller' do merged_problem = Problem.merge!(@problem1, @problem2) expect(merged_problem.errs.length).to eq 2 expect { - post :unmerge_several, :problems => [merged_problem.id.to_s] + post :unmerge_several, problems: [merged_problem.id.to_s] expect(merged_problem.reload.errs.length).to eq 1 }.to change(Problem, :count).by(1) end @@ -335,22 +335,22 @@ describe ProblemsController, type: 'controller' do context "POST /problems/resolve_several" do it "should require at least one problem" do - post :resolve_several, :problems => [] + post :resolve_several, problems: [] expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') end it "should resolve the issue" do - post :resolve_several, :problems => [@problem2.id.to_s] + post :resolve_several, problems: [@problem2.id.to_s] expect(@problem2.reload.resolved?).to eq true end it "should display a message about 1 err" do - post :resolve_several, :problems => [@problem2.id.to_s] + post :resolve_several, problems: [@problem2.id.to_s] expect(flash[:success]).to match(/1 error has been resolved/) end it "should display a message about 2 errs" do - post :resolve_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] + post :resolve_several, problems: [@problem1.id.to_s, @problem2.id.to_s] expect(flash[:success]).to match(/2 errors have been resolved/) expect(controller.selected_problems).to eq [@problem1, @problem2] end @@ -358,12 +358,12 @@ describe ProblemsController, type: 'controller' do context "POST /problems/unresolve_several" do it "should require at least one problem" do - post :unresolve_several, :problems => [] + post :unresolve_several, problems: [] expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') end it "should unresolve the issue" do - post :unresolve_several, :problems => [@problem1.id.to_s] + post :unresolve_several, problems: [@problem1.id.to_s] expect(@problem1.reload.resolved?).to eq false end end @@ -371,7 +371,7 @@ describe ProblemsController, type: 'controller' do context "POST /problems/destroy_several" do it "should delete the problems" do expect { - post :destroy_several, :problems => [@problem1.id.to_s] + post :destroy_several, problems: [@problem1.id.to_s] }.to change(Problem, :count).by(-1) end end @@ -380,25 +380,25 @@ describe ProblemsController, type: 'controller' do before do sign_in user @app = Fabricate(:app) - @problem1 = Fabricate(:problem, :app => @app) - @problem2 = Fabricate(:problem, :app => @app) + @problem1 = Fabricate(:problem, app: @app) + @problem2 = Fabricate(:problem, app: @app) end it "destroys all problems" do expect { - post :destroy_all, :app_id => @app.id + post :destroy_all, app_id: @app.id }.to change(Problem, :count).by(-2) expect(controller.app).to eq @app end it "should display a message" do - put :destroy_all, :app_id => @app.id + put :destroy_all, app_id: @app.id expect(request.flash[:success]).to match(/been deleted/) end it "should redirect back to the app page" do request.env["HTTP_REFERER"] = edit_app_path(@app) - put :destroy_all, :app_id => @app.id + put :destroy_all, app_id: @app.id expect(response).to redirect_to(edit_app_path(@app)) end end diff --git a/spec/controllers/site_config_controller_spec.rb b/spec/controllers/site_config_controller_spec.rb index 9195b8e..4281b19 100644 --- a/spec/controllers/site_config_controller_spec.rb +++ b/spec/controllers/site_config_controller_spec.rb @@ -1,6 +1,6 @@ describe SiteConfigController, type: 'controller' do it_requires_admin_privileges for: { - index: :get, + index: :get, update: :put } @@ -18,7 +18,7 @@ describe SiteConfigController, type: 'controller' do it 'updates' do put :update, site_config: { notice_fingerprinter_attributes: { - backtrace_lines: 3, + backtrace_lines: 3, environment_name: false } } diff --git a/spec/controllers/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/users/omniauth_callbacks_controller_spec.rb index 14b957c..ea82767 100644 --- a/spec/controllers/users/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/users/omniauth_callbacks_controller_spec.rb @@ -4,9 +4,9 @@ describe Users::OmniauthCallbacksController, type: 'controller' do request.env["devise.mapping"] = Devise.mappings[:user] env = { "omniauth.auth" => Hashie::Mash.new( - :provider => 'github', - :extra => { :raw_info => { :login => login } }, - :credentials => { :token => token } + provider: 'github', + extra: { raw_info: { login: login } }, + credentials: { token: token } ) } allow(@controller).to receive(:env).and_return(env) @@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: 'controller' do end it "should show an error if another user already has that github login" do - Fabricate(:user, :github_login => "existing_user") + Fabricate(:user, github_login: "existing_user") stub_env_for_github_omniauth("existing_user") get :github diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 07f54ac..1f6fc4e 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,11 +1,11 @@ describe UsersController, type: 'controller' do it_requires_authentication - it_requires_admin_privileges :for => { - :index => :get, - :show => :get, - :new => :get, - :create => :post, - :destroy => :delete + it_requires_admin_privileges for: { + index: :get, + show: :get, + new: :get, + create: :post, + destroy: :delete } let(:admin) { Fabricate(:admin) } @@ -23,14 +23,14 @@ describe UsersController, type: 'controller' do context "GET /users/:other_id/edit" do it "redirects to the home page" do - get :edit, :id => other_user.id + get :edit, id: other_user.id expect(response).to redirect_to(root_path) end end context "GET /users/:my_id/edit" do it 'finds the user' do - get :edit, :id => user.id + get :edit, id: user.id expect(controller.user).to eq(user) expect(response).to render_template 'edit' end @@ -38,7 +38,7 @@ describe UsersController, type: 'controller' do context "PUT /users/:other_id" do it "redirects to the home page" do - put :update, :id => other_user.id + put :update, id: other_user.id expect(response).to redirect_to(root_path) end end @@ -46,47 +46,47 @@ describe UsersController, type: 'controller' do context "PUT /users/:my_id/id" do context "when the update is successful" do it "sets a message to display" do - put :update, :id => user.to_param, :user => { :name => 'Kermit' } + put :update, id: user.to_param, user: { name: 'Kermit' } expect(request.flash[:success]).to include('updated') end it "redirects to the user's page" do - put :update, :id => user.to_param, :user => { :name => 'Kermit' } + put :update, id: user.to_param, user: { name: 'Kermit' } expect(response).to redirect_to(user_path(user)) end it "should not be able to become an admin" do expect { - put :update, :id => user.to_param, :user => { :admin => true } + put :update, id: user.to_param, user: { admin: true } }.to_not change { user.reload.admin }.from(false) end it "should be able to set per_page option" do - put :update, :id => user.to_param, :user => { :per_page => 555 } + put :update, id: user.to_param, user: { per_page: 555 } expect(user.reload.per_page).to eq 555 end it "should be able to set time_zone option" do - put :update, :id => user.to_param, :user => { :time_zone => "Warsaw" } + put :update, id: user.to_param, user: { time_zone: "Warsaw" } expect(user.reload.time_zone).to eq "Warsaw" end it "should be able to not set github_login option" do - put :update, :id => user.to_param, :user => { :github_login => " " } + put :update, id: user.to_param, user: { github_login: " " } expect(user.reload.github_login).to eq nil end it "should be able to set github_login option" do - put :update, :id => user.to_param, :user => { :github_login => "awesome_name" } + put :update, id: user.to_param, user: { github_login: "awesome_name" } expect(user.reload.github_login).to eq "awesome_name" end end context "when the update is unsuccessful" do it "renders the edit page" do - put :update, :id => user.to_param, :user => { :name => nil } + put :update, id: user.to_param, user: { name: nil } expect(response).to render_template(:edit) end end @@ -109,7 +109,7 @@ describe UsersController, type: 'controller' do context "GET /users/:id" do it 'finds the user' do - get :show, :id => user.id + get :show, id: user.id expect(controller.user).to eq user end end @@ -124,14 +124,14 @@ describe UsersController, type: 'controller' do context "GET /users/:id/edit" do it 'finds the user' do - get :edit, :id => user.id + get :edit, id: user.id expect(controller.user).to eq user end end context "POST /users" do context "when the create is successful" do - let(:attrs) { { :user => Fabricate.to_params(:user) } } + let(:attrs) { { user: Fabricate.to_params(:user) } } it "sets a message to display" do post :create, attrs @@ -166,7 +166,7 @@ describe UsersController, type: 'controller' do end it "renders the new page" do - post :create, :user => { :username => 'foo' } + post :create, user: { username: 'foo' } expect(response).to render_template(:new) end end @@ -175,20 +175,20 @@ describe UsersController, type: 'controller' do context "PUT /users/:id" do context "when the update is successful" do before { - put :update, :id => user.to_param, :user => user_params + put :update, id: user.to_param, user: user_params } context "with normal params" do - let(:user_params) { { :name => 'Kermit' } } + let(:user_params) { { name: 'Kermit' } } it "sets a message to display" do - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.reload.name) + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', name: user.reload.name) expect(response).to redirect_to(user_path(user)) end end end context "when the update is unsuccessful" do it "renders the edit page" do - put :update, :id => user.to_param, :user => { :name => nil } + put :update, id: user.to_param, user: { name: nil } expect(response).to render_template(:edit) end end @@ -196,15 +196,15 @@ describe UsersController, type: 'controller' do context "DELETE /users/:id" do context "with a destroy success" do - let(:user_destroy) { double(:destroy => true) } + let(:user_destroy) { double(destroy: true) } before { expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) - delete :destroy, :id => user.id + delete :destroy, id: user.id } it 'should destroy user' do - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', :name => user.name) + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', name: user.name) expect(response).to redirect_to(users_path) end end @@ -212,7 +212,7 @@ describe UsersController, type: 'controller' do context "with trying destroy himself" do before { expect(UserDestroy).to_not receive(:new) - delete :destroy, :id => admin.id + delete :destroy, id: admin.id } it 'should not destroy user' do @@ -230,7 +230,7 @@ describe UsersController, type: 'controller' do ActionController::Parameters.new(user_param) ) } - let(:user_param) { { 'user' => { :name => 'foo', :admin => true } } } + let(:user_param) { { 'user' => { name: 'foo', admin: true } } } it 'not have admin field' do expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) end diff --git a/spec/controllers/watchers_controller_spec.rb b/spec/controllers/watchers_controller_spec.rb index 8ac42ba..0c44767 100644 --- a/spec/controllers/watchers_controller_spec.rb +++ b/spec/controllers/watchers_controller_spec.rb @@ -15,7 +15,7 @@ describe WatchersController, type: 'controller' do let(:watcher) { app.watchers.first } before(:each) do - delete :destroy, :app_id => app.id, :id => watcher.user.id.to_s + delete :destroy, app_id: app.id, id: watcher.user.id.to_s problem.reload end @@ -34,7 +34,7 @@ describe WatchersController, type: 'controller' do context "successful watcher update" do before(:each) do - put :update, :app_id => app.id, :id => user.id.to_s + put :update, app_id: app.id, id: user.id.to_s problem.reload end diff --git a/spec/decorators/app_decorator_spec.rb b/spec/decorators/app_decorator_spec.rb index 44eb885..e0d4b62 100644 --- a/spec/decorators/app_decorator_spec.rb +++ b/spec/decorators/app_decorator_spec.rb @@ -1,27 +1,27 @@ describe AppDecorator do describe "#email_at_notices" do it 'return the list separate by comma' do - expect(AppDecorator.new(double(:email_at_notices => [2, 3])).email_at_notices).to eql '2, 3' + expect(AppDecorator.new(double(email_at_notices: [2, 3])).email_at_notices).to eql '2, 3' end end describe "#notify_user_display" do it 'return display:none if notify' do - expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;' + expect(AppDecorator.new(double(notify_all_users: true)).notify_user_display).to eql 'display: none;' end it 'return blank if no notify' do - expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql '' + expect(AppDecorator.new(double(notify_all_users: false)).notify_user_display).to eql '' end end describe "#notify_err_display" do it 'return display:none if no notify' do - expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;' + expect(AppDecorator.new(double(notify_on_errs: false)).notify_err_display).to eql 'display: none;' end it 'return blank if no notify' do - expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql '' + expect(AppDecorator.new(double(notify_on_errs: true)).notify_err_display).to eql '' end end end diff --git a/spec/decorators/backtrace_decorator_spec.rb b/spec/decorators/backtrace_decorator_spec.rb index dfba0f9..e028564 100644 --- a/spec/decorators/backtrace_decorator_spec.rb +++ b/spec/decorators/backtrace_decorator_spec.rb @@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do described_class.new(Backtrace.new( lines: [ { number: 131, - file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', + file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', method: :update_preferences }, { number: 61, - file: '[PROJECT_ROOT]app/controllers/application_controller.rb', + file: '[PROJECT_ROOT]app/controllers/application_controller.rb', method: :call }, { number: 182, - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', method: :call }, { number: 384, - file: '[PROJECT_ROOT]app/models/account.rb', + file: '[PROJECT_ROOT]app/models/account.rb', method: :update_server_tag_scope }, { number: 182, - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', method: :evaluate_method }, { number: 23, - file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', + file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', method: '
' } ] )) diff --git a/spec/decorators/backtrace_line_decorator_spec.rb b/spec/decorators/backtrace_line_decorator_spec.rb index 32dde29..873118f 100644 --- a/spec/decorators/backtrace_line_decorator_spec.rb +++ b/spec/decorators/backtrace_line_decorator_spec.rb @@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do let(:backtrace_line) do described_class.new( number: 884, - file: '/path/to/file/ea315ea4.rb', + file: '/path/to/file/ea315ea4.rb', method: :instance_eval) end let(:backtrace_line_in_app) do described_class.new( number: 884, - file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb', + file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb', method: :instance_eval) end let(:app) { Fabricate(:app, github_repo: 'foo/bar') } diff --git a/spec/decorators/issue_tracker_decorator_spec.rb b/spec/decorators/issue_tracker_decorator_spec.rb index 8fdc938..9f8ebd2 100644 --- a/spec/decorators/issue_tracker_decorator_spec.rb +++ b/spec/decorators/issue_tracker_decorator_spec.rb @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do def self.fields { - :foo => { :label => 'foo' }, - :bar => { :label => 'bar' } + foo: { label: 'foo' }, + bar: { label: 'bar' } } end diff --git a/spec/decorators/issue_tracker_field_decorator.rb b/spec/decorators/issue_tracker_field_decorator.rb index c6003e5..3bef966 100644 --- a/spec/decorators/issue_tracker_field_decorator.rb +++ b/spec/decorators/issue_tracker_field_decorator.rb @@ -1,7 +1,7 @@ describe IssueTrackerFieldDecorator do describe "#label" do it 'return the label of field_info by default' do - expect(IssueTrackerFieldDecorator.new(:foo, { :label => 'hello' }).label).to eq 'hello' + expect(IssueTrackerFieldDecorator.new(:foo, { label: 'hello' }).label).to eq 'hello' end it 'return the key of field if no label define' do diff --git a/spec/decorators/issue_tracker_type_decorator_spec.rb b/spec/decorators/issue_tracker_type_decorator_spec.rb index 4ca52c2..b979421 100644 --- a/spec/decorators/issue_tracker_type_decorator_spec.rb +++ b/spec/decorators/issue_tracker_type_decorator_spec.rb @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do def self.fields { - :foo => { :label => 'foo' }, - :bar => { :label => 'bar' } + foo: { label: 'foo' }, + bar: { label: 'bar' } } end @@ -45,7 +45,7 @@ describe IssueTrackerDecorator do decorator.fields do |itf| expect(itf).to be_a(IssueTrackerFieldDecorator) expect([:foo, :bar]).to be_include(itf.object) - expect([{ :label => 'foo' }, { :label => 'bar' }]).to be_include(itf.field_info) + expect([{ label: 'foo' }, { label: 'bar' }]).to be_include(itf.field_info) end end end diff --git a/spec/decorators/watcher_decorator_spec.rb b/spec/decorators/watcher_decorator_spec.rb index 1983363..7691f13 100644 --- a/spec/decorators/watcher_decorator_spec.rb +++ b/spec/decorators/watcher_decorator_spec.rb @@ -2,13 +2,13 @@ describe WatcherDecorator do describe "#email_choosen" do context "with email define" do it 'return blank' do - expect(WatcherDecorator.new(double(:email => 'foo')).email_choosen).to eql '' + expect(WatcherDecorator.new(double(email: 'foo')).email_choosen).to eql '' end end context "without email define" do it 'return choosen' do - expect(WatcherDecorator.new(double(:email => '')).email_choosen).to eql 'chosen' + expect(WatcherDecorator.new(double(email: '')).email_choosen).to eql 'chosen' end end end diff --git a/spec/errbit_plugin/mock_issue_tracker.rb b/spec/errbit_plugin/mock_issue_tracker.rb index 28e79fd..1757789 100644 --- a/spec/errbit_plugin/mock_issue_tracker.rb +++ b/spec/errbit_plugin/mock_issue_tracker.rb @@ -10,8 +10,8 @@ module ErrbitPlugin def self.fields { - :foo => { :label => 'foo' }, - :bar => { :label => 'bar' } + foo: { label: 'foo' }, + bar: { label: 'bar' } } end diff --git a/spec/fabricators/app_fabricator.rb b/spec/fabricators/app_fabricator.rb index d58ddaa..ed9667a 100644 --- a/spec/fabricators/app_fabricator.rb +++ b/spec/fabricators/app_fabricator.rb @@ -3,9 +3,9 @@ Fabricator(:app) do repository_branch 'master' end -Fabricator(:app_with_watcher, :from => :app) do - watchers(:count => 1) { |parent, _i| - Fabricate.build(:watcher, :app => parent) +Fabricator(:app_with_watcher, from: :app) do + watchers(count: 1) { |parent, _i| + Fabricate.build(:watcher, app: parent) } end @@ -15,7 +15,7 @@ Fabricator(:watcher) do email { sequence(:email) { |n| "email#{n}@example.com" } } end -Fabricator(:user_watcher, :from => :watcher) do +Fabricator(:user_watcher, from: :watcher) do user watcher_type 'user' end diff --git a/spec/fabricators/backtrace_fabricator.rb b/spec/fabricators/backtrace_fabricator.rb index e7d78a4..ea9358a 100644 --- a/spec/fabricators/backtrace_fabricator.rb +++ b/spec/fabricators/backtrace_fabricator.rb @@ -1,8 +1,8 @@ Fabricator :backtrace do - lines(:count => 99) do + lines(count: 99) do { number: rand(999), - file: "/path/to/file/#{SecureRandom.hex(4)}.rb", + file: "/path/to/file/#{SecureRandom.hex(4)}.rb", method: ActiveSupport.methods.sample } end diff --git a/spec/fabricators/comment_fabricator.rb b/spec/fabricators/comment_fabricator.rb index 5450096..ac6e1f9 100644 --- a/spec/fabricators/comment_fabricator.rb +++ b/spec/fabricators/comment_fabricator.rb @@ -1,5 +1,5 @@ Fabricator :comment do user body 'Test comment' - err(:fabricator => :problem) + err(fabricator: :problem) end diff --git a/spec/fabricators/issue_tracker_fabricator.rb b/spec/fabricators/issue_tracker_fabricator.rb index e18a440..5b5fb08 100644 --- a/spec/fabricators/issue_tracker_fabricator.rb +++ b/spec/fabricators/issue_tracker_fabricator.rb @@ -2,8 +2,8 @@ Fabricator :issue_tracker do type_tracker 'mock' options { { - :foo => 'one', - :bar => 'two' + foo: 'one', + bar: 'two' }} app end diff --git a/spec/fabricators/notification_service_fabricator.rb b/spec/fabricators/notification_service_fabricator.rb index 269ed63..d90fe45 100644 --- a/spec/fabricators/notification_service_fabricator.rb +++ b/spec/fabricators/notification_service_fabricator.rb @@ -6,20 +6,20 @@ Fabricator :notification_service do notify_at_notices { sequence { |_a| [0] } } end -Fabricator :gtalk_notification_service, :from => :notification_service, :class_name => "NotificationServices::GtalkService" do +Fabricator :gtalk_notification_service, from: :notification_service, class_name: "NotificationServices::GtalkService" do user_id { sequence :word } service_url { sequence :word } service { sequence :word } end -Fabricator :slack_notification_service, :from => :notification_service, :class_name => "NotificationServices::SlackService" do +Fabricator :slack_notification_service, from: :notification_service, class_name: "NotificationServices::SlackService" do service_url { sequence :word } end -Fabricator :hipchat_notification_service, :from => :notification_service, :class_name => "NotificationServices::HipchatService" do +Fabricator :hipchat_notification_service, from: :notification_service, class_name: "NotificationServices::HipchatService" do service { 'v2' } end %w(campfire flowdock hoiio hubot pushover webhook).each do |t| - Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationServices::#{t.camelcase}Service" + Fabricator "#{t}_notification_service".to_sym, from: :notification_service, class_name: "NotificationServices::#{t.camelcase}Service" end diff --git a/spec/fabricators/problem_fabricator.rb b/spec/fabricators/problem_fabricator.rb index b230ef7..a4f0559 100644 --- a/spec/fabricators/problem_fabricator.rb +++ b/spec/fabricators/problem_fabricator.rb @@ -5,25 +5,25 @@ Fabricator(:problem) do environment 'production' end -Fabricator(:problem_with_comments, :from => :problem) do +Fabricator(:problem_with_comments, from: :problem) do after_create { |parent| 3.times do - Fabricate(:comment, :err => parent) + Fabricate(:comment, err: parent) end } end -Fabricator(:problem_with_errs, :from => :problem) do +Fabricator(:problem_with_errs, from: :problem) do after_create { |parent| 3.times do - Fabricate(:err, :problem => parent) + Fabricate(:err, problem: parent) end } end -Fabricator(:problem_resolved, :from => :problem) do +Fabricator(:problem_resolved, from: :problem) do after_create do |pr| - Fabricate(:notice, :err => Fabricate(:err, :problem => pr)) + Fabricate(:notice, err: Fabricate(:err, problem: pr)) pr.resolve! end end diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 84ce6a6..244b27e 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -5,6 +5,6 @@ Fabricator :user do password_confirmation 'password' end -Fabricator :admin, :from => :user do +Fabricator :admin, from: :user do admin true end diff --git a/spec/helpers/problems_helper_spec.rb b/spec/helpers/problems_helper_spec.rb index bbb86b6..6aeaf5b 100644 --- a/spec/helpers/problems_helper_spec.rb +++ b/spec/helpers/problems_helper_spec.rb @@ -1,14 +1,14 @@ describe ProblemsHelper do describe '#truncated_problem_message' do it 'is html safe' do - problem = double('problem', :message => '#') + problem = double('problem', message: '#') truncated = helper.truncated_problem_message(problem) expect(truncated).to be_html_safe expect(truncated).to_not include('<', '>') end it 'does not double escape html' do - problem = double('problem', :message => '#') + problem = double('problem', message: '#') truncated = helper.truncated_problem_message(problem) expect(truncated).to be_html_safe expect(truncated).to_not include('&') @@ -28,12 +28,12 @@ describe ProblemsHelper do it "should render image_tag with correct alt and src" do expected = "\"#{email}\"" - expect(helper.gravatar_tag(email, :s => 48)).to eq(expected) + expect(helper.gravatar_tag(email, s: 48)).to eq(expected) end it "should override :d" do expected = "\"#{email}\"" - expect(helper.gravatar_tag(email, :d => 'retro', :s => 48)).to eq(expected) + expect(helper.gravatar_tag(email, d: 'retro', s: 48)).to eq(expected) end end diff --git a/spec/initializers/action_mailer_spec.rb b/spec/initializers/action_mailer_spec.rb index a69c0f3..e932f6c 100644 --- a/spec/initializers/action_mailer_spec.rb +++ b/spec/initializers/action_mailer_spec.rb @@ -35,12 +35,12 @@ describe 'initializers/action_mailer' do load_initializer expect(ActionMailer::Base.smtp_settings).to eq({ - address: 'smtp.somedomain.com', - port: 998, + address: 'smtp.somedomain.com', + port: 998, authentication: :login, - user_name: 'my-username', - password: 'my-password', - domain: 'someotherdomain.com' + user_name: 'my-username', + password: 'my-password', + domain: 'someotherdomain.com' }) end end diff --git a/spec/initializers/devise_spec.rb b/spec/initializers/devise_spec.rb index 46e1618..a973f97 100644 --- a/spec/initializers/devise_spec.rb +++ b/spec/initializers/devise_spec.rb @@ -15,9 +15,9 @@ describe 'initializers/devise' do options = Devise.omniauth_configs[:github].options expect(options).to have_key(:client_options) expect(options[:client_options]).to eq({ - site: 'https://api.github.com', + site: 'https://api.github.com', authorize_url: 'https://github.com/login/oauth/authorize', - token_url: 'https://github.com/login/oauth/access_token' + token_url: 'https://github.com/login/oauth/access_token' }) end @@ -29,9 +29,9 @@ describe 'initializers/devise' do options = Devise.omniauth_configs[:github].options expect(options).to have_key(:client_options) expect(options[:client_options]).to eq({ - site: 'https://github.example.com/api/v3', + site: 'https://github.example.com/api/v3', authorize_url: 'https://github.example.com/login/oauth/authorize', - token_url: 'https://github.example.com/login/oauth/access_token' + token_url: 'https://github.example.com/login/oauth/access_token' }) end end diff --git a/spec/interactors/problem_destroy_spec.rb b/spec/interactors/problem_destroy_spec.rb index fda714a..b123502 100644 --- a/spec/interactors/problem_destroy_spec.rb +++ b/spec/interactors/problem_destroy_spec.rb @@ -6,8 +6,8 @@ describe ProblemDestroy do context "in unit way" do let(:problem) { problem = Problem.new - allow(problem).to receive(:errs).and_return(double(:criteria, :only => [err_1, err_2])) - allow(problem).to receive(:comments).and_return(double(:criteria, :only => [comment_1, comment_2])) + allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2])) + allow(problem).to receive(:comments).and_return(double(:criteria, only: [comment_1, comment_2])) allow(problem).to receive(:delete) problem } @@ -30,17 +30,17 @@ describe ProblemDestroy do end it 'delete all errs associate' do - expect(Err).to receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) + expect(Err).to receive(:delete_all).with(_id: { '$in' => [err_1.id, err_2.id] }) problem_destroy.execute end it 'delete all comments associate' do - expect(Comment).to receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) + expect(Comment).to receive(:delete_all).with(_id: { '$in' => [comment_1.id, comment_2.id] }) problem_destroy.execute end it 'delete all notice of associate to this errs' do - expect(Notice).to receive(:delete_all).with({ :err_id => { '$in' => [err_1.id, err_2.id] } }) + expect(Notice).to receive(:delete_all).with({ err_id: { '$in' => [err_1.id, err_2.id] } }) problem_destroy.execute end end @@ -48,26 +48,26 @@ describe ProblemDestroy do context "in integration way" do let!(:problem) { Fabricate(:problem) } - let!(:comment_1) { Fabricate(:comment, :err => problem) } - let!(:comment_2) { Fabricate(:comment, :err => problem) } - let!(:err_1) { Fabricate(:err, :problem => problem) } - let!(:err_2) { Fabricate(:err, :problem => problem) } - let!(:notice_1_1) { Fabricate(:notice, :err => err_1) } - let!(:notice_1_2) { Fabricate(:notice, :err => err_1) } - let!(:notice_2_1) { Fabricate(:notice, :err => err_2) } - let!(:notice_2_2) { Fabricate(:notice, :err => err_2) } + let!(:comment_1) { Fabricate(:comment, err: problem) } + let!(:comment_2) { Fabricate(:comment, err: problem) } + let!(:err_1) { Fabricate(:err, problem: problem) } + let!(:err_2) { Fabricate(:err, problem: problem) } + let!(:notice_1_1) { Fabricate(:notice, err: err_1) } + let!(:notice_1_2) { Fabricate(:notice, err: err_1) } + let!(:notice_2_1) { Fabricate(:notice, err: err_2) } + let!(:notice_2_2) { Fabricate(:notice, err: err_2) } it 'should all destroy' do problem_destroy.execute - expect(Problem.where(:_id => problem.id).entries).to be_empty - expect(Err.where(:_id => err_1.id).entries).to be_empty - expect(Err.where(:_id => err_2.id).entries).to be_empty - expect(Comment.where(:_id => comment_1.id).entries).to be_empty - expect(Comment.where(:_id => comment_2.id).entries).to be_empty - expect(Notice.where(:_id => notice_1_1.id).entries).to be_empty - expect(Notice.where(:_id => notice_1_2.id).entries).to be_empty - expect(Notice.where(:_id => notice_2_1.id).entries).to be_empty - expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty + expect(Problem.where(_id: problem.id).entries).to be_empty + expect(Err.where(_id: err_1.id).entries).to be_empty + expect(Err.where(_id: err_2.id).entries).to be_empty + expect(Comment.where(_id: comment_1.id).entries).to be_empty + expect(Comment.where(_id: comment_2.id).entries).to be_empty + expect(Notice.where(_id: notice_1_1.id).entries).to be_empty + expect(Notice.where(_id: notice_1_2.id).entries).to be_empty + expect(Notice.where(_id: notice_2_1.id).entries).to be_empty + expect(Notice.where(_id: notice_2_2.id).entries).to be_empty end end end diff --git a/spec/interactors/problem_merge_spec.rb b/spec/interactors/problem_merge_spec.rb index 88de144..d72295c 100644 --- a/spec/interactors/problem_merge_spec.rb +++ b/spec/interactors/problem_merge_spec.rb @@ -25,8 +25,8 @@ describe ProblemMerge do } let(:first_errs) { problem.errs } let(:merged_errs) { problem_1.errs } - let!(:notice) { Fabricate(:notice, :err => first_errs.first) } - let!(:notice_1) { Fabricate(:notice, :err => merged_errs.first) } + let!(:notice) { Fabricate(:notice, err: first_errs.first) } + let!(:notice_1) { Fabricate(:notice, err: merged_errs.first) } it 'delete one of problem' do expect { @@ -52,8 +52,8 @@ describe ProblemMerge do end context "with problem with comment" do - let!(:comment) { Fabricate(:comment, :err => problem) } - let!(:comment_2) { Fabricate(:comment, :err => problem_1, :user => comment.user) } + let!(:comment) { Fabricate(:comment, err: problem) } + let!(:comment_2) { Fabricate(:comment, err: problem_1, user: comment.user) } it 'merge comment' do expect { problem_merge.merge diff --git a/spec/interactors/resolved_problem_clearer_spec.rb b/spec/interactors/resolved_problem_clearer_spec.rb index 4fa7fbf..a10e48f 100644 --- a/spec/interactors/resolved_problem_clearer_spec.rb +++ b/spec/interactors/resolved_problem_clearer_spec.rb @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do end it 'not repair database' do allow(Mongoid.default_client).to receive(:command).and_call_original - expect(Mongoid.default_client).to_not receive(:command).with({ :repairDatabase => 1 }) + expect(Mongoid.default_client).to_not receive(:command).with({ repairDatabase: 1 }) resolved_problem_clearer.execute end end @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do context "with problem resolve" do before do allow(Mongoid.default_client).to receive(:command).and_call_original - allow(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) + allow(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) problems.first.resolve! problems.second.resolve! end @@ -39,12 +39,12 @@ describe ResolvedProblemClearer do }.to change { Problem.count }.by(-2) - expect(Problem.where(:_id => problems.first.id).first).to be_nil - expect(Problem.where(:_id => problems.second.id).first).to be_nil + expect(Problem.where(_id: problems.first.id).first).to be_nil + expect(Problem.where(_id: problems.second.id).first).to be_nil end it 'repair database' do - expect(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) + expect(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) resolved_problem_clearer.execute end end diff --git a/spec/interactors/user_destroy_spec.rb b/spec/interactors/user_destroy_spec.rb index f935d4d..c708d68 100644 --- a/spec/interactors/user_destroy_spec.rb +++ b/spec/interactors/user_destroy_spec.rb @@ -2,8 +2,8 @@ describe UserDestroy do let(:app) { Fabricate( :app, - :watchers => [ - Fabricate.build(:user_watcher, :user => user) + watchers: [ + Fabricate.build(:user_watcher, user: user) ]) } @@ -19,7 +19,7 @@ describe UserDestroy do expect { UserDestroy.new(user).destroy }.to change { - app.reload.watchers.where(:user_id => user.id).count + app.reload.watchers.where(user_id: user.id).count }.from(1).to(0) end end diff --git a/spec/lib/configurator_spec.rb b/spec/lib/configurator_spec.rb index bd6383d..eda3a49 100644 --- a/spec/lib/configurator_spec.rb +++ b/spec/lib/configurator_spec.rb @@ -29,7 +29,7 @@ describe Configurator do it 'overrides can refer to other values' do result = Configurator.run({ - one: ['VARONE', ->(values) { values[:one] }], + one: ['VARONE', ->(values) { values[:one] }], three: ['VARTHREE'] }) expect(result.one).to eq('zoom') diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb index 23af8b8..e54b6b0 100644 --- a/spec/mailers/mailer_spec.rb +++ b/spec/mailers/mailer_spec.rb @@ -41,8 +41,8 @@ describe Mailer do let(:app) do a = notice.app a.update_attributes( - :asset_host => "http://example.com", - :notify_all_users => true + asset_host: "http://example.com", + notify_all_users: true ) a end @@ -55,8 +55,8 @@ describe Mailer do let(:error_report) do instance_double( 'ErrorReport', - notice: notice, - app: app, + notice: notice, + app: app, problem: problem ) end @@ -85,7 +85,7 @@ describe Mailer do end context 'with a very long message' do - let(:notice) { Fabricate(:notice, :message => 6.times.collect { |_a| "0123456789" }.join('')) } + let(:notice) { Fabricate(:notice, message: 6.times.collect { |_a| "0123456789" }.join('')) } it "should truncate the long message" do expect(email.subject).to match(/ \d{47}\.{3}$/) end @@ -97,13 +97,13 @@ describe Mailer do include EmailSpec::Matchers let!(:notice) { Fabricate(:notice) } - let!(:comment) { Fabricate(:comment, :err => notice.problem) } - let!(:watcher) { Fabricate(:watcher, :app => comment.app) } + let!(:comment) { Fabricate(:comment, err: notice.problem) } + let!(:watcher) { Fabricate(:watcher, app: comment.app) } let(:recipients) { ['recipient@example.com', 'another@example.com'] } before do expect(comment).to receive(:notification_recipients).and_return(recipients) - Fabricate(:notice, :err => notice.err) + Fabricate(:notice, err: notice.err) @email = Mailer.comment_notification(comment).deliver_now end diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 1388880..9bfca9c 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -9,21 +9,21 @@ describe App, type: 'model' do context 'validations' do it 'requires a name' do - app = Fabricate.build(:app, :name => nil) + app = Fabricate.build(:app, name: nil) expect(app).to_not be_valid expect(app.errors[:name]).to include("can't be blank") end it 'requires unique names' do - Fabricate(:app, :name => 'Errbit') - app = Fabricate.build(:app, :name => 'Errbit') + Fabricate(:app, name: 'Errbit') + app = Fabricate.build(:app, name: 'Errbit') expect(app).to_not be_valid expect(app.errors[:name]).to include('is already taken') end it 'requires unique api_keys' do - Fabricate(:app, :api_key => 'APIKEY') - app = Fabricate.build(:app, :api_key => 'APIKEY') + Fabricate(:app, api_key: 'APIKEY') + app = Fabricate.build(:app, api_key: 'APIKEY') expect(app).to_not be_valid expect(app.errors[:api_key]).to include('is already taken') end @@ -31,24 +31,24 @@ describe App, type: 'model' do describe '<=>' do it 'is compared by unresolved count' do - app_0 = stub_model(App, :name => 'app', :unresolved_count => 1, :problem_count => 1) - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) + app_0 = stub_model(App, name: 'app', unresolved_count: 1, problem_count: 1) + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1) expect(app_0).to be < app_1 expect(app_1).to be > app_0 end it 'is compared by problem count' do - app_0 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 0) + app_0 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1) + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 0) expect(app_0).to be < app_1 expect(app_1).to be > app_0 end it 'is compared by name' do - app_0 = stub_model(App, :name => 'app_0', :unresolved_count => 0, :problem_count => 0) - app_1 = stub_model(App, :name => 'app_1', :unresolved_count => 0, :problem_count => 0) + app_0 = stub_model(App, name: 'app_0', unresolved_count: 0, problem_count: 0) + app_1 = stub_model(App, name: 'app_1', unresolved_count: 0, problem_count: 0) expect(app_0).to be < app_1 expect(app_1).to be > app_0 @@ -69,31 +69,31 @@ describe App, type: 'model' do end it 'is fine with blank github repos' do - app = Fabricate.build(:app, :github_repo => "") + app = Fabricate.build(:app, github_repo: "") app.save expect(app.github_repo).to eq "" end it 'doesnt touch github user/repo' do - app = Fabricate.build(:app, :github_repo => "errbit/errbit") + app = Fabricate.build(:app, github_repo: "errbit/errbit") app.save expect(app.github_repo).to eq "errbit/errbit" end it 'removes domain from https github repos' do - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit") + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit") app.save expect(app.github_repo).to eq "errbit/errbit" end it 'normalizes public git repo as a github repo' do - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit.git") + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit.git") app.save expect(app.github_repo).to eq "errbit/errbit" end it 'normalizes private git repo as a github repo' do - app = Fabricate.build(:app, :github_repo => "git@github.com:errbit/errbit.git") + app = Fabricate.build(:app, github_repo: "git@github.com:errbit/errbit.git") app.save expect(app.github_repo).to eq "errbit/errbit" end @@ -101,14 +101,14 @@ describe App, type: 'model' do context '#github_url_to_file' do it 'resolves to full path to file' do - app = Fabricate(:app, :github_repo => "errbit/errbit") + app = Fabricate(:app, github_repo: "errbit/errbit") expect(app.github_url_to_file('path/to/file')).to eq "https://github.com/errbit/errbit/blob/master/path/to/file" end end context '#github_repo?' do it 'is true when there is a github_repo' do - app = Fabricate(:app, :github_repo => "errbit/errbit") + app = Fabricate(:app, github_repo: "errbit/errbit") expect(app.github_repo?).to be(true) end @@ -122,7 +122,7 @@ describe App, type: 'model' do it "should send notices to either all users plus watchers, or the configured watchers" do @app = Fabricate(:app) 3.times { Fabricate(:user) } - 5.times { Fabricate(:watcher, :app => @app) } + 5.times { Fabricate(:watcher, app: @app) } @app.notify_all_users = true expect(@app.notification_recipients.size).to eq 8 @app.notify_all_users = false @@ -132,19 +132,19 @@ describe App, type: 'model' do context "emailable?" do it "should be true if notify on errs and there are notification recipients" do - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) - 2.times { Fabricate(:watcher, :app => app) } + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false) + 2.times { Fabricate(:watcher, app: app) } expect(app.emailable?).to be(true) end it "should be false if notify on errs is disabled" do - app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) - 2.times { Fabricate(:watcher, :app => app) } + app = Fabricate(:app, notify_on_errs: false, notify_all_users: false) + 2.times { Fabricate(:watcher, app: app) } expect(app.emailable?).to be(false) end it "should be false if there are no notification recipients" do - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false) expect(app.watchers).to be_empty expect(app.emailable?).to be(false) end @@ -152,9 +152,9 @@ describe App, type: 'model' do context "copying attributes from existing app" do it "should only copy the necessary fields" do - @app = Fabricate(:app, :name => "app", :github_repo => "url") - @copy_app = Fabricate(:app, :name => "copy_app", :github_repo => "copy url") - @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) + @app = Fabricate(:app, name: "app", github_repo: "url") + @copy_app = Fabricate(:app, name: "copy_app", github_repo: "copy url") + @copy_watcher = Fabricate(:watcher, email: "copywatcher@example.com", app: @copy_app) @app.copy_attributes_from(@copy_app.id) expect(@app.name).to eq "app" expect(@app.github_repo).to eq "copy url" @@ -166,18 +166,18 @@ describe App, type: 'model' do let(:app) { Fabricate(:app) } let(:conditions) { { - :error_class => 'Whoops', - :environment => 'production', - :fingerprint => 'some-finger-print' + error_class: 'Whoops', + environment: 'production', + fingerprint: 'some-finger-print' } } it 'returns the correct err if one already exists' do existing = Fabricate(:err, { - :problem => Fabricate(:problem, :app => app), - :fingerprint => conditions[:fingerprint] + problem: Fabricate(:problem, app: app), + fingerprint: conditions[:fingerprint] }) - expect(Err.where(:fingerprint => conditions[:fingerprint]).first).to eq existing + expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing expect(app.find_or_create_err!(conditions)).to eq existing end @@ -195,8 +195,8 @@ describe App, type: 'model' do context "without error_class" do let(:conditions) { { - :environment => 'production', - :fingerprint => 'some-finger-print' + environment: 'production', + fingerprint: 'some-finger-print' } } it 'save the err' do diff --git a/spec/models/comment_observer_spec.rb b/spec/models/comment_observer_spec.rb index dda3e92..299928f 100644 --- a/spec/models/comment_observer_spec.rb +++ b/spec/models/comment_observer_spec.rb @@ -8,7 +8,7 @@ describe "Callback on Comment", type: 'model' do it 'should send an email notification' do expect(Mailer).to receive(:comment_notification). with(comment). - and_return(double('email', :deliver_now => true)) + and_return(double('email', deliver_now: true)) comment.save end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 8ad3fb4..7f4ab5c 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,7 +1,7 @@ describe Comment, type: 'model' do context 'validations' do it 'should require a body' do - comment = Fabricate.build(:comment, :body => nil) + comment = Fabricate.build(:comment, body: nil) expect(comment).to_not be_valid expect(comment.errors[:body]).to include("can't be blank") end @@ -9,13 +9,13 @@ describe Comment, type: 'model' do context 'notification_recipients' do let(:app) { Fabricate(:app) } - let!(:watcher) { Fabricate(:watcher, :app => app) } - let(:err) { Fabricate(:problem, :app => app) } - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') } - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) } + let!(:watcher) { Fabricate(:watcher, app: app) } + let(:err) { Fabricate(:problem, app: app) } + let(:comment_user) { Fabricate(:user, email: 'author@example.com') } + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) } before do - Fabricate(:user_watcher, :app => app, :user => comment_user) + Fabricate(:user_watcher, app: app, user: comment_user) end it 'includes app notification_recipients except user email' do @@ -24,14 +24,14 @@ describe Comment, type: 'model' do end context 'emailable?' do - let(:app) { Fabricate(:app, :notify_on_errs => true) } - let!(:watcher) { Fabricate(:watcher, :app => app) } - let(:err) { Fabricate(:problem, :app => app) } - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') } - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) } + let(:app) { Fabricate(:app, notify_on_errs: true) } + let!(:watcher) { Fabricate(:watcher, app: app) } + let(:err) { Fabricate(:problem, app: app) } + let(:comment_user) { Fabricate(:user, email: 'author@example.com') } + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) } before do - Fabricate(:user_watcher, :app => app, :user => comment_user) + Fabricate(:user_watcher, app: app, user: comment_user) end it 'should be true if app is emailable? and there are notification recipients' do diff --git a/spec/models/deploy_observer_spec.rb b/spec/models/deploy_observer_spec.rb index cece4fe..e578565 100644 --- a/spec/models/deploy_observer_spec.rb +++ b/spec/models/deploy_observer_spec.rb @@ -3,15 +3,15 @@ describe "Callback on Deploy", type: 'model' do context 'and the app should notify on deploys' do it 'should send an email notification' do expect(Mailer).to receive(:deploy_notification). - and_return(double('email', :deliver_now => true)) - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) + and_return(double('email', deliver_now: true)) + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: true)) end end context 'and the app is not set to notify on deploys' do it 'should not send an email notification' do expect(Mailer).to_not receive(:deploy_notification) - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: false)) end end end diff --git a/spec/models/deploy_spec.rb b/spec/models/deploy_spec.rb index fab2e54..85cb068 100644 --- a/spec/models/deploy_spec.rb +++ b/spec/models/deploy_spec.rb @@ -1,13 +1,13 @@ describe Deploy, type: 'model' do context 'validations' do it 'requires a username' do - deploy = Fabricate.build(:deploy, :username => nil) + deploy = Fabricate.build(:deploy, username: nil) expect(deploy).to_not be_valid expect(deploy.errors[:username]).to include("can't be blank") end it 'requires an environment' do - deploy = Fabricate.build(:deploy, :environment => nil) + deploy = Fabricate.build(:deploy, environment: nil) expect(deploy).to_not be_valid expect(deploy.errors[:environment]).to include("can't be blank") end @@ -16,19 +16,19 @@ describe Deploy, type: 'model' do context 'being created' do context 'when the app has resolve_errs_on_deploy set to false' do it 'should not resolve the apps errs' do - app = Fabricate(:app, :resolve_errs_on_deploy => false) - @problems = 3.times.map { Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app)) } - Fabricate(:deploy, :app => app) + app = Fabricate(:app, resolve_errs_on_deploy: false) + @problems = 3.times.map { Fabricate(:err, problem: Fabricate(:problem, resolved: false, app: app)) } + Fabricate(:deploy, app: app) expect(app.reload.problems.none?(&:resolved?)).to eq true end end context 'when the app has resolve_errs_on_deploy set to true' do it 'should resolve the apps errs that were in the same environment' do - app = Fabricate(:app, :resolve_errs_on_deploy => true) - @prod_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'production') } - @staging_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging') } - Fabricate(:deploy, :app => app, :environment => 'production') + app = Fabricate(:app, resolve_errs_on_deploy: true) + @prod_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'production') } + @staging_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'staging') } + Fabricate(:deploy, app: app, environment: 'production') expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false end @@ -36,6 +36,6 @@ describe Deploy, type: 'model' do end it "should produce a shortened revision with 7 characters" do - expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567" + expect(Deploy.new(revision: "1234567890abcdef").short_revision).to eq "1234567" end end diff --git a/spec/models/err_spec.rb b/spec/models/err_spec.rb index 07a7351..85d69f5 100644 --- a/spec/models/err_spec.rb +++ b/spec/models/err_spec.rb @@ -1,13 +1,13 @@ describe Err, type: 'model' do context 'validations' do it 'requires a fingerprint' do - err = Fabricate.build(:err, :fingerprint => nil) + err = Fabricate.build(:err, fingerprint: nil) expect(err).to_not be_valid expect(err.errors[:fingerprint]).to include("can't be blank") end it 'requires a problem' do - err = Fabricate.build(:err, :problem_id => nil, :problem => nil) + err = Fabricate.build(:err, problem_id: nil, problem: nil) expect(err).to_not be_valid expect(err.errors[:problem_id]).to include("can't be blank") end diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb index 690e439..506cfef 100644 --- a/spec/models/error_report_spec.rb +++ b/spec/models/error_report_spec.rb @@ -26,7 +26,7 @@ describe ErrorReport do let!(:app) { Fabricate( :app, - :api_key => 'APIKEY' + api_key: 'APIKEY' ) } @@ -68,9 +68,9 @@ describe ErrorReport do context "with notice generate by Airbrake gem" do let(:xml) { Airbrake::Notice.new( - :exception => Exception.new, - :api_key => 'APIKEY', - :project_root => Rails.root + exception: Exception.new, + api_key: 'APIKEY', + project_root: Rails.root ).to_xml } it 'save a notice' do @@ -159,7 +159,7 @@ describe ErrorReport do problem = error_report.problem problem.update( resolved_at: Time.zone.now, - resolved: true + resolved: true ) error_report = ErrorReport.new(xml) @@ -223,7 +223,7 @@ describe ErrorReport do context "with notification service configured" do before do app.notify_on_errs = true - app.watchers.build(:email => 'foo@example.com') + app.watchers.build(email: 'foo@example.com') app.save end @@ -271,7 +271,7 @@ describe ErrorReport do end context "with not valid api_key" do before do - App.where(:api_key => app.api_key).delete_all + App.where(api_key: app.api_key).delete_all end it "return false" do expect(error_report.valid?).to be false diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index ec16164..0f48ee1 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -2,27 +2,27 @@ describe "Callback on Notice", type: 'model' do let(:notice_attrs_for) do lambda do |api_key| { - error_class: "HoptoadTestingException", - message: "some message", - backtrace: [ + error_class: "HoptoadTestingException", + message: "some message", + backtrace: [ { "number" => "425", "file" => "[GEM_ROOT]/callbacks.rb", "method" => "__callbacks" } ], - request: { "component" => "application" }, + request: { "component" => "application" }, server_environment: { "project-root" => "/path/to/sample/project", "environment-name" => "development" }, - api_key: api_key, - notifier: { + api_key: api_key, + notifier: { "name" => "Hoptoad Notifier", "version" => "2.3.2", "url" => "http://hoptoadapp.com" }, - framework: "Rails: 3.2.11" + framework: "Rails: 3.2.11" } end end @@ -49,7 +49,7 @@ describe "Callback on Notice", type: 'model' do @problem.update_attributes notices_count: threshold - 1 expect(Mailer).to receive(:err_notification). - and_return(double('email', :deliver_now => true)) + and_return(double('email', deliver_now: true)) error_report = ErrorReport.new(notice_attrs) error_report.generate_notice! @@ -77,7 +77,7 @@ describe "Callback on Notice", type: 'model' do let(:app) do Fabricate( :app_with_watcher, - notify_on_errs: true, + notify_on_errs: true, email_at_notices: [1, 100] ) end @@ -95,7 +95,7 @@ describe "Callback on Notice", type: 'model' do err.problem.resolve! expect(Mailer).to receive(:err_notification). - and_return(double('email', :deliver_now => true)) + and_return(double('email', deliver_now: true)) ErrorReport.new(notice_attrs).generate_notice! end @@ -106,7 +106,7 @@ describe "Callback on Notice", type: 'model' do let(:app) do Fabricate( :app_with_watcher, - notify_on_errs: true, + notify_on_errs: true, notification_service: notification_service ) end @@ -121,7 +121,7 @@ describe "Callback on Notice", type: 'model' do expect(error_report.app.notification_service). to receive(:create_notification).and_raise(ArgumentError) expect(Mailer). - to receive(:err_notification).and_return(double(:deliver_now => true)) + to receive(:err_notification).and_return(double(deliver_now: true)) error_report.generate_notice! end diff --git a/spec/models/notice_spec.rb b/spec/models/notice_spec.rb index b99a3b9..97d222f 100644 --- a/spec/models/notice_spec.rb +++ b/spec/models/notice_spec.rb @@ -1,19 +1,19 @@ describe Notice, type: 'model' do context 'validations' do it 'requires a backtrace' do - notice = Fabricate.build(:notice, :backtrace => nil) + notice = Fabricate.build(:notice, backtrace: nil) expect(notice).to_not be_valid expect(notice.errors[:backtrace_id]).to include("can't be blank") end it 'requires the server_environment' do - notice = Fabricate.build(:notice, :server_environment => nil) + notice = Fabricate.build(:notice, server_environment: nil) expect(notice).to_not be_valid expect(notice.errors[:server_environment]).to include("can't be blank") end it 'requires the notifier' do - notice = Fabricate.build(:notice, :notifier => nil) + notice = Fabricate.build(:notice, notifier: nil) expect(notice).to_not be_valid expect(notice.errors[:notifier]).to include("can't be blank") end @@ -57,7 +57,7 @@ describe Notice, type: 'model' do describe "user agent" do it "should be parsed and human-readable" do - notice = Fabricate.build(:notice, :request => { 'cgi-data' => { + 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' } }) expect(notice.user_agent.browser).to eq 'Chrome' @@ -72,7 +72,7 @@ describe Notice, type: 'model' do describe "user agent string" do it "should be parsed and human-readable" do - 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' } }) + 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' } }) expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)' end @@ -84,22 +84,22 @@ describe Notice, type: 'model' do describe "host" do it "returns host if url is valid" do - notice = Fabricate.build(:notice, :request => { 'url' => "http://example.com/resource/12" }) + notice = Fabricate.build(:notice, request: { 'url' => "http://example.com/resource/12" }) expect(notice.host).to eq 'example.com' end it "returns 'N/A' when url is not valid" do - notice = Fabricate.build(:notice, :request => { 'url' => "file:///path/to/some/resource/12" }) + notice = Fabricate.build(:notice, request: { 'url' => "file:///path/to/some/resource/12" }) expect(notice.host).to eq 'N/A' end it "returns 'N/A' when url is not valid" do - notice = Fabricate.build(:notice, :request => { 'url' => "some string" }) + notice = Fabricate.build(:notice, request: { 'url' => "some string" }) expect(notice.host).to eq 'N/A' end it "returns 'N/A' when url is empty" do - notice = Fabricate.build(:notice, :request => {}) + notice = Fabricate.build(:notice, request: {}) expect(notice.host).to eq 'N/A' end end diff --git a/spec/models/notification_service/campfire_service_spec.rb b/spec/models/notification_service/campfire_service_spec.rb index f883c68..f12d92c 100644 --- a/spec/models/notification_service/campfire_service_spec.rb +++ b/spec/models/notification_service/campfire_service_spec.rb @@ -2,7 +2,7 @@ describe NotificationServices::CampfireService, type: 'model' do it "it should send a notification to campfire" do # setup notice = Fabricate :notice - notification_service = Fabricate :campfire_notification_service, :app => notice.app + notification_service = Fabricate :campfire_notification_service, app: notice.app problem = notice.problem #campy stubbing diff --git a/spec/models/notification_service/flowdock_service_spec.rb b/spec/models/notification_service/flowdock_service_spec.rb index b77ab7a..641c59e 100644 --- a/spec/models/notification_service/flowdock_service_spec.rb +++ b/spec/models/notification_service/flowdock_service_spec.rb @@ -1,7 +1,7 @@ describe NotificationServices::FlowdockService, type: 'model' do let(:service) { Fabricate.build(:flowdock_notification_service) } - let(:app) { Fabricate(:app, :name => 'App #3') } - let(:problem) { Fabricate(:problem, :app => app, :message => '<3') } + let(:app) { Fabricate(:app, name: 'App #3') } + let(:problem) { Fabricate(:problem, app: app, message: '<3') } it 'sends message in appropriate format' do allow_any_instance_of(Flowdock::Flow).to receive(:push_to_team_inbox) do |*args| diff --git a/spec/models/notification_service/gtalk_service_spec.rb b/spec/models/notification_service/gtalk_service_spec.rb index 6d6351d..6c98db5 100644 --- a/spec/models/notification_service/gtalk_service_spec.rb +++ b/spec/models/notification_service/gtalk_service_spec.rb @@ -3,7 +3,7 @@ describe NotificationServices::GtalkService, type: 'model' do # setup notice = Fabricate :notice notice.problem - notification_service = Fabricate :gtalk_notification_service, :app => notice.app + notification_service = Fabricate :gtalk_notification_service, app: notice.app problem = notice.problem #gtalk stubbing @@ -35,7 +35,7 @@ describe NotificationServices::GtalkService, type: 'model' do before(:each) do # setup @notice = Fabricate :notice - @notification_service = Fabricate :gtalk_notification_service, :app => @notice.app + @notification_service = Fabricate :gtalk_notification_service, app: @notice.app @problem = @notice.problem @error_msg = """#{@problem.app.name} #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{@problem.app.id} @@ -94,7 +94,7 @@ describe NotificationServices::GtalkService, type: 'model' do # setup notice = Fabricate :notice notice.problem - notification_service = Fabricate :gtalk_notification_service, :app => notice.app + notification_service = Fabricate :gtalk_notification_service, app: notice.app problem = notice.problem #gtalk stubbing diff --git a/spec/models/notification_service/hoiio_service_spec.rb b/spec/models/notification_service/hoiio_service_spec.rb index 870a90f..4dc7036 100644 --- a/spec/models/notification_service/hoiio_service_spec.rb +++ b/spec/models/notification_service/hoiio_service_spec.rb @@ -2,7 +2,7 @@ describe NotificationServices::HoiioService, type: 'model' do it "it should send a notification to hoiio" do # setup notice = Fabricate :notice - notification_service = Fabricate :hoiio_notification_service, :app => notice.app + notification_service = Fabricate :hoiio_notification_service, app: notice.app problem = notice.problem # hoi stubbing diff --git a/spec/models/notification_service/hubot_service_spec.rb b/spec/models/notification_service/hubot_service_spec.rb index 6a6a475..029c6d4 100644 --- a/spec/models/notification_service/hubot_service_spec.rb +++ b/spec/models/notification_service/hubot_service_spec.rb @@ -2,11 +2,11 @@ describe NotificationServices::HubotService, type: 'model' do it "it should send a notification to Hubot" do # setup notice = Fabricate :notice - notification_service = Fabricate :hubot_notification_service, :app => notice.app + notification_service = Fabricate :hubot_notification_service, app: notice.app problem = notice.problem # faraday stubbing - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => { :message => an_instance_of(String), :room => notification_service.room_id }).and_return(true) + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: { message: an_instance_of(String), room: notification_service.room_id }).and_return(true) notification_service.create_notification(problem) end diff --git a/spec/models/notification_service/notification_service_spec.rb b/spec/models/notification_service/notification_service_spec.rb index 0d8cad5..c1e40aa 100644 --- a/spec/models/notification_service/notification_service_spec.rb +++ b/spec/models/notification_service/notification_service_spec.rb @@ -1,6 +1,6 @@ describe NotificationServices, type: 'model' do let(:notice) { Fabricate :notice } - let(:notification_service) { Fabricate :notification_service, :app => notice.app } + let(:notification_service) { Fabricate :notification_service, app: notice.app } let(:problem) { notice.problem } it "it should use http by default in #problem_url" do diff --git a/spec/models/notification_service/pushover_service_spec.rb b/spec/models/notification_service/pushover_service_spec.rb index f6014b7..d0afabf 100644 --- a/spec/models/notification_service/pushover_service_spec.rb +++ b/spec/models/notification_service/pushover_service_spec.rb @@ -2,7 +2,7 @@ describe NotificationServices::PushoverService, type: 'model' do it "it should send a notification to Pushover" do # setup notice = Fabricate :notice - notification_service = Fabricate :pushover_notification_service, :app => notice.app + notification_service = Fabricate :pushover_notification_service, app: notice.app problem = notice.problem # hoi stubbing diff --git a/spec/models/notification_service/slack_service_spec.rb b/spec/models/notification_service/slack_service_spec.rb index 5b6dd54..3e52a6c 100644 --- a/spec/models/notification_service/slack_service_spec.rb +++ b/spec/models/notification_service/slack_service_spec.rb @@ -2,52 +2,52 @@ describe NotificationServices::SlackService, type: 'model' do it "it should send a notification to Slack with hook url" do # setup notice = Fabricate :notice - notification_service = Fabricate :slack_notification_service, :app => notice.app, :service_url => "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX" + notification_service = Fabricate :slack_notification_service, app: notice.app, service_url: "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX" problem = notice.problem # faraday stubbing payload = { - :attachments => [ + attachments: [ { - :fallback => notification_service.message_for_slack(problem), - :pretext => "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", - :color => "#D00000", - :fields => [ + fallback: notification_service.message_for_slack(problem), + pretext: "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", + color: "#D00000", + fields: [ { - :title => "Environment", - :value => problem.environment, - :short => false + title: "Environment", + value: problem.environment, + short: false }, { - :title => "Location", - :value => problem.where, - :short => false + title: "Location", + value: problem.where, + short: false }, { - :title => "Message", - :value => problem.message.to_s, - :short => false + title: "Message", + value: problem.message.to_s, + short: false }, { - :title => "First Noticed", - :value => problem.first_notice_at, - :short => false + title: "First Noticed", + value: problem.first_notice_at, + short: false }, { - :title => "Last Noticed", - :value => problem.last_notice_at, - :short => false + title: "Last Noticed", + value: problem.last_notice_at, + short: false }, { - :title => "Times Occurred", - :value => problem.notices_count, - :short => false + title: "Times Occurred", + value: problem.notices_count, + short: false } ] } ] }.to_json - expect(HTTParty).to receive(:post).with(notification_service.service_url, :body => payload, :headers => { "Content-Type" => "application/json" }).and_return(true) + expect(HTTParty).to receive(:post).with(notification_service.service_url, body: payload, headers: { "Content-Type" => "application/json" }).and_return(true) notification_service.create_notification(problem) end diff --git a/spec/models/notification_service/webhook_service_spec.rb b/spec/models/notification_service/webhook_service_spec.rb index 43c269b..1ecf11c 100644 --- a/spec/models/notification_service/webhook_service_spec.rb +++ b/spec/models/notification_service/webhook_service_spec.rb @@ -1,11 +1,11 @@ describe NotificationServices::WebhookService, type: 'model' do it "it should send a notification to a user-specified URL" do notice = Fabricate :notice - notification_service = Fabricate :webhook_notification_service, :app => notice.app + notification_service = Fabricate :webhook_notification_service, app: notice.app problem = notice.problem payload = notification_service.message_for_webhook(problem) - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => payload).and_return(true) + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: payload).and_return(true) notification_service.create_notification(problem) end diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index 17f7a7c..e3818fa 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -1,7 +1,7 @@ describe Problem, type: 'model' do context 'validations' do it 'requires an environment' do - err = Fabricate.build(:problem, :environment => nil) + err = Fabricate.build(:problem, environment: nil) expect(err).to_not be_valid expect(err.errors[:environment]).to include("can't be blank") end @@ -39,10 +39,10 @@ describe Problem, type: 'model' do problem = err.problem expect(problem).to_not be_nil - notice1 = Fabricate(:notice, :err => err) + notice1 = Fabricate(:notice, err: err) expect(problem.last_notice_at).to eq notice1.reload.created_at - notice2 = Fabricate(:notice, :err => err) + notice2 = Fabricate(:notice, err: err) expect(problem.last_notice_at).to eq notice2.reload.created_at end end @@ -53,10 +53,10 @@ describe Problem, type: 'model' do problem = err.problem expect(problem).to_not be_nil - notice1 = Fabricate(:notice, :err => err) + notice1 = Fabricate(:notice, err: err) expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) - Fabricate(:notice, :err => err) + Fabricate(:notice, err: err) expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) end end @@ -66,7 +66,7 @@ describe Problem, type: 'model' do err = Fabricate(:err) problem = err.problem expect { - Fabricate(:notice, :err => err, :message => 'ERR 1') + Fabricate(:notice, err: err, message: 'ERR 1') }.to change(problem, :message).from(nil).to('ERR 1') end end @@ -74,9 +74,9 @@ describe Problem, type: 'model' do context 'being created' do context 'when the app has err notifications set to false' do it 'should not send an email notification' do - app = Fabricate(:app_with_watcher, :notify_on_errs => false) + app = Fabricate(:app_with_watcher, notify_on_errs: false) expect(Mailer).to_not receive(:err_notification) - Fabricate(:problem, :app => app) + Fabricate(:problem, app: app) end end end @@ -114,7 +114,7 @@ describe Problem, type: 'model' do end it "should not reset notice count" do - problem = Fabricate(:problem, :notices_count => 1) + problem = Fabricate(:problem, notices_count: 1) original_notices_count = problem.notices_count expect(original_notices_count).to be > 0 @@ -157,8 +157,8 @@ describe Problem, type: 'model' do context "Scopes" do context "resolved" do it 'only finds resolved Problems' do - resolved = Fabricate(:problem, :resolved => true) - unresolved = Fabricate(:problem, :resolved => false) + resolved = Fabricate(:problem, resolved: true) + unresolved = Fabricate(:problem, resolved: false) expect(Problem.resolved.all).to include(resolved) expect(Problem.resolved.all).to_not include(unresolved) end @@ -166,8 +166,8 @@ describe Problem, type: 'model' do context "unresolved" do it 'only finds unresolved Problems' do - resolved = Fabricate(:problem, :resolved => true) - unresolved = Fabricate(:problem, :resolved => false) + resolved = Fabricate(:problem, resolved: true) + unresolved = Fabricate(:problem, resolved: false) expect(Problem.unresolved.all).to_not include(resolved) expect(Problem.unresolved.all).to include(unresolved) end @@ -175,15 +175,15 @@ describe Problem, type: 'model' do context "searching" do it 'finds the correct record' do - find = Fabricate(:problem, :resolved => false, :error_class => 'theErrorclass::other', - :message => "other", :where => 'errorclass', :environment => 'development', :app_name => 'other') - dont_find = Fabricate(:problem, :resolved => false, :error_class => "Batman", - :message => 'todo', :where => 'classerror', :environment => 'development', :app_name => 'other') + find = Fabricate(:problem, resolved: false, error_class: 'theErrorclass::other', + message: "other", where: 'errorclass', environment: 'development', app_name: 'other') + dont_find = Fabricate(:problem, resolved: false, error_class: "Batman", + message: 'todo', where: 'classerror', environment: 'development', app_name: 'other') expect(Problem.search("theErrorClass").unresolved).to include(find) expect(Problem.search("theErrorClass").unresolved).to_not include(dont_find) end it 'find on where message' do - problem = Fabricate(:problem, :where => 'cyril') + problem = Fabricate(:problem, where: 'cyril') expect(Problem.search('cyril').entries).to eq [problem] end end @@ -192,8 +192,8 @@ describe Problem, type: 'model' do context "notice counter cache" do before do @app = Fabricate(:app) - @problem = Fabricate(:problem, :app => @app) - @err = Fabricate(:err, :problem => @problem) + @problem = Fabricate(:problem, app: @app) + @err = Fabricate(:err, problem: @problem) end it "#notices_count returns 0 by default" do @@ -202,12 +202,12 @@ describe Problem, type: 'model' do it "adding a notice increases #notices_count by 1" do expect { - Fabricate(:notice, :err => @err, :message => 'ERR 1') + Fabricate(:notice, err: @err, message: 'ERR 1') }.to change(@problem.reload, :notices_count).from(0).to(1) end it "removing a notice decreases #notices_count by 1" do - Fabricate(:notice, :err => @err, :message => 'ERR 1') + Fabricate(:notice, err: @err, message: 'ERR 1') expect { @err.notices.first.destroy @problem.reload @@ -217,7 +217,7 @@ describe Problem, type: 'model' do context "#app_name" do let!(:app) { Fabricate(:app) } - let!(:problem) { Fabricate(:problem, :app => app) } + let!(:problem) { Fabricate(:problem, app: app) } before { app.reload } @@ -227,7 +227,7 @@ describe Problem, type: 'model' do it "is updated when an app is updated" do expect { - app.update_attributes!(:name => "Bar App") + app.update_attributes!(name: "Bar App") problem.reload }.to change(problem, :app_name).to("Bar App") end @@ -237,19 +237,19 @@ describe Problem, type: 'model' do before do @app = Fabricate(:app) @last_deploy = 10.days.ago - Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") + Fabricate(:deploy, app: @app, created_at: @last_deploy, environment: "production") end it "is set when a problem is created" do - problem = Fabricate(:problem, :app => @app, :environment => "production") + problem = Fabricate(:problem, app: @app, environment: "production") assert_equal @last_deploy, problem.last_deploy_at end it "is updated when a deploy is created" do - problem = Fabricate(:problem, :app => @app, :environment => "production") + problem = Fabricate(:problem, app: @app, environment: "production") next_deploy = 5.minutes.ago expect { - @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) + @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy) problem.reload }.to change { problem.last_deploy_at.iso8601 }. from(@last_deploy.iso8601). @@ -260,8 +260,8 @@ describe Problem, type: 'model' do context "notice messages cache" do before do @app = Fabricate(:app) - @problem = Fabricate(:problem, :app => @app) - @err = Fabricate(:err, :problem => @problem) + @problem = Fabricate(:problem, app: @app) + @err = Fabricate(:err, problem: @problem) end it "#messages should be empty by default" do @@ -269,7 +269,7 @@ describe Problem, type: 'model' do end it "removing a notice removes string from #messages" do - Fabricate(:notice, :err => @err, :message => 'ERR 1') + Fabricate(:notice, err: @err, message: 'ERR 1') expect { @err.notices.first.destroy @problem.reload @@ -277,7 +277,7 @@ describe Problem, type: 'model' do end it "removing a notice from the problem with broken counter should not raise an error" do - Fabricate(:notice, :err => @err, :message => 'ERR 1') + Fabricate(:notice, err: @err, message: 'ERR 1') @problem.messages = {} @problem.save! expect { @err.notices.first.destroy }.not_to raise_error @@ -287,8 +287,8 @@ describe Problem, type: 'model' do context "notice hosts cache" do before do @app = Fabricate(:app) - @problem = Fabricate(:problem, :app => @app) - @err = Fabricate(:err, :problem => @problem) + @problem = Fabricate(:problem, app: @app) + @err = Fabricate(:err, problem: @problem) end it "#hosts should be empty by default" do @@ -296,7 +296,7 @@ describe Problem, type: 'model' do end it "removing a notice removes string from #hosts" do - Fabricate(:notice, :err => @err, :request => { 'url' => "http://example.com/resource/12" }) + Fabricate(:notice, err: @err, request: { 'url' => "http://example.com/resource/12" }) expect { @err.notices.first.destroy @problem.reload @@ -307,8 +307,8 @@ describe Problem, type: 'model' do context "notice user_agents cache" do before do @app = Fabricate(:app) - @problem = Fabricate(:problem, :app => @app) - @err = Fabricate(:err, :problem => @problem) + @problem = Fabricate(:problem, app: @app) + @err = Fabricate(:err, problem: @problem) end it "#user_agents should be empty by default" do @@ -316,7 +316,7 @@ describe Problem, type: 'model' do end it "removing a notice removes string from #user_agents" do - 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' } }) + 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' } }) expect { @err.notices.first.destroy @problem.reload @@ -329,7 +329,7 @@ describe Problem, type: 'model' do context "comment counter cache" do before do @app = Fabricate(:app) - @problem = Fabricate(:problem, :app => @app) + @problem = Fabricate(:problem, app: @app) end it "#comments_count returns 0 by default" do @@ -338,12 +338,12 @@ describe Problem, type: 'model' do it "adding a comment increases #comments_count by 1" do expect { - Fabricate(:comment, :err => @problem) + Fabricate(:comment, err: @problem) }.to change(@problem, :comments_count).from(0).to(1) end it "removing a comment decreases #comments_count by 1" do - Fabricate(:comment, :err => @problem) + Fabricate(:comment, err: @problem) expect { @problem.reload.comments.first.destroy @problem.reload @@ -354,11 +354,11 @@ describe Problem, type: 'model' do describe "#issue_type" do context "without issue_type fill in Problem" do let(:problem) do - Problem.new(:app => app) + Problem.new(app: app) end let(:app) do - App.new(:issue_tracker => issue_tracker) + App.new(issue_tracker: issue_tracker) end context "without issue_tracker associate to app" do @@ -384,7 +384,7 @@ describe Problem, type: 'model' do context "with issue_tracker not valid associate to app" do let(:issue_tracker) do - IssueTracker.new(:type_tracker => 'fake') + IssueTracker.new(type_tracker: 'fake') end it 'return nil' do @@ -395,7 +395,7 @@ describe Problem, type: 'model' do context "with issue_type fill in Problem" do it 'return the value associate' do - expect(Problem.new(:issue_type => 'foo').issue_type).to eql 'foo' + expect(Problem.new(issue_type: 'foo').issue_type).to eql 'foo' end end end @@ -403,7 +403,7 @@ describe Problem, type: 'model' do describe '#recache' do let(:problem) { Fabricate(:problem_with_errs) } let(:first_errs) { problem.errs } - let!(:notice) { Fabricate(:notice, :err => first_errs.first) } + let!(:notice) { Fabricate(:notice, err: first_errs.first) } before do problem.update_attribute(:notices_count, 0) @@ -419,7 +419,7 @@ describe Problem, type: 'model' do context "with only one notice" do before do - problem.update_attributes!(:messages => {}) + problem.update_attributes!(messages: {}) problem.recache end @@ -456,10 +456,10 @@ describe Problem, type: 'model' do end context "with several notices" do - let!(:notice_2) { Fabricate(:notice, :err => first_errs.first) } - let!(:notice_3) { Fabricate(:notice, :err => first_errs.first) } + let!(:notice_2) { Fabricate(:notice, err: first_errs.first) } + let!(:notice_3) { Fabricate(:notice, err: first_errs.first) } before do - problem.update_attributes!(:messages => {}) + problem.update_attributes!(messages: {}) problem.recache end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e41a798..21aa8ff 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,37 +1,37 @@ describe User do context 'validations' do it 'require that a name is present' do - user = Fabricate.build(:user, :name => nil) + user = Fabricate.build(:user, name: nil) expect(user).to_not be_valid expect(user.errors[:name]).to include("can't be blank") end it 'requires password without github login' do - user = Fabricate.build(:user, :password => nil) + user = Fabricate.build(:user, password: nil) expect(user).to_not be_valid expect(user.errors[:password]).to include("can't be blank") end it "doesn't require password with github login" do - user = Fabricate.build(:user, :password => nil, :github_login => 'nashby') + user = Fabricate.build(:user, password: nil, github_login: 'nashby') expect(user).to be_valid end it 'requires uniq github login' do - user1 = Fabricate(:user, :github_login => 'nashby') + user1 = Fabricate(:user, github_login: 'nashby') expect(user1).to be_valid - user2 = Fabricate.build(:user, :github_login => 'nashby') + user2 = Fabricate.build(:user, github_login: 'nashby') user2.save expect(user2).to_not be_valid expect(user2.errors[:github_login]).to include("is already taken") end it 'allows blank / null github_login' do - user1 = Fabricate(:user, :github_login => ' ') + user1 = Fabricate(:user, github_login: ' ') expect(user1).to be_valid - user2 = Fabricate.build(:user, :github_login => ' ') + user2 = Fabricate.build(:user, github_login: ' ') user2.save expect(user2).to be_valid end @@ -43,7 +43,7 @@ describe User do allow($stdout).to receive(:puts).and_return(true) require Rails.root.join('db/seeds.rb') }.to change { - User.where(:admin => true).count + User.where(admin: true).count }.from(0).to(1) end end diff --git a/spec/models/watcher_spec.rb b/spec/models/watcher_spec.rb index 0b2f10d..5ba7d6a 100644 --- a/spec/models/watcher_spec.rb +++ b/spec/models/watcher_spec.rb @@ -1,7 +1,7 @@ describe Watcher, type: 'model' do context 'validations' do it 'requires an email address or an associated user' do - watcher = Fabricate.build(:watcher, :email => nil, :user => nil) + watcher = Fabricate.build(:watcher, email: nil, user: nil) expect(watcher).to_not be_valid expect(watcher.errors[:base]).to include("You must specify either a user or an email address") @@ -19,13 +19,13 @@ describe Watcher, type: 'model' do context 'address' do it "returns the user's email address if there is a user" do - user = Fabricate(:user, :email => 'foo@bar.com') - watcher = Fabricate(:user_watcher, :user => user) + user = Fabricate(:user, email: 'foo@bar.com') + watcher = Fabricate(:user_watcher, user: user) expect(watcher.address).to eq 'foo@bar.com' end it "returns the email if there is no user" do - watcher = Fabricate(:watcher, :email => 'widgets@acme.com') + watcher = Fabricate(:watcher, email: 'widgets@acme.com') expect(watcher.address).to eq 'widgets@acme.com' end end diff --git a/spec/requests/notices_controller_spec.rb b/spec/requests/notices_controller_spec.rb index 52f1cd4..8e2a149 100644 --- a/spec/requests/notices_controller_spec.rb +++ b/spec/requests/notices_controller_spec.rb @@ -1,12 +1,12 @@ describe "Notices management", type: 'request' do - let(:errbit_app) { Fabricate(:app, :api_key => 'APIKEY') } + let(:errbit_app) { Fabricate(:app, api_key: 'APIKEY') } describe "create a new notice" do context "with valide notice" do let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'save a new notice' do expect { - post '/notifier_api/v2/notices', :data => xml + post '/notifier_api/v2/notices', data: xml expect(response).to be_success }.to change { errbit_app.problems.count @@ -18,7 +18,7 @@ describe "Notices management", type: 'request' do let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } it 'save a new notice' do expect { - post '/notifier_api/v2/notices', :data => xml + post '/notifier_api/v2/notices', data: xml expect(response).to be_success }.to change { errbit_app.problems.count @@ -31,7 +31,7 @@ describe "Notices management", type: 'request' do let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'not save a new notice and return 422' do expect { - post '/notifier_api/v2/notices', :data => xml + post '/notifier_api/v2/notices', data: xml expect(response.status).to eq 422 expect(response.body).to eq "Your API key is unknown" }.to_not change(errbit_app.problems, :count) @@ -42,7 +42,7 @@ describe "Notices management", type: 'request' do let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'save a new notice' do expect { - get '/notifier_api/v2/notices', :data => xml + get '/notifier_api/v2/notices', data: xml expect(response).to be_success }.to change { errbit_app.problems.count diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7fcbb0a..5d33387 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,9 +36,9 @@ Mongoid::Tasks::Database.create_indexes ActionMailer::Base.delivery_method = :test RSpec.configure do |config| - config.include Devise::TestHelpers, :type => :controller - config.include Mongoid::Matchers, :type => :model - config.alias_example_to :fit, :focused => true + config.include Devise::TestHelpers, type: :controller + config.include Mongoid::Matchers, type: :model + config.alias_example_to :fit, focused: true config.before(:each) do Mongoid::Config.truncate! diff --git a/spec/support/macros.rb b/spec/support/macros.rb index d4b373f..aa7776d 100644 --- a/spec/support/macros.rb +++ b/spec/support/macros.rb @@ -1,15 +1,15 @@ def it_requires_authentication(options = {}) default_options = { - :for => { - :index => :get, - :show => :get, - :new => :get, - :create => :post, - :edit => :get, - :update => :put, - :destroy => :delete + for: { + index: :get, + show: :get, + new: :get, + create: :post, + edit: :get, + update: :put, + destroy: :delete }, - :params => { :id => '4c6c760494df2a18cc000015' } + params: { id: '4c6c760494df2a18cc000015' } } options.reverse_merge!(default_options) @@ -29,16 +29,16 @@ end def it_requires_admin_privileges(options = {}) default_options = { - :for => { - :index => :get, - :show => :get, - :new => :get, - :create => :post, - :edit => :get, - :update => :put, - :destroy => :delete + for: { + index: :get, + show: :get, + new: :get, + create: :post, + edit: :get, + update: :put, + destroy: :delete }, - :params => { :id => 'dummyid' } + params: { id: 'dummyid' } } options.reverse_merge!(default_options) diff --git a/spec/views/apps/index.html.haml_spec.rb b/spec/views/apps/index.html.haml_spec.rb index 5b513c4..aa37382 100644 --- a/spec/views/apps/index.html.haml_spec.rb +++ b/spec/views/apps/index.html.haml_spec.rb @@ -1,6 +1,6 @@ describe "apps/index.html.haml", type: 'view' do before do - app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.zone.now, :revision => "123456789abcdef")]) + app = stub_model(App, deploys: [stub_model(Deploy, created_at: Time.zone.now, revision: "123456789abcdef")]) allow(view).to receive(:apps).and_return([app]) allow(controller).to receive(:current_user).and_return(stub_model(User)) end diff --git a/spec/views/apps/new.html.haml_spec.rb b/spec/views/apps/new.html.haml_spec.rb index 5594d70..890c59c 100644 --- a/spec/views/apps/new.html.haml_spec.rb +++ b/spec/views/apps/new.html.haml_spec.rb @@ -16,7 +16,7 @@ describe "apps/new.html.haml", type: 'view' do it "should confirm the 'cancel' link" do render - expect(action_bar).to have_selector('a.button', :text => 'cancel') + expect(action_bar).to have_selector('a.button', text: 'cancel') end end diff --git a/spec/views/apps/show.atom.builder_spec.rb b/spec/views/apps/show.atom.builder_spec.rb index 08b2164..28e17af 100644 --- a/spec/views/apps/show.atom.builder_spec.rb +++ b/spec/views/apps/show.atom.builder_spec.rb @@ -1,6 +1,6 @@ describe "apps/show.atom.builder", type: 'view' do let(:app) { stub_model(App) } - let(:problems) { [stub_model(Problem, :message => 'foo', :app => app)] } + let(:problems) { [stub_model(Problem, message: 'foo', app: app)] } before do allow(view).to receive(:app).and_return(app) diff --git a/spec/views/apps/show.html.haml_spec.rb b/spec/views/apps/show.html.haml_spec.rb index cbec694..15eb6b6 100644 --- a/spec/views/apps/show.html.haml_spec.rb +++ b/spec/views/apps/show.html.haml_spec.rb @@ -17,7 +17,7 @@ describe "apps/show.html.haml", type: 'view' do it "should confirm the 'cancel' link" do render - expect(action_bar).to have_selector('a.button', :text => 'all errors') + expect(action_bar).to have_selector('a.button', text: 'all errors') end end diff --git a/spec/views/issue_trackers/issue.md.erb_spec.rb b/spec/views/issue_trackers/issue.md.erb_spec.rb index e344f93..ed8a9a0 100644 --- a/spec/views/issue_trackers/issue.md.erb_spec.rb +++ b/spec/views/issue_trackers/issue.md.erb_spec.rb @@ -1,7 +1,7 @@ describe "issue_trackers/issue.md.erb", type: 'view' do let(:problem) { problem = Fabricate(:problem) - Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) + Fabricate(:notice, err: Fabricate(:err, problem: problem)) problem } diff --git a/spec/views/issue_trackers/issue.txt.erb_spec.rb b/spec/views/issue_trackers/issue.txt.erb_spec.rb index fcd30e1..d9c6b8c 100644 --- a/spec/views/issue_trackers/issue.txt.erb_spec.rb +++ b/spec/views/issue_trackers/issue.txt.erb_spec.rb @@ -1,7 +1,7 @@ describe "issue_trackers/issue.txt.erb", type: 'view' do let(:problem) { problem = Fabricate(:problem) - Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) + Fabricate(:notice, err: Fabricate(:err, problem: problem)) problem } diff --git a/spec/views/notices/_summary.html.haml_spec.rb b/spec/views/notices/_summary.html.haml_spec.rb index 0ea37b2..13317f2 100644 --- a/spec/views/notices/_summary.html.haml_spec.rb +++ b/spec/views/notices/_summary.html.haml_spec.rb @@ -1,8 +1,8 @@ describe "notices/_summary.html.haml", type: 'view' do - let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } + let(:notice) { Fabricate(:notice, framework: 'Rails 3.2.11') } it "renders application framework" do - render "notices/summary", :notice => notice, :problem => notice.problem + render "notices/summary", notice: notice, problem: notice.problem expect(rendered).to have_content('Rails 3.2.11') end diff --git a/spec/views/notices/_user_attributes.html.haml_spec.rb b/spec/views/notices/_user_attributes.html.haml_spec.rb index af8e4ce..82d0ff4 100644 --- a/spec/views/notices/_user_attributes.html.haml_spec.rb +++ b/spec/views/notices/_user_attributes.html.haml_spec.rb @@ -2,13 +2,13 @@ describe "notices/_user_attributes.html.haml", type: 'view' do describe 'autolink' do let(:notice) do user_attributes = { 'foo' => { 'bar' => 'http://example.com' } } - Fabricate(:notice, :user_attributes => user_attributes) + Fabricate(:notice, user_attributes: user_attributes) end it "renders table with user attributes" do assign :app, notice.err.app - render "notices/user_attributes", :user => notice.user_attributes + render "notices/user_attributes", user: notice.user_attributes expect(rendered).to have_link('http://example.com') end end diff --git a/spec/views/problems/index.atom.builder_spec.rb b/spec/views/problems/index.atom.builder_spec.rb index 861ce4b..3a7b989 100644 --- a/spec/views/problems/index.atom.builder_spec.rb +++ b/spec/views/problems/index.atom.builder_spec.rb @@ -1,9 +1,9 @@ describe "problems/index.atom.builder", type: 'view' do it 'display problem message' do - app = App.new(:new_record => false) + app = App.new(new_record: false) allow(view).to receive(:problems).and_return([Problem.new( - :message => 'foo', - :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) + message: 'foo', + new_record: false, app: app), Problem.new(new_record: false, app: app)]) render expect(rendered).to match('foo') end diff --git a/spec/views/problems/index.html.haml_spec.rb b/spec/views/problems/index.html.haml_spec.rb index 3a9d07c..afa374c 100644 --- a/spec/views/problems/index.html.haml_spec.rb +++ b/spec/views/problems/index.html.haml_spec.rb @@ -1,6 +1,6 @@ describe "problems/index.html.haml", type: 'view' do let(:problem_1) { Fabricate(:problem) } - let(:problem_2) { Fabricate(:problem, :app => problem_1.app) } + let(:problem_2) { Fabricate(:problem, app: problem_1.app) } before do allow(view).to receive(:selected_problems).and_return([]) diff --git a/spec/views/problems/show.html.haml_spec.rb b/spec/views/problems/show.html.haml_spec.rb index b4e126d..5c971e6 100644 --- a/spec/views/problems/show.html.haml_spec.rb +++ b/spec/views/problems/show.html.haml_spec.rb @@ -53,9 +53,9 @@ describe "problems/show.html.haml", type: 'view' do def with_issue_tracker(tracker, _problem) allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(trackers) app.issue_tracker = IssueTrackerDecorator.new( - IssueTracker.new :type_tracker => tracker, :options => { - :api_token => "token token token", - :project_id => "1234" + IssueTracker.new type_tracker: tracker, options: { + api_token: "token token token", + project_id: "1234" }) end @@ -85,7 +85,7 @@ describe "problems/show.html.haml", type: 'view' do url = 'http://localhost:3000/problems' controller.request.env['HTTP_REFERER'] = url render - expect(action_bar).to have_selector("span a.up[href='#{url}']", :text => 'up') + expect(action_bar).to have_selector("span a.up[href='#{url}']", text: 'up') end it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do @@ -96,11 +96,11 @@ describe "problems/show.html.haml", type: 'view' do allow(view).to receive(:app).and_return(problem.app) render - expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') + expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", text: 'up') end context 'create issue links' do - let(:app) { Fabricate(:app, :github_repo => "test_user/test_repo") } + let(:app) { Fabricate(:app, github_repo: "test_user/test_repo") } it 'should allow creating issue for github if application has a github tracker' do problem = Fabricate(:problem_with_comments, app: app) @@ -113,8 +113,8 @@ describe "problems/show.html.haml", type: 'view' do end context "without issue tracker associate on app" do - let(:problem) { Problem.new(:new_record => false, :app => app) } - let(:app) { App.new(:new_record => false) } + let(:problem) { Problem.new(new_record: false, app: app) } + let(:app) { App.new(new_record: false) } it 'not see link to create issue' do render @@ -128,12 +128,12 @@ describe "problems/show.html.haml", type: 'view' do end context "with app having github_repo" do - let(:app) { App.new(:new_record => false, :github_repo => 'foo/bar') } - let(:problem) { Problem.new(:new_record => false, :app => app) } + let(:app) { App.new(new_record: false, github_repo: 'foo/bar') } + let(:problem) { Problem.new(new_record: false, app: app) } before do problem.issue_link = nil - user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef') + user = Fabricate(:user, github_login: 'test_user', github_oauth_token: 'abcdef') allow(controller).to receive(:current_user).and_return(user) end diff --git a/spec/views/problems/show.ics.haml_spec.rb b/spec/views/problems/show.ics.haml_spec.rb index 9bcfc3e..df04378 100644 --- a/spec/views/problems/show.ics.haml_spec.rb +++ b/spec/views/problems/show.ics.haml_spec.rb @@ -6,6 +6,6 @@ describe "problems/show.html.ics", type: 'view' do end it 'works' do - render :template => 'problems/show', :formats => [:ics], :handlers => [:haml] + render template: 'problems/show', formats: [:ics], handlers: [:haml] end end diff --git a/spec/views/users/edit.html.haml_spec.rb b/spec/views/users/edit.html.haml_spec.rb index 018a8cb..3d94ce9 100644 --- a/spec/views/users/edit.html.haml_spec.rb +++ b/spec/views/users/edit.html.haml_spec.rb @@ -1,5 +1,5 @@ describe 'users/edit.html.haml', type: 'view' do - let(:user) { stub_model(User, :name => 'shingara') } + let(:user) { stub_model(User, name: 'shingara') } before { allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:user).and_return(user) diff --git a/spec/views/users/index.html.haml_spec.rb b/spec/views/users/index.html.haml_spec.rb index 6d32479..20c82d3 100644 --- a/spec/views/users/index.html.haml_spec.rb +++ b/spec/views/users/index.html.haml_spec.rb @@ -3,7 +3,7 @@ describe 'users/index.html.haml', type: 'view' do before { allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:users).and_return( - Kaminari.paginate_array([user], :total_count => 1).page(1) + Kaminari.paginate_array([user], total_count: 1).page(1) ) } it 'should see users option' do diff --git a/spec/views/users/show.html.haml_spec.rb b/spec/views/users/show.html.haml_spec.rb index 5e9eeb0..7812ee3 100644 --- a/spec/views/users/show.html.haml_spec.rb +++ b/spec/views/users/show.html.haml_spec.rb @@ -1,6 +1,6 @@ describe 'users/show.html.haml', type: 'view' do let(:user) do - stub_model(User, :created_at => Time.zone.now, :email => "test@example.com") + stub_model(User, created_at: Time.zone.now, email: "test@example.com") end before do -- libgit2 0.21.2