diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e91782a..42029f4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -295,12 +295,6 @@ Style/SpaceInsideBrackets: - 'spec/lib/configurator_spec.rb' - 'spec/models/issue_spec.rb' -# Offense count: 189 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -Style/SpaceInsideHashLiteralBraces: - Enabled: false - # Offense count: 873 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index 958b783..c6df8ba 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -8,7 +8,7 @@ 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 diff --git a/app/controllers/api/v1/problems_controller.rb b/app/controllers/api/v1/problems_controller.rb index 9119a5f..8d15a83 100644 --- a/app/controllers/api/v1/problems_controller.rb +++ b/app/controllers/api/v1/problems_controller.rb @@ -24,7 +24,7 @@ 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 diff --git a/app/helpers/apps_helper.rb b/app/helpers/apps_helper.rb index f8d163a..15b3c0f 100644 --- a/app/helpers/apps_helper.rb +++ b/app/helpers/apps_helper.rb @@ -5,8 +5,8 @@ module AppsHelper :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/navigation_helper.rb b/app/helpers/navigation_helper.rb index b78897a..ad1c070 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -22,7 +22,7 @@ module NavigationHelper matches.each {|c| s[c] = :all} s else - {matches => :all} + { matches => :all } end active = nil diff --git a/app/models/notification_services/flowdock_service.rb b/app/models/notification_services/flowdock_service.rb index 524997a..a63ebbd 100644 --- a/app/models/notification_services/flowdock_service.rb +++ b/app/models/notification_services/flowdock_service.rb @@ -21,7 +21,7 @@ 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) diff --git a/app/models/notification_services/hubot_service.rb b/app/models/notification_services/hubot_service.rb index 13b9d48..cabcbae 100644 --- a/app/models/notification_services/hubot_service.rb +++ b/app/models/notification_services/hubot_service.rb @@ -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/webhook_service.rb b/app/models/notification_services/webhook_service.rb index 4225026..bf759ae 100644 --- a/app/models/notification_services/webhook_service.rb +++ b/app/models/notification_services/webhook_service.rb @@ -14,7 +14,7 @@ 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) diff --git a/app/models/problem.rb b/app/models/problem.rb index 634ae6a..9022f0b 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -139,7 +139,7 @@ class Problem # find only notices related to this problem Notice.collection.find.aggregate([ { "$match" => { err_id: { "$in" => err_ids } } }, - { "$group" => { _id: "$#{v}", count: {"$sum" => 1} } } + { "$group" => { _id: "$#{v}", count: { "$sum" => 1 } } } ]).each do |agg| send(k)[Digest::MD5.hexdigest(agg[:_id] || 'N/A')] = { 'value' => agg[:_id] || 'N/A', @@ -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 @@ -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/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index f57fe59..db3933a 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -12,15 +12,15 @@ module Hoptoad case node when Hash if node.key?('var') && node.key?('key') - {normalize_key(node['key']) => rekey(node['var'])} + { normalize_key(node['key']) => rekey(node['var']) } elsif node.key?('var') rekey(node['var']) elsif node.key?('__content__') && node.key?('key') - {normalize_key(node['key']) => rekey(node['__content__'])} + { normalize_key(node['key']) => rekey(node['__content__']) } elsif node.key?('__content__') rekey(node['__content__']) elsif node.key?('key') - {normalize_key(node['key']) => nil} + { normalize_key(node['key']) => nil } else node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))} end diff --git a/lib/tasks/errbit/demo.rake b/lib/tasks/errbit/demo.rake index 552fea1..47356de 100644 --- a/lib/tasks/errbit/demo.rake +++ b/lib/tasks/errbit/demo.rake @@ -52,8 +52,8 @@ namespace :errbit do 'action' => 'error', 'url' => "http://example.com/post/#{[111, 222, 333].sample}" }, - :server_environment => {'environment-name' => Rails.env.to_s}, - :notifier => {:name => "seeds.rb"}, + :server_environment => { 'environment-name' => Rails.env.to_s }, + :notifier => { :name => "seeds.rb" }, :app_user => { :id => "1234", :username => "jsmith", diff --git a/spec/controllers/api/v1/notices_controller_spec.rb b/spec/controllers/api/v1/notices_controller_spec.rb index 6b85e00..46db92e 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 dfc8ed1..0bbc478 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/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb index 796806b..17e23a2 100644 --- a/spec/controllers/apps_controller_spec.rb +++ b/spec/controllers/apps_controller_spec.rb @@ -1,6 +1,6 @@ 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) } @@ -247,7 +247,7 @@ 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 @@ -288,7 +288,7 @@ describe AppsController, type: 'controller' 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'} + :type_tracker => 'unknown', :options => { :project_id => '1234', :api_token => '123123', :account => 'myapp' } } } @app.reload end diff --git a/spec/controllers/problems_controller_spec.rb b/spec/controllers/problems_controller_spec.rb index 5612f60..0cfa54f 100644 --- a/spec/controllers/problems_controller_spec.rb +++ b/spec/controllers/problems_controller_spec.rb @@ -2,7 +2,7 @@ describe ProblemsController, type: 'controller' do 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) } diff --git a/spec/controllers/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/users/omniauth_callbacks_controller_spec.rb index 84ec87b..14b957c 100644 --- a/spec/controllers/users/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/users/omniauth_callbacks_controller_spec.rb @@ -5,7 +5,7 @@ describe Users::OmniauthCallbacksController, type: 'controller' do env = { "omniauth.auth" => Hashie::Mash.new( :provider => 'github', - :extra => { :raw_info => { :login => login }}, + :extra => { :raw_info => { :login => login } }, :credentials => { :token => token } ) } diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 9b3705c..07f54ac 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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 @@ -131,7 +131,7 @@ describe UsersController, type: 'controller' do 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 @@ -179,7 +179,7 @@ describe UsersController, type: 'controller' do } 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(response).to redirect_to(user_path(user)) @@ -188,7 +188,7 @@ describe UsersController, type: 'controller' do 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 @@ -230,14 +230,14 @@ 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'}) + 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' => '' }} } + 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_decorator_spec.rb b/spec/decorators/issue_tracker_decorator_spec.rb index 764c8f8..8fdc938 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 e9476ad..c6003e5 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 1f49363..4ca52c2 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/errbit_plugin/mock_issue_tracker.rb b/spec/errbit_plugin/mock_issue_tracker.rb index 8b7bb1e..28e79fd 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/interactors/problem_destroy_spec.rb b/spec/interactors/problem_destroy_spec.rb index 0d1e95f..fda714a 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 0e1a4a0..4fa7fbf 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 48b4205..c559f9d 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,7 @@ 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/models/notice_spec.rb b/spec/models/notice_spec.rb index ef87d0c..b99a3b9 100644 --- a/spec/models/notice_spec.rb +++ b/spec/models/notice_spec.rb @@ -21,8 +21,8 @@ describe Notice, type: 'model' do describe "key sanitization" do before do - @hash = { "some.key" => { "$nested.key" => {"$Path" => "/", "some$key" => "key"}}} - @hash_sanitized = { "some.key" => { "$nested.key" => {"$Path" => "/", "some$key" => "key"}}} + @hash = { "some.key" => { "$nested.key" => { "$Path" => "/", "some$key" => "key" } } } + @hash_sanitized = { "some.key" => { "$nested.key" => { "$Path" => "/", "some$key" => "key" } } } end [:server_environment, :request, :notifier].each do |key| it "replaces . with . and $ with $ in keys used in #{key}" do @@ -37,7 +37,7 @@ describe Notice, type: 'model' do let(:notice) { Fabricate.build(:notice, request: request) } context "when it has a request url" do - let(:request) { {'url' => "http://example.com/resource/12", 'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0'}} } + let(:request) { { 'url' => "http://example.com/resource/12", 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } } it 'has a curl representation' do cmd = notice.to_curl @@ -46,7 +46,7 @@ describe Notice, type: 'model' do end context "when it has not a request url" do - let(:request) { {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0'}} } + let(:request) { { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } } it 'has a curl representation' do cmd = notice.to_curl @@ -57,9 +57,9 @@ 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' expect(notice.user_agent.version.to_s).to match(/^10\.0/) end @@ -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,17 +84,17 @@ 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 diff --git a/spec/models/notification_service/hubot_service_spec.rb b/spec/models/notification_service/hubot_service_spec.rb index feee7c0..6a6a475 100644 --- a/spec/models/notification_service/hubot_service_spec.rb +++ b/spec/models/notification_service/hubot_service_spec.rb @@ -6,7 +6,7 @@ describe NotificationServices::HubotService, type: 'model' do 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/slack_service_spec.rb b/spec/models/notification_service/slack_service_spec.rb index 4d252f5..5b6dd54 100644 --- a/spec/models/notification_service/slack_service_spec.rb +++ b/spec/models/notification_service/slack_service_spec.rb @@ -47,7 +47,7 @@ describe NotificationServices::SlackService, type: 'model' do } ] }.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/problem_spec.rb b/spec/models/problem_spec.rb index bd00c87..14bf5a8 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 @@ -296,11 +296,11 @@ 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 - }.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,12 +316,12 @@ 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} + 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 @@ -438,19 +438,19 @@ describe Problem, type: 'model' do it 'update stats messages' do expect(problem.messages).to eq({ - Digest::MD5.hexdigest(notice.message) => {'value' => notice.message, 'count' => 1} + Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 1 } }) end it 'update stats hosts' do expect(problem.hosts).to eq({ - Digest::MD5.hexdigest(notice.host) => {'value' => notice.host, 'count' => 1} + Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 1 } }) 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' => 1} + Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 1 } }) end end @@ -478,19 +478,19 @@ describe Problem, type: 'model' do it 'update stats messages' do expect(problem.messages).to eq({ - Digest::MD5.hexdigest(notice.message) => {'value' => notice.message, 'count' => 3} + 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} + 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} + Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 } }) end end diff --git a/spec/support/macros.rb b/spec/support/macros.rb index c1d15d0..d4b373f 100644 --- a/spec/support/macros.rb +++ b/spec/support/macros.rb @@ -9,7 +9,7 @@ def it_requires_authentication(options = {}) :update => :put, :destroy => :delete }, - :params => {:id => '4c6c760494df2a18cc000015'} + :params => { :id => '4c6c760494df2a18cc000015' } } options.reverse_merge!(default_options) @@ -38,7 +38,7 @@ def it_requires_admin_privileges(options = {}) :update => :put, :destroy => :delete }, - :params => {:id => 'dummyid'} + :params => { :id => 'dummyid' } } options.reverse_merge!(default_options) diff --git a/spec/views/notices/_user_attributes.html.haml_spec.rb b/spec/views/notices/_user_attributes.html.haml_spec.rb index fc3c315..af8e4ce 100644 --- a/spec/views/notices/_user_attributes.html.haml_spec.rb +++ b/spec/views/notices/_user_attributes.html.haml_spec.rb @@ -1,7 +1,7 @@ describe "notices/_user_attributes.html.haml", type: 'view' do describe 'autolink' do let(:notice) do - user_attributes = { 'foo' => {'bar' => 'http://example.com'} } + user_attributes = { 'foo' => { 'bar' => 'http://example.com' } } Fabricate(:notice, :user_attributes => user_attributes) end -- libgit2 0.21.2