From 7dc461eed78b12a0090c7cd57b6c5ec486b56722 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 23:03:02 +0100 Subject: [PATCH] Rubocop: remove unnecessary braces around parameters --- .rubocop_todo.yml | 6 ------ app/helpers/apps_helper.rb | 2 +- app/models/backtrace.rb | 2 +- app/models/problem.rb | 2 +- config/load.rb | 4 ++-- config/mongo.rb | 4 ++-- db/migrate/201510290041_extract_issue_tracker.rb | 4 +--- lib/tasks/errbit/demo.rake | 40 +++++++++++++++++++++------------------- spec/controllers/api/v1/notices_controller_spec.rb | 4 ++-- spec/controllers/api/v1/problems_controller_spec.rb | 4 ++-- spec/controllers/api/v3/notices_controller_spec.rb | 8 ++++---- spec/controllers/deploys_controller_spec.rb | 6 ++---- spec/controllers/devise_sessions_controller_spec.rb | 4 ++-- spec/controllers/users_controller_spec.rb | 4 ++-- spec/decorators/issue_tracker_field_decorator.rb | 2 +- spec/decorators/issue_tracker_type_decorator_spec.rb | 4 +--- spec/initializers/action_mailer_spec.rb | 4 ++-- spec/initializers/devise_spec.rb | 10 ++++------ spec/interactors/problem_destroy_spec.rb | 2 +- spec/interactors/resolved_problem_clearer_spec.rb | 6 +++--- spec/lib/airbrake_api/v3/notice_parser_spec.rb | 9 +++++++-- spec/lib/configurator_spec.rb | 24 ++++++++++-------------- spec/models/app_spec.rb | 5 +++-- spec/models/notice_spec.rb | 2 +- spec/models/problem_spec.rb | 46 +++++++++++++++++++++++++--------------------- 25 files changed, 101 insertions(+), 107 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6debcd1..48d4126 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -59,12 +59,6 @@ Rails/Validation: Style/BlockDelimiters: Enabled: false -# Offense count: 49 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/BracesAroundHashParameters: - Enabled: false - # Offense count: 15 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassAndModuleChildren: diff --git a/app/helpers/apps_helper.rb b/app/helpers/apps_helper.rb index 3efea3e..e4f975c 100644 --- a/app/helpers/apps_helper.rb +++ b/app/helpers/apps_helper.rb @@ -6,7 +6,7 @@ module AppsHelper 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;" }) + class: "choose_other_app", style: "display: none;") return html end end diff --git a/app/models/backtrace.rb b/app/models/backtrace.rb index fae8b95..ba7ed6a 100644 --- a/app/models/backtrace.rb +++ b/app/models/backtrace.rb @@ -15,7 +15,7 @@ class Backtrace where(fingerprint: fingerprint).find_one_and_update( { '$setOnInsert' => { fingerprint: fingerprint, lines: lines } }, - { return_document: :after, upsert: true }) + return_document: :after, upsert: true) end def self.generate_fingerprint(lines) diff --git a/app/models/problem.rb b/app/models/problem.rb index 4f52eab..af9eb07 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -241,7 +241,7 @@ class Problem end def self.search(value) - Problem.where({ '$text' => { '$search' => value } }) + Problem.where('$text' => { '$search' => value }) end private diff --git a/config/load.rb b/config/load.rb index d315f39..39fad42 100644 --- a/config/load.rb +++ b/config/load.rb @@ -7,7 +7,7 @@ require_relative '../lib/configurator' # # We use the first non-nil environment variable in the list. If the last array # element is a proc, it runs at the end, overriding the config value -Errbit::Config = Configurator.run({ +Errbit::Config = Configurator.run( host: ['ERRBIT_HOST'], protocol: ['ERRBIT_PROTOCOL'], port: ['ERRBIT_PORT'], @@ -60,4 +60,4 @@ Errbit::Config = Configurator.run({ sendmail_arguments: ['SENDMAIL_ARGUMENTS'], devise_modules: ['DEVISE_MODULES'] -}) +) diff --git a/config/mongo.rb b/config/mongo.rb index 94ec888..47727a3 100644 --- a/config/mongo.rb +++ b/config/mongo.rb @@ -10,7 +10,7 @@ Mongoid.configure do |config| Errbit::Config.mongo_url end - config.load_configuration({ + config.load_configuration( clients: { default: { uri: uri @@ -19,5 +19,5 @@ Mongoid.configure do |config| options: { use_activesupport_time_zone: true } - }) + ) end diff --git a/db/migrate/201510290041_extract_issue_tracker.rb b/db/migrate/201510290041_extract_issue_tracker.rb index b18efc4..aab19ec 100644 --- a/db/migrate/201510290041_extract_issue_tracker.rb +++ b/db/migrate/201510290041_extract_issue_tracker.rb @@ -34,9 +34,7 @@ class ExtractIssueTracker < Mongoid::Migration 'created_at' => created_at } - App.where({ _id: app.id }).update({ - "$set" => { issue_tracker: tracker } - }) + App.where(_id: app.id).update("$set" => { issue_tracker: tracker }) end end diff --git a/lib/tasks/errbit/demo.rake b/lib/tasks/errbit/demo.rake index 8712cdd..fb04240 100644 --- a/lib/tasks/errbit/demo.rake +++ b/lib/tasks/errbit/demo.rake @@ -43,25 +43,27 @@ 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: { - '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" - } - })).generate_notice! + ErrorReport.new( + error_template.reverse_merge( + 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" + } + ) + ).generate_notice! end end diff --git a/spec/controllers/api/v1/notices_controller_spec.rb b/spec/controllers/api/v1/notices_controller_spec.rb index 6f0b2d0..aabd755 100644 --- a/spec/controllers/api/v1/notices_controller_spec.rb +++ b/spec/controllers/api/v1/notices_controller_spec.rb @@ -29,7 +29,7 @@ describe Api::V1::NoticesController, type: 'controller' do 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 079987c..20bce0d 100644 --- a/spec/controllers/api/v1/problems_controller_spec.rb +++ b/spec/controllers/api/v1/problems_controller_spec.rb @@ -82,7 +82,7 @@ describe Api::V1::ProblemsController, type: 'controller' do 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/api/v3/notices_controller_spec.rb b/spec/controllers/api/v3/notices_controller_spec.rb index cd735d3..32c5cfc 100644 --- a/spec/controllers/api/v3/notices_controller_spec.rb +++ b/spec/controllers/api/v3/notices_controller_spec.rb @@ -15,10 +15,10 @@ describe Api::V3::NoticesController, type: :controller do it 'returns created notice id in json format' do post :create, legit_body, legit_params notice = Notice.last - expect(JSON.parse(response.body)).to eq({ + expect(JSON.parse(response.body)).to eq( 'id' => notice.id.to_s, 'url' => app_problem_url(app, notice.problem) - }) + ) end it 'responds with 400 when request attributes are not valid' do @@ -30,7 +30,7 @@ describe Api::V3::NoticesController, type: :controller do end it 'responds with 422 when project_id is invalid' do - post :create, legit_body, { project_id: 'hm?', key: 'wha?' } + post :create, legit_body, project_id: 'hm?', key: 'wha?' expect(response.status).to eq(422) expect(response.body).to eq('Your API key is unknown') @@ -38,7 +38,7 @@ describe Api::V3::NoticesController, type: :controller do it 'ignores notices for older api' do app = Fabricate(:app, current_app_version: '2.0') - post :create, legit_body, { project_id: app.api_key, key: app.api_key } + post :create, legit_body, project_id: app.api_key, key: app.api_key expect(response.body).to eq('Notice for old app version ignored') expect(Notice.count).to eq(0) end diff --git a/spec/controllers/deploys_controller_spec.rb b/spec/controllers/deploys_controller_spec.rb index 621cf5c..4d8287d 100644 --- a/spec/controllers/deploys_controller_spec.rb +++ b/spec/controllers/deploys_controller_spec.rb @@ -21,14 +21,12 @@ describe DeploysController, type: 'controller' do it 'creates a deploy' do expect(App).to receive(:find_by_api_key!).and_return(@app) expect(@app.deploys).to receive(:create!). - with({ + with( username: 'john.doe', environment: 'production', repository: 'git@github.com/errbit/errbit.git', revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', - message: 'johns first deploy' - - }).and_return(Fabricate(:deploy)) + message: 'johns first deploy').and_return(Fabricate(:deploy)) post :create, deploy: @params, api_key: 'APIKEY' end diff --git a/spec/controllers/devise_sessions_controller_spec.rb b/spec/controllers/devise_sessions_controller_spec.rb index bf31d24..58061e9 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/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 1f6fc4e..d1c2f00 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -232,12 +232,12 @@ describe UsersController, type: 'controller' do } let(:user_param) { { 'user' => { name: 'foo', admin: true } } } it 'not have admin field' do - expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) + expect(controller.send(:user_params)).to eq('name' => 'foo') end context "with password and password_confirmation empty?" do let(:user_param) { { 'user' => { :name => 'foo', 'password' => '', 'password_confirmation' => '' } } } it 'not have password and password_confirmation field' do - expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) + expect(controller.send(:user_params)).to eq('name' => 'foo') end end end diff --git a/spec/decorators/issue_tracker_field_decorator.rb b/spec/decorators/issue_tracker_field_decorator.rb index 3bef966..c87ae11 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 b979421..a58994d 100644 --- a/spec/decorators/issue_tracker_type_decorator_spec.rb +++ b/spec/decorators/issue_tracker_type_decorator_spec.rb @@ -24,9 +24,7 @@ describe IssueTrackerDecorator do end end - allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return({ - fake: klass - }) + allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(fake: klass) klass end diff --git a/spec/initializers/action_mailer_spec.rb b/spec/initializers/action_mailer_spec.rb index e932f6c..c74f61d 100644 --- a/spec/initializers/action_mailer_spec.rb +++ b/spec/initializers/action_mailer_spec.rb @@ -34,14 +34,14 @@ describe 'initializers/action_mailer' do allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com') load_initializer - expect(ActionMailer::Base.smtp_settings).to eq({ + expect(ActionMailer::Base.smtp_settings).to eq( address: 'smtp.somedomain.com', port: 998, authentication: :login, user_name: 'my-username', password: 'my-password', domain: 'someotherdomain.com' - }) + ) end end end diff --git a/spec/initializers/devise_spec.rb b/spec/initializers/devise_spec.rb index a973f97..5c51dfc 100644 --- a/spec/initializers/devise_spec.rb +++ b/spec/initializers/devise_spec.rb @@ -14,11 +14,10 @@ describe 'initializers/devise' do options = Devise.omniauth_configs[:github].options expect(options).to have_key(:client_options) - expect(options[:client_options]).to eq({ + expect(options[:client_options]).to eq( 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 it 'sets the client options correctly for the a GitHub Enterprise github_url' do @@ -28,11 +27,10 @@ describe 'initializers/devise' do options = Devise.omniauth_configs[:github].options expect(options).to have_key(:client_options) - expect(options[:client_options]).to eq({ + expect(options[:client_options]).to eq( 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 end diff --git a/spec/interactors/problem_destroy_spec.rb b/spec/interactors/problem_destroy_spec.rb index b123502..34ab6d9 100644 --- a/spec/interactors/problem_destroy_spec.rb +++ b/spec/interactors/problem_destroy_spec.rb @@ -40,7 +40,7 @@ describe ProblemDestroy do 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 diff --git a/spec/interactors/resolved_problem_clearer_spec.rb b/spec/interactors/resolved_problem_clearer_spec.rb index a10e48f..ec73c8e 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 @@ -44,7 +44,7 @@ describe ResolvedProblemClearer do 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/lib/airbrake_api/v3/notice_parser_spec.rb b/spec/lib/airbrake_api/v3/notice_parser_spec.rb index c559f9d..023e428 100644 --- a/spec/lib/airbrake_api/v3/notice_parser_spec.rb +++ b/spec/lib/airbrake_api/v3/notice_parser_spec.rb @@ -7,7 +7,7 @@ describe AirbrakeApi::V3::NoticeParser do }.to raise_error(AirbrakeApi::ParamsError) expect { - AirbrakeApi::V3::NoticeParser.new({ 'errors' => [] }).report + AirbrakeApi::V3::NoticeParser.new('errors' => []).report }.to raise_error(AirbrakeApi::ParamsError) end @@ -20,7 +20,12 @@ describe AirbrakeApi::V3::NoticeParser do expect(report.error_class).to eq('Error') expect(report.message).to eq('Error: TestError') expect(report.backtrace.lines.size).to eq(9) - expect(notice.user_attributes).to include({ 'Id' => 1, 'Name' => 'John Doe', 'Email' => 'john.doe@example.org', 'Username' => 'john' }) + expect(notice.user_attributes).to include( + 'Id' => 1, + 'Name' => 'John Doe', + 'Email' => 'john.doe@example.org', + 'Username' => 'john' + ) expect(notice.session).to include('isAdmin' => true) expect(notice.params).to include('returnTo' => 'dashboard') expect(notice.env_vars).to include( diff --git a/spec/lib/configurator_spec.rb b/spec/lib/configurator_spec.rb index eda3a49..49bf33b 100644 --- a/spec/lib/configurator_spec.rb +++ b/spec/lib/configurator_spec.rb @@ -6,56 +6,52 @@ describe Configurator do end it 'takes the first existing env, second item' do - result = Configurator.run({ two: %w(VARTWO VARTHREE) }) + result = Configurator.run(two: %w(VARTWO VARTHREE)) expect(result.two).to eq('zipp') end it 'takes the first existing env, first item' do - result = Configurator.run({ three: %w(VARTHREE VARONE) }) + result = Configurator.run(three: %w(VARTHREE VARONE)) expect(result.three).to eq('zipp') end it 'provides nothing for missing variables' do - result = Configurator.run({ four: ['VAREIGHTY'] }) + result = Configurator.run(four: ['VAREIGHTY']) expect(result.four).to be_nil end it 'overrides existing variables' do - result = Configurator.run({ - one: ['VARONE', ->(_values) { 'oveRIIIDE' }] - }) + result = Configurator.run(one: ['VARONE', ->(_values) { 'oveRIIIDE' }]) expect(result.one).to eq('oveRIIIDE') end it 'overrides can refer to other values' do - result = Configurator.run({ - one: ['VARONE', ->(values) { values[:one] }], - three: ['VARTHREE'] - }) + result = Configurator.run(one: ['VARONE', ->(values) { values[:one] }], + three: ['VARTHREE']) expect(result.one).to eq('zoom') end it 'extracts symbol values' do allow(ENV).to receive(:[]).with('MYSYMBOL').and_return(':asymbol') - result = Configurator.run({ mysymbol: ['MYSYMBOL'] }) + result = Configurator.run(mysymbol: ['MYSYMBOL']) expect(result.mysymbol).to be(:asymbol) end it 'extracts array values' do allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') - result = Configurator.run({ myarray: ['MYARRAY'] }) + result = Configurator.run(myarray: ['MYARRAY']) expect(result.myarray).to eq(%w(one two three)) end it 'extracts booleans' do allow(ENV).to receive(:[]).with('MYBOOLEAN').and_return('true') - result = Configurator.run({ myboolean: ['MYBOOLEAN'] }) + result = Configurator.run(myboolean: ['MYBOOLEAN']) expect(result.myboolean).to be(true) end it 'extracts numbers' do allow(ENV).to receive(:[]).with('MYNUMBER').and_return('0') - result = Configurator.run({ mynumber: ['MYNUMBER'] }) + result = Configurator.run(mynumber: ['MYNUMBER']) expect(result.mynumber).to be(0) end end diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 9bfca9c..44d69bd 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -173,10 +173,11 @@ describe App, type: 'model' do } it 'returns the correct err if one already exists' do - existing = Fabricate(:err, { + existing = Fabricate( + :err, problem: Fabricate(:problem, app: app), fingerprint: conditions[:fingerprint] - }) + ) expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing expect(app.find_or_create_err!(conditions)).to eq existing end diff --git a/spec/models/notice_spec.rb b/spec/models/notice_spec.rb index 97d222f..32b5602 100644 --- a/spec/models/notice_spec.rb +++ b/spec/models/notice_spec.rb @@ -115,7 +115,7 @@ describe Notice, type: 'model' do it "returns the cgi-data" do notice = Notice.new notice.request = { 'cgi-data' => { 'ONE' => 'TWO' } } - expect(notice.env_vars).to eq({ 'ONE' => 'TWO' }) + expect(notice.env_vars).to eq('ONE' => 'TWO') end it "always returns a hash" do diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index e3818fa..b4bf84b 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -273,7 +273,7 @@ describe Problem, type: 'model' do expect { @err.notices.first.destroy @problem.reload - }.to change(@problem, :messages).from({ Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 } }).to({}) + }.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) end it "removing a notice from the problem with broken counter should not raise an error" do @@ -300,7 +300,7 @@ describe Problem, type: 'model' do expect { @err.notices.first.destroy @problem.reload - }.to change(@problem, :hosts).from({ Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 } }).to({}) + }.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) end end @@ -316,13 +316,23 @@ 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 - }.to change(@problem, :user_agents).from({ - Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } - }).to({}) + }.to change(@problem, :user_agents). + from( + Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { + 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } + ).to({}) end end @@ -437,21 +447,21 @@ describe Problem, type: 'model' do end it 'update stats messages' do - expect(problem.messages).to eq({ + expect(problem.messages).to eq( Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 1 } - }) + ) end it 'update stats hosts' do - expect(problem.hosts).to eq({ + expect(problem.hosts).to eq( Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 1 } - }) + ) end it 'update stats user_agents' do - expect(problem.user_agents).to eq({ + expect(problem.user_agents).to eq( Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 1 } - }) + ) end end @@ -477,21 +487,15 @@ describe Problem, type: 'model' do end it 'update stats messages' do - expect(problem.messages).to eq({ - Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 3 } - }) + expect(problem.messages).to eq(Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 3 }) end it 'update stats hosts' do - expect(problem.hosts).to eq({ - Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 3 } - }) + expect(problem.hosts).to eq(Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 3 }) end it 'update stats user_agents' do - expect(problem.user_agents).to eq({ - Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 } - }) + expect(problem.user_agents).to eq(Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 }) end end end -- libgit2 0.21.2