Commit 7dc461eed78b12a0090c7cd57b6c5ec486b56722
1 parent
1ebc5fb8
Exists in
master
and in
1 other branch
Rubocop: remove unnecessary braces around parameters
Showing
25 changed files
with
101 additions
and
107 deletions
Show diff stats
.rubocop_todo.yml
| @@ -59,12 +59,6 @@ Rails/Validation: | @@ -59,12 +59,6 @@ Rails/Validation: | ||
| 59 | Style/BlockDelimiters: | 59 | Style/BlockDelimiters: |
| 60 | Enabled: false | 60 | Enabled: false |
| 61 | 61 | ||
| 62 | -# Offense count: 49 | ||
| 63 | -# Cop supports --auto-correct. | ||
| 64 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
| 65 | -Style/BracesAroundHashParameters: | ||
| 66 | - Enabled: false | ||
| 67 | - | ||
| 68 | # Offense count: 15 | 62 | # Offense count: 15 |
| 69 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 63 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| 70 | Style/ClassAndModuleChildren: | 64 | Style/ClassAndModuleChildren: |
app/helpers/apps_helper.rb
| @@ -6,7 +6,7 @@ module AppsHelper | @@ -6,7 +6,7 @@ module AppsHelper | ||
| 6 | html << select("duplicate", "app", | 6 | html << select("duplicate", "app", |
| 7 | App.all.asc(:name).reject { |a| a == @app }. | 7 | App.all.asc(:name).reject { |a| a == @app }. |
| 8 | collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" }, | 8 | collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" }, |
| 9 | - { class: "choose_other_app", style: "display: none;" }) | 9 | + class: "choose_other_app", style: "display: none;") |
| 10 | return html | 10 | return html |
| 11 | end | 11 | end |
| 12 | end | 12 | end |
app/models/backtrace.rb
| @@ -15,7 +15,7 @@ class Backtrace | @@ -15,7 +15,7 @@ class Backtrace | ||
| 15 | 15 | ||
| 16 | where(fingerprint: fingerprint).find_one_and_update( | 16 | where(fingerprint: fingerprint).find_one_and_update( |
| 17 | { '$setOnInsert' => { fingerprint: fingerprint, lines: lines } }, | 17 | { '$setOnInsert' => { fingerprint: fingerprint, lines: lines } }, |
| 18 | - { return_document: :after, upsert: true }) | 18 | + return_document: :after, upsert: true) |
| 19 | end | 19 | end |
| 20 | 20 | ||
| 21 | def self.generate_fingerprint(lines) | 21 | def self.generate_fingerprint(lines) |
app/models/problem.rb
| @@ -241,7 +241,7 @@ class Problem | @@ -241,7 +241,7 @@ class Problem | ||
| 241 | end | 241 | end |
| 242 | 242 | ||
| 243 | def self.search(value) | 243 | def self.search(value) |
| 244 | - Problem.where({ '$text' => { '$search' => value } }) | 244 | + Problem.where('$text' => { '$search' => value }) |
| 245 | end | 245 | end |
| 246 | 246 | ||
| 247 | private | 247 | private |
config/load.rb
| @@ -7,7 +7,7 @@ require_relative '../lib/configurator' | @@ -7,7 +7,7 @@ require_relative '../lib/configurator' | ||
| 7 | # | 7 | # |
| 8 | # We use the first non-nil environment variable in the list. If the last array | 8 | # We use the first non-nil environment variable in the list. If the last array |
| 9 | # element is a proc, it runs at the end, overriding the config value | 9 | # element is a proc, it runs at the end, overriding the config value |
| 10 | -Errbit::Config = Configurator.run({ | 10 | +Errbit::Config = Configurator.run( |
| 11 | host: ['ERRBIT_HOST'], | 11 | host: ['ERRBIT_HOST'], |
| 12 | protocol: ['ERRBIT_PROTOCOL'], | 12 | protocol: ['ERRBIT_PROTOCOL'], |
| 13 | port: ['ERRBIT_PORT'], | 13 | port: ['ERRBIT_PORT'], |
| @@ -60,4 +60,4 @@ Errbit::Config = Configurator.run({ | @@ -60,4 +60,4 @@ Errbit::Config = Configurator.run({ | ||
| 60 | sendmail_arguments: ['SENDMAIL_ARGUMENTS'], | 60 | sendmail_arguments: ['SENDMAIL_ARGUMENTS'], |
| 61 | 61 | ||
| 62 | devise_modules: ['DEVISE_MODULES'] | 62 | devise_modules: ['DEVISE_MODULES'] |
| 63 | -}) | 63 | +) |
config/mongo.rb
| @@ -10,7 +10,7 @@ Mongoid.configure do |config| | @@ -10,7 +10,7 @@ Mongoid.configure do |config| | ||
| 10 | Errbit::Config.mongo_url | 10 | Errbit::Config.mongo_url |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | - config.load_configuration({ | 13 | + config.load_configuration( |
| 14 | clients: { | 14 | clients: { |
| 15 | default: { | 15 | default: { |
| 16 | uri: uri | 16 | uri: uri |
| @@ -19,5 +19,5 @@ Mongoid.configure do |config| | @@ -19,5 +19,5 @@ Mongoid.configure do |config| | ||
| 19 | options: { | 19 | options: { |
| 20 | use_activesupport_time_zone: true | 20 | use_activesupport_time_zone: true |
| 21 | } | 21 | } |
| 22 | - }) | 22 | + ) |
| 23 | end | 23 | end |
db/migrate/201510290041_extract_issue_tracker.rb
| @@ -34,9 +34,7 @@ class ExtractIssueTracker < Mongoid::Migration | @@ -34,9 +34,7 @@ class ExtractIssueTracker < Mongoid::Migration | ||
| 34 | 'created_at' => created_at | 34 | 'created_at' => created_at |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | - App.where({ _id: app.id }).update({ | ||
| 38 | - "$set" => { issue_tracker: tracker } | ||
| 39 | - }) | 37 | + App.where(_id: app.id).update("$set" => { issue_tracker: tracker }) |
| 40 | end | 38 | end |
| 41 | end | 39 | end |
| 42 | 40 |
lib/tasks/errbit/demo.rake
| @@ -43,25 +43,27 @@ namespace :errbit do | @@ -43,25 +43,27 @@ namespace :errbit do | ||
| 43 | 43 | ||
| 44 | errors.each do |error_template| | 44 | errors.each do |error_template| |
| 45 | rand(34).times do | 45 | rand(34).times do |
| 46 | - ErrorReport.new(error_template.reverse_merge({ | ||
| 47 | - api_key: app.api_key, | ||
| 48 | - error_class: "StandardError", | ||
| 49 | - message: "Oops. Something went wrong!", | ||
| 50 | - backtrace: random_backtrace, | ||
| 51 | - request: { | ||
| 52 | - 'component' => 'main', | ||
| 53 | - 'action' => 'error', | ||
| 54 | - 'url' => "http://example.com/post/#{[111, 222, 333].sample}" | ||
| 55 | - }, | ||
| 56 | - server_environment: { 'environment-name' => Rails.env.to_s }, | ||
| 57 | - notifier: { name: "seeds.rb" }, | ||
| 58 | - app_user: { | ||
| 59 | - id: "1234", | ||
| 60 | - username: "jsmith", | ||
| 61 | - name: "John Smith", | ||
| 62 | - url: "http://www.example.com/users/jsmith" | ||
| 63 | - } | ||
| 64 | - })).generate_notice! | 46 | + ErrorReport.new( |
| 47 | + error_template.reverse_merge( | ||
| 48 | + api_key: app.api_key, | ||
| 49 | + error_class: "StandardError", | ||
| 50 | + message: "Oops. Something went wrong!", | ||
| 51 | + backtrace: random_backtrace, | ||
| 52 | + request: { | ||
| 53 | + 'component' => 'main', | ||
| 54 | + 'action' => 'error', | ||
| 55 | + 'url' => "http://example.com/post/#{[111, 222, 333].sample}" | ||
| 56 | + }, | ||
| 57 | + server_environment: { 'environment-name' => Rails.env.to_s }, | ||
| 58 | + notifier: { name: "seeds.rb" }, | ||
| 59 | + app_user: { | ||
| 60 | + id: "1234", | ||
| 61 | + username: "jsmith", | ||
| 62 | + name: "John Smith", | ||
| 63 | + url: "http://www.example.com/users/jsmith" | ||
| 64 | + } | ||
| 65 | + ) | ||
| 66 | + ).generate_notice! | ||
| 65 | end | 67 | end |
| 66 | end | 68 | end |
| 67 | 69 |
spec/controllers/api/v1/notices_controller_spec.rb
| @@ -29,7 +29,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -29,7 +29,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
| 29 | 29 | ||
| 30 | describe "given a date range" do | 30 | describe "given a date range" do |
| 31 | it "should return only the notices created during the date range" do | 31 | it "should return only the notices created during the date range" do |
| 32 | - get :index, { auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27" } | 32 | + get :index, auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27" |
| 33 | expect(response).to be_success | 33 | expect(response).to be_success |
| 34 | notices = JSON.load response.body | 34 | notices = JSON.load response.body |
| 35 | expect(notices.length).to eq 3 | 35 | expect(notices.length).to eq 3 |
| @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | it "should return all notices" do | 39 | it "should return all notices" do |
| 40 | - get :index, { auth_token: @user.authentication_token } | 40 | + get :index, auth_token: @user.authentication_token |
| 41 | expect(response).to be_success | 41 | expect(response).to be_success |
| 42 | notices = JSON.load response.body | 42 | notices = JSON.load response.body |
| 43 | expect(notices.length).to eq 4 | 43 | expect(notices.length).to eq 4 |
spec/controllers/api/v1/problems_controller_spec.rb
| @@ -82,7 +82,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -82,7 +82,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
| 82 | 82 | ||
| 83 | describe "given a date range" do | 83 | describe "given a date range" do |
| 84 | it "should return only the problems open during the date range" do | 84 | it "should return only the problems open during the date range" do |
| 85 | - get :index, { auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27" } | 85 | + get :index, auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27" |
| 86 | expect(response).to be_success | 86 | expect(response).to be_success |
| 87 | problems = JSON.load response.body | 87 | problems = JSON.load response.body |
| 88 | expect(problems.length).to eq 2 | 88 | expect(problems.length).to eq 2 |
| @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
| 90 | end | 90 | end |
| 91 | 91 | ||
| 92 | it "should return all problems" do | 92 | it "should return all problems" do |
| 93 | - get :index, { auth_token: @user.authentication_token } | 93 | + get :index, auth_token: @user.authentication_token |
| 94 | expect(response).to be_success | 94 | expect(response).to be_success |
| 95 | problems = JSON.load response.body | 95 | problems = JSON.load response.body |
| 96 | expect(problems.length).to eq 4 | 96 | expect(problems.length).to eq 4 |
spec/controllers/api/v3/notices_controller_spec.rb
| @@ -15,10 +15,10 @@ describe Api::V3::NoticesController, type: :controller do | @@ -15,10 +15,10 @@ describe Api::V3::NoticesController, type: :controller do | ||
| 15 | it 'returns created notice id in json format' do | 15 | it 'returns created notice id in json format' do |
| 16 | post :create, legit_body, legit_params | 16 | post :create, legit_body, legit_params |
| 17 | notice = Notice.last | 17 | notice = Notice.last |
| 18 | - expect(JSON.parse(response.body)).to eq({ | 18 | + expect(JSON.parse(response.body)).to eq( |
| 19 | 'id' => notice.id.to_s, | 19 | 'id' => notice.id.to_s, |
| 20 | 'url' => app_problem_url(app, notice.problem) | 20 | 'url' => app_problem_url(app, notice.problem) |
| 21 | - }) | 21 | + ) |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | it 'responds with 400 when request attributes are not valid' do | 24 | it 'responds with 400 when request attributes are not valid' do |
| @@ -30,7 +30,7 @@ describe Api::V3::NoticesController, type: :controller do | @@ -30,7 +30,7 @@ describe Api::V3::NoticesController, type: :controller do | ||
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | it 'responds with 422 when project_id is invalid' do | 32 | it 'responds with 422 when project_id is invalid' do |
| 33 | - post :create, legit_body, { project_id: 'hm?', key: 'wha?' } | 33 | + post :create, legit_body, project_id: 'hm?', key: 'wha?' |
| 34 | 34 | ||
| 35 | expect(response.status).to eq(422) | 35 | expect(response.status).to eq(422) |
| 36 | expect(response.body).to eq('Your API key is unknown') | 36 | expect(response.body).to eq('Your API key is unknown') |
| @@ -38,7 +38,7 @@ describe Api::V3::NoticesController, type: :controller do | @@ -38,7 +38,7 @@ describe Api::V3::NoticesController, type: :controller do | ||
| 38 | 38 | ||
| 39 | it 'ignores notices for older api' do | 39 | it 'ignores notices for older api' do |
| 40 | app = Fabricate(:app, current_app_version: '2.0') | 40 | app = Fabricate(:app, current_app_version: '2.0') |
| 41 | - post :create, legit_body, { project_id: app.api_key, key: app.api_key } | 41 | + post :create, legit_body, project_id: app.api_key, key: app.api_key |
| 42 | expect(response.body).to eq('Notice for old app version ignored') | 42 | expect(response.body).to eq('Notice for old app version ignored') |
| 43 | expect(Notice.count).to eq(0) | 43 | expect(Notice.count).to eq(0) |
| 44 | end | 44 | end |
spec/controllers/deploys_controller_spec.rb
| @@ -21,14 +21,12 @@ describe DeploysController, type: 'controller' do | @@ -21,14 +21,12 @@ describe DeploysController, type: 'controller' do | ||
| 21 | it 'creates a deploy' do | 21 | it 'creates a deploy' do |
| 22 | expect(App).to receive(:find_by_api_key!).and_return(@app) | 22 | expect(App).to receive(:find_by_api_key!).and_return(@app) |
| 23 | expect(@app.deploys).to receive(:create!). | 23 | expect(@app.deploys).to receive(:create!). |
| 24 | - with({ | 24 | + with( |
| 25 | username: 'john.doe', | 25 | username: 'john.doe', |
| 26 | environment: 'production', | 26 | environment: 'production', |
| 27 | repository: 'git@github.com/errbit/errbit.git', | 27 | repository: 'git@github.com/errbit/errbit.git', |
| 28 | revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', | 28 | revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
| 29 | - message: 'johns first deploy' | ||
| 30 | - | ||
| 31 | - }).and_return(Fabricate(:deploy)) | 29 | + message: 'johns first deploy').and_return(Fabricate(:deploy)) |
| 32 | post :create, deploy: @params, api_key: 'APIKEY' | 30 | post :create, deploy: @params, api_key: 'APIKEY' |
| 33 | end | 31 | end |
| 34 | 32 |
spec/controllers/devise_sessions_controller_spec.rb
| @@ -10,12 +10,12 @@ describe Devise::SessionsController, type: 'controller' do | @@ -10,12 +10,12 @@ describe Devise::SessionsController, type: 'controller' do | ||
| 10 | let(:user) { Fabricate(:user) } | 10 | let(:user) { Fabricate(:user) } |
| 11 | 11 | ||
| 12 | it 'redirects to app index page if there are no apps for the user' do | 12 | it 'redirects to app index page if there are no apps for the user' do |
| 13 | - post :create, { user: { 'email' => user.email, 'password' => user.password } } | 13 | + post :create, user: { 'email' => user.email, 'password' => user.password } |
| 14 | expect(response).to redirect_to(root_path) | 14 | expect(response).to redirect_to(root_path) |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | it 'displays a friendly error when credentials are invalid' do | 17 | it 'displays a friendly error when credentials are invalid' do |
| 18 | - post :create, { user: { 'email' => 'whatever', 'password' => 'somethinginvalid' } } | 18 | + post :create, user: { 'email' => 'whatever', 'password' => 'somethinginvalid' } |
| 19 | expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') | 19 | expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') |
| 20 | end | 20 | end |
| 21 | end | 21 | end |
spec/controllers/users_controller_spec.rb
| @@ -232,12 +232,12 @@ describe UsersController, type: 'controller' do | @@ -232,12 +232,12 @@ describe UsersController, type: 'controller' do | ||
| 232 | } | 232 | } |
| 233 | let(:user_param) { { 'user' => { name: 'foo', admin: true } } } | 233 | let(:user_param) { { 'user' => { name: 'foo', admin: true } } } |
| 234 | it 'not have admin field' do | 234 | it 'not have admin field' do |
| 235 | - expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) | 235 | + expect(controller.send(:user_params)).to eq('name' => 'foo') |
| 236 | end | 236 | end |
| 237 | context "with password and password_confirmation empty?" do | 237 | context "with password and password_confirmation empty?" do |
| 238 | let(:user_param) { { 'user' => { :name => 'foo', 'password' => '', 'password_confirmation' => '' } } } | 238 | let(:user_param) { { 'user' => { :name => 'foo', 'password' => '', 'password_confirmation' => '' } } } |
| 239 | it 'not have password and password_confirmation field' do | 239 | it 'not have password and password_confirmation field' do |
| 240 | - expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) | 240 | + expect(controller.send(:user_params)).to eq('name' => 'foo') |
| 241 | end | 241 | end |
| 242 | end | 242 | end |
| 243 | end | 243 | end |
spec/decorators/issue_tracker_field_decorator.rb
| 1 | describe IssueTrackerFieldDecorator do | 1 | describe IssueTrackerFieldDecorator do |
| 2 | describe "#label" do | 2 | describe "#label" do |
| 3 | it 'return the label of field_info by default' do | 3 | it 'return the label of field_info by default' do |
| 4 | - expect(IssueTrackerFieldDecorator.new(:foo, { label: 'hello' }).label).to eq 'hello' | 4 | + expect(IssueTrackerFieldDecorator.new(:foo, label: 'hello').label).to eq 'hello' |
| 5 | end | 5 | end |
| 6 | 6 | ||
| 7 | it 'return the key of field if no label define' do | 7 | it 'return the key of field if no label define' do |
spec/decorators/issue_tracker_type_decorator_spec.rb
| @@ -24,9 +24,7 @@ describe IssueTrackerDecorator do | @@ -24,9 +24,7 @@ describe IssueTrackerDecorator do | ||
| 24 | end | 24 | end |
| 25 | end | 25 | end |
| 26 | 26 | ||
| 27 | - allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return({ | ||
| 28 | - fake: klass | ||
| 29 | - }) | 27 | + allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(fake: klass) |
| 30 | 28 | ||
| 31 | klass | 29 | klass |
| 32 | end | 30 | end |
spec/initializers/action_mailer_spec.rb
| @@ -34,14 +34,14 @@ describe 'initializers/action_mailer' do | @@ -34,14 +34,14 @@ describe 'initializers/action_mailer' do | ||
| 34 | allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com') | 34 | allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com') |
| 35 | load_initializer | 35 | load_initializer |
| 36 | 36 | ||
| 37 | - expect(ActionMailer::Base.smtp_settings).to eq({ | 37 | + expect(ActionMailer::Base.smtp_settings).to eq( |
| 38 | address: 'smtp.somedomain.com', | 38 | address: 'smtp.somedomain.com', |
| 39 | port: 998, | 39 | port: 998, |
| 40 | authentication: :login, | 40 | authentication: :login, |
| 41 | user_name: 'my-username', | 41 | user_name: 'my-username', |
| 42 | password: 'my-password', | 42 | password: 'my-password', |
| 43 | domain: 'someotherdomain.com' | 43 | domain: 'someotherdomain.com' |
| 44 | - }) | 44 | + ) |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
| 47 | end | 47 | end |
spec/initializers/devise_spec.rb
| @@ -14,11 +14,10 @@ describe 'initializers/devise' do | @@ -14,11 +14,10 @@ describe 'initializers/devise' do | ||
| 14 | 14 | ||
| 15 | options = Devise.omniauth_configs[:github].options | 15 | options = Devise.omniauth_configs[:github].options |
| 16 | expect(options).to have_key(:client_options) | 16 | expect(options).to have_key(:client_options) |
| 17 | - expect(options[:client_options]).to eq({ | 17 | + expect(options[:client_options]).to eq( |
| 18 | site: 'https://api.github.com', | 18 | site: 'https://api.github.com', |
| 19 | authorize_url: 'https://github.com/login/oauth/authorize', | 19 | authorize_url: 'https://github.com/login/oauth/authorize', |
| 20 | - token_url: 'https://github.com/login/oauth/access_token' | ||
| 21 | - }) | 20 | + token_url: 'https://github.com/login/oauth/access_token') |
| 22 | end | 21 | end |
| 23 | 22 | ||
| 24 | it 'sets the client options correctly for the a GitHub Enterprise github_url' do | 23 | it 'sets the client options correctly for the a GitHub Enterprise github_url' do |
| @@ -28,11 +27,10 @@ describe 'initializers/devise' do | @@ -28,11 +27,10 @@ describe 'initializers/devise' do | ||
| 28 | 27 | ||
| 29 | options = Devise.omniauth_configs[:github].options | 28 | options = Devise.omniauth_configs[:github].options |
| 30 | expect(options).to have_key(:client_options) | 29 | expect(options).to have_key(:client_options) |
| 31 | - expect(options[:client_options]).to eq({ | 30 | + expect(options[:client_options]).to eq( |
| 32 | site: 'https://github.example.com/api/v3', | 31 | site: 'https://github.example.com/api/v3', |
| 33 | authorize_url: 'https://github.example.com/login/oauth/authorize', | 32 | authorize_url: 'https://github.example.com/login/oauth/authorize', |
| 34 | - token_url: 'https://github.example.com/login/oauth/access_token' | ||
| 35 | - }) | 33 | + token_url: 'https://github.example.com/login/oauth/access_token') |
| 36 | end | 34 | end |
| 37 | end | 35 | end |
| 38 | end | 36 | end |
spec/interactors/problem_destroy_spec.rb
| @@ -40,7 +40,7 @@ describe ProblemDestroy do | @@ -40,7 +40,7 @@ describe ProblemDestroy do | ||
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | it 'delete all notice of associate to this errs' do | 42 | it 'delete all notice of associate to this errs' do |
| 43 | - expect(Notice).to receive(:delete_all).with({ err_id: { '$in' => [err_1.id, err_2.id] } }) | 43 | + expect(Notice).to receive(:delete_all).with(err_id: { '$in' => [err_1.id, err_2.id] }) |
| 44 | problem_destroy.execute | 44 | problem_destroy.execute |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
spec/interactors/resolved_problem_clearer_spec.rb
| @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do | @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do | ||
| 20 | end | 20 | end |
| 21 | it 'not repair database' do | 21 | it 'not repair database' do |
| 22 | allow(Mongoid.default_client).to receive(:command).and_call_original | 22 | allow(Mongoid.default_client).to receive(:command).and_call_original |
| 23 | - expect(Mongoid.default_client).to_not receive(:command).with({ repairDatabase: 1 }) | 23 | + expect(Mongoid.default_client).to_not receive(:command).with(repairDatabase: 1) |
| 24 | resolved_problem_clearer.execute | 24 | resolved_problem_clearer.execute |
| 25 | end | 25 | end |
| 26 | end | 26 | end |
| @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do | @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do | ||
| 28 | context "with problem resolve" do | 28 | context "with problem resolve" do |
| 29 | before do | 29 | before do |
| 30 | allow(Mongoid.default_client).to receive(:command).and_call_original | 30 | allow(Mongoid.default_client).to receive(:command).and_call_original |
| 31 | - allow(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) | 31 | + allow(Mongoid.default_client).to receive(:command).with(repairDatabase: 1) |
| 32 | problems.first.resolve! | 32 | problems.first.resolve! |
| 33 | problems.second.resolve! | 33 | problems.second.resolve! |
| 34 | end | 34 | end |
| @@ -44,7 +44,7 @@ describe ResolvedProblemClearer do | @@ -44,7 +44,7 @@ describe ResolvedProblemClearer do | ||
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | it 'repair database' do | 46 | it 'repair database' do |
| 47 | - expect(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) | 47 | + expect(Mongoid.default_client).to receive(:command).with(repairDatabase: 1) |
| 48 | resolved_problem_clearer.execute | 48 | resolved_problem_clearer.execute |
| 49 | end | 49 | end |
| 50 | end | 50 | end |
spec/lib/airbrake_api/v3/notice_parser_spec.rb
| @@ -7,7 +7,7 @@ describe AirbrakeApi::V3::NoticeParser do | @@ -7,7 +7,7 @@ describe AirbrakeApi::V3::NoticeParser do | ||
| 7 | }.to raise_error(AirbrakeApi::ParamsError) | 7 | }.to raise_error(AirbrakeApi::ParamsError) |
| 8 | 8 | ||
| 9 | expect { | 9 | expect { |
| 10 | - AirbrakeApi::V3::NoticeParser.new({ 'errors' => [] }).report | 10 | + AirbrakeApi::V3::NoticeParser.new('errors' => []).report |
| 11 | }.to raise_error(AirbrakeApi::ParamsError) | 11 | }.to raise_error(AirbrakeApi::ParamsError) |
| 12 | end | 12 | end |
| 13 | 13 | ||
| @@ -20,7 +20,12 @@ describe AirbrakeApi::V3::NoticeParser do | @@ -20,7 +20,12 @@ describe AirbrakeApi::V3::NoticeParser do | ||
| 20 | expect(report.error_class).to eq('Error') | 20 | expect(report.error_class).to eq('Error') |
| 21 | expect(report.message).to eq('Error: TestError') | 21 | expect(report.message).to eq('Error: TestError') |
| 22 | expect(report.backtrace.lines.size).to eq(9) | 22 | expect(report.backtrace.lines.size).to eq(9) |
| 23 | - expect(notice.user_attributes).to include({ 'Id' => 1, 'Name' => 'John Doe', 'Email' => 'john.doe@example.org', 'Username' => 'john' }) | 23 | + expect(notice.user_attributes).to include( |
| 24 | + 'Id' => 1, | ||
| 25 | + 'Name' => 'John Doe', | ||
| 26 | + 'Email' => 'john.doe@example.org', | ||
| 27 | + 'Username' => 'john' | ||
| 28 | + ) | ||
| 24 | expect(notice.session).to include('isAdmin' => true) | 29 | expect(notice.session).to include('isAdmin' => true) |
| 25 | expect(notice.params).to include('returnTo' => 'dashboard') | 30 | expect(notice.params).to include('returnTo' => 'dashboard') |
| 26 | expect(notice.env_vars).to include( | 31 | expect(notice.env_vars).to include( |
spec/lib/configurator_spec.rb
| @@ -6,56 +6,52 @@ describe Configurator do | @@ -6,56 +6,52 @@ describe Configurator do | ||
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | it 'takes the first existing env, second item' do | 8 | it 'takes the first existing env, second item' do |
| 9 | - result = Configurator.run({ two: %w(VARTWO VARTHREE) }) | 9 | + result = Configurator.run(two: %w(VARTWO VARTHREE)) |
| 10 | expect(result.two).to eq('zipp') | 10 | expect(result.two).to eq('zipp') |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | it 'takes the first existing env, first item' do | 13 | it 'takes the first existing env, first item' do |
| 14 | - result = Configurator.run({ three: %w(VARTHREE VARONE) }) | 14 | + result = Configurator.run(three: %w(VARTHREE VARONE)) |
| 15 | expect(result.three).to eq('zipp') | 15 | expect(result.three).to eq('zipp') |
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | it 'provides nothing for missing variables' do | 18 | it 'provides nothing for missing variables' do |
| 19 | - result = Configurator.run({ four: ['VAREIGHTY'] }) | 19 | + result = Configurator.run(four: ['VAREIGHTY']) |
| 20 | expect(result.four).to be_nil | 20 | expect(result.four).to be_nil |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | it 'overrides existing variables' do | 23 | it 'overrides existing variables' do |
| 24 | - result = Configurator.run({ | ||
| 25 | - one: ['VARONE', ->(_values) { 'oveRIIIDE' }] | ||
| 26 | - }) | 24 | + result = Configurator.run(one: ['VARONE', ->(_values) { 'oveRIIIDE' }]) |
| 27 | expect(result.one).to eq('oveRIIIDE') | 25 | expect(result.one).to eq('oveRIIIDE') |
| 28 | end | 26 | end |
| 29 | 27 | ||
| 30 | it 'overrides can refer to other values' do | 28 | it 'overrides can refer to other values' do |
| 31 | - result = Configurator.run({ | ||
| 32 | - one: ['VARONE', ->(values) { values[:one] }], | ||
| 33 | - three: ['VARTHREE'] | ||
| 34 | - }) | 29 | + result = Configurator.run(one: ['VARONE', ->(values) { values[:one] }], |
| 30 | + three: ['VARTHREE']) | ||
| 35 | expect(result.one).to eq('zoom') | 31 | expect(result.one).to eq('zoom') |
| 36 | end | 32 | end |
| 37 | 33 | ||
| 38 | it 'extracts symbol values' do | 34 | it 'extracts symbol values' do |
| 39 | allow(ENV).to receive(:[]).with('MYSYMBOL').and_return(':asymbol') | 35 | allow(ENV).to receive(:[]).with('MYSYMBOL').and_return(':asymbol') |
| 40 | - result = Configurator.run({ mysymbol: ['MYSYMBOL'] }) | 36 | + result = Configurator.run(mysymbol: ['MYSYMBOL']) |
| 41 | expect(result.mysymbol).to be(:asymbol) | 37 | expect(result.mysymbol).to be(:asymbol) |
| 42 | end | 38 | end |
| 43 | 39 | ||
| 44 | it 'extracts array values' do | 40 | it 'extracts array values' do |
| 45 | allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') | 41 | allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') |
| 46 | - result = Configurator.run({ myarray: ['MYARRAY'] }) | 42 | + result = Configurator.run(myarray: ['MYARRAY']) |
| 47 | expect(result.myarray).to eq(%w(one two three)) | 43 | expect(result.myarray).to eq(%w(one two three)) |
| 48 | end | 44 | end |
| 49 | 45 | ||
| 50 | it 'extracts booleans' do | 46 | it 'extracts booleans' do |
| 51 | allow(ENV).to receive(:[]).with('MYBOOLEAN').and_return('true') | 47 | allow(ENV).to receive(:[]).with('MYBOOLEAN').and_return('true') |
| 52 | - result = Configurator.run({ myboolean: ['MYBOOLEAN'] }) | 48 | + result = Configurator.run(myboolean: ['MYBOOLEAN']) |
| 53 | expect(result.myboolean).to be(true) | 49 | expect(result.myboolean).to be(true) |
| 54 | end | 50 | end |
| 55 | 51 | ||
| 56 | it 'extracts numbers' do | 52 | it 'extracts numbers' do |
| 57 | allow(ENV).to receive(:[]).with('MYNUMBER').and_return('0') | 53 | allow(ENV).to receive(:[]).with('MYNUMBER').and_return('0') |
| 58 | - result = Configurator.run({ mynumber: ['MYNUMBER'] }) | 54 | + result = Configurator.run(mynumber: ['MYNUMBER']) |
| 59 | expect(result.mynumber).to be(0) | 55 | expect(result.mynumber).to be(0) |
| 60 | end | 56 | end |
| 61 | end | 57 | end |
spec/models/app_spec.rb
| @@ -173,10 +173,11 @@ describe App, type: 'model' do | @@ -173,10 +173,11 @@ describe App, type: 'model' do | ||
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | it 'returns the correct err if one already exists' do | 175 | it 'returns the correct err if one already exists' do |
| 176 | - existing = Fabricate(:err, { | 176 | + existing = Fabricate( |
| 177 | + :err, | ||
| 177 | problem: Fabricate(:problem, app: app), | 178 | problem: Fabricate(:problem, app: app), |
| 178 | fingerprint: conditions[:fingerprint] | 179 | fingerprint: conditions[:fingerprint] |
| 179 | - }) | 180 | + ) |
| 180 | expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing | 181 | expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing |
| 181 | expect(app.find_or_create_err!(conditions)).to eq existing | 182 | expect(app.find_or_create_err!(conditions)).to eq existing |
| 182 | end | 183 | end |
spec/models/notice_spec.rb
| @@ -115,7 +115,7 @@ describe Notice, type: 'model' do | @@ -115,7 +115,7 @@ describe Notice, type: 'model' do | ||
| 115 | it "returns the cgi-data" do | 115 | it "returns the cgi-data" do |
| 116 | notice = Notice.new | 116 | notice = Notice.new |
| 117 | notice.request = { 'cgi-data' => { 'ONE' => 'TWO' } } | 117 | notice.request = { 'cgi-data' => { 'ONE' => 'TWO' } } |
| 118 | - expect(notice.env_vars).to eq({ 'ONE' => 'TWO' }) | 118 | + expect(notice.env_vars).to eq('ONE' => 'TWO') |
| 119 | end | 119 | end |
| 120 | 120 | ||
| 121 | it "always returns a hash" do | 121 | it "always returns a hash" do |
spec/models/problem_spec.rb
| @@ -273,7 +273,7 @@ describe Problem, type: 'model' do | @@ -273,7 +273,7 @@ describe Problem, type: 'model' do | ||
| 273 | expect { | 273 | expect { |
| 274 | @err.notices.first.destroy | 274 | @err.notices.first.destroy |
| 275 | @problem.reload | 275 | @problem.reload |
| 276 | - }.to change(@problem, :messages).from({ Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 } }).to({}) | 276 | + }.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) |
| 277 | end | 277 | end |
| 278 | 278 | ||
| 279 | it "removing a notice from the problem with broken counter should not raise an error" do | 279 | 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 | @@ -300,7 +300,7 @@ describe Problem, type: 'model' do | ||
| 300 | expect { | 300 | expect { |
| 301 | @err.notices.first.destroy | 301 | @err.notices.first.destroy |
| 302 | @problem.reload | 302 | @problem.reload |
| 303 | - }.to change(@problem, :hosts).from({ Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 } }).to({}) | 303 | + }.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) |
| 304 | end | 304 | end |
| 305 | end | 305 | end |
| 306 | 306 | ||
| @@ -316,13 +316,23 @@ describe Problem, type: 'model' do | @@ -316,13 +316,23 @@ describe Problem, type: 'model' do | ||
| 316 | end | 316 | end |
| 317 | 317 | ||
| 318 | it "removing a notice removes string from #user_agents" do | 318 | it "removing a notice removes string from #user_agents" do |
| 319 | - Fabricate(:notice, err: @err, request: { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } }) | 319 | + Fabricate( |
| 320 | + :notice, | ||
| 321 | + err: @err, | ||
| 322 | + request: { | ||
| 323 | + 'cgi-data' => { | ||
| 324 | + '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' | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + ) | ||
| 320 | expect { | 328 | expect { |
| 321 | @err.notices.first.destroy | 329 | @err.notices.first.destroy |
| 322 | @problem.reload | 330 | @problem.reload |
| 323 | - }.to change(@problem, :user_agents).from({ | ||
| 324 | - 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 } | ||
| 325 | - }).to({}) | 331 | + }.to change(@problem, :user_agents). |
| 332 | + from( | ||
| 333 | + Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { | ||
| 334 | + 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } | ||
| 335 | + ).to({}) | ||
| 326 | end | 336 | end |
| 327 | end | 337 | end |
| 328 | 338 | ||
| @@ -437,21 +447,21 @@ describe Problem, type: 'model' do | @@ -437,21 +447,21 @@ describe Problem, type: 'model' do | ||
| 437 | end | 447 | end |
| 438 | 448 | ||
| 439 | it 'update stats messages' do | 449 | it 'update stats messages' do |
| 440 | - expect(problem.messages).to eq({ | 450 | + expect(problem.messages).to eq( |
| 441 | Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 1 } | 451 | Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 1 } |
| 442 | - }) | 452 | + ) |
| 443 | end | 453 | end |
| 444 | 454 | ||
| 445 | it 'update stats hosts' do | 455 | it 'update stats hosts' do |
| 446 | - expect(problem.hosts).to eq({ | 456 | + expect(problem.hosts).to eq( |
| 447 | Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 1 } | 457 | Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 1 } |
| 448 | - }) | 458 | + ) |
| 449 | end | 459 | end |
| 450 | 460 | ||
| 451 | it 'update stats user_agents' do | 461 | it 'update stats user_agents' do |
| 452 | - expect(problem.user_agents).to eq({ | 462 | + expect(problem.user_agents).to eq( |
| 453 | Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 1 } | 463 | Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 1 } |
| 454 | - }) | 464 | + ) |
| 455 | end | 465 | end |
| 456 | end | 466 | end |
| 457 | 467 | ||
| @@ -477,21 +487,15 @@ describe Problem, type: 'model' do | @@ -477,21 +487,15 @@ describe Problem, type: 'model' do | ||
| 477 | end | 487 | end |
| 478 | 488 | ||
| 479 | it 'update stats messages' do | 489 | it 'update stats messages' do |
| 480 | - expect(problem.messages).to eq({ | ||
| 481 | - Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 3 } | ||
| 482 | - }) | 490 | + expect(problem.messages).to eq(Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 3 }) |
| 483 | end | 491 | end |
| 484 | 492 | ||
| 485 | it 'update stats hosts' do | 493 | it 'update stats hosts' do |
| 486 | - expect(problem.hosts).to eq({ | ||
| 487 | - Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 3 } | ||
| 488 | - }) | 494 | + expect(problem.hosts).to eq(Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 3 }) |
| 489 | end | 495 | end |
| 490 | 496 | ||
| 491 | it 'update stats user_agents' do | 497 | it 'update stats user_agents' do |
| 492 | - expect(problem.user_agents).to eq({ | ||
| 493 | - Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 } | ||
| 494 | - }) | 498 | + expect(problem.user_agents).to eq(Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 }) |
| 495 | end | 499 | end |
| 496 | end | 500 | end |
| 497 | end | 501 | end |