Commit eb856246616e9c41ab430d73a0b91cea4c17b357

Authored by Laust Rud Jacobsen
1 parent 0149f833
Exists in master and in 1 other branch production

Rubocop: ensure a space is inside the braces of hash literals

.rubocop_todo.yml
... ... @@ -295,12 +295,6 @@ Style/SpaceInsideBrackets:
295 295 - 'spec/lib/configurator_spec.rb'
296 296 - 'spec/models/issue_spec.rb'
297 297  
298   -# Offense count: 189
299   -# Cop supports --auto-correct.
300   -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
301   -Style/SpaceInsideHashLiteralBraces:
302   - Enabled: false
303   -
304 298 # Offense count: 873
305 299 # Cop supports --auto-correct.
306 300 # Configuration parameters: EnforcedStyle, SupportedStyles.
... ...
app/controllers/api/v1/notices_controller.rb
... ... @@ -8,7 +8,7 @@ class Api::V1::NoticesController < ApplicationController
8 8 if params.key?(:start_date) && params.key?(:end_date)
9 9 start_date = Time.zone.parse(params[:start_date]).utc
10 10 end_date = Time.zone.parse(params[:end_date]).utc
11   - query = {:created_at => {"$lte" => end_date, "$gte" => start_date}}
  11 + query = { :created_at => { "$lte" => end_date, "$gte" => start_date } }
12 12 end
13 13  
14 14 results = benchmark("[api/v1/notices_controller] query time") do
... ...
app/controllers/api/v1/problems_controller.rb
... ... @@ -24,7 +24,7 @@ class Api::V1::ProblemsController < ApplicationController
24 24 if params.key?(:start_date) && params.key?(:end_date)
25 25 start_date = Time.parse(params[:start_date]).utc
26 26 end_date = Time.parse(params[:end_date]).utc
27   - query = {:first_notice_at => {"$lte" => end_date}, "$or" => [{:resolved_at => nil}, {:resolved_at => {"$gte" => start_date}}]}
  27 + query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ :resolved_at => nil }, { :resolved_at => { "$gte" => start_date } }] }
28 28 end
29 29  
30 30 results = benchmark("[api/v1/problems_controller/index] query time") do
... ...
app/helpers/apps_helper.rb
... ... @@ -5,8 +5,8 @@ module AppsHelper
5 5 :class => 'button copy_config')
6 6 html << select("duplicate", "app",
7 7 App.all.asc(:name).reject{|a| a == @app }.
8   - collect{|p| [ p.name, p.id ] }, {:include_blank => "[choose app]"},
9   - {:class => "choose_other_app", :style => "display: none;"})
  8 + collect{|p| [ p.name, p.id ] }, { :include_blank => "[choose app]" },
  9 + { :class => "choose_other_app", :style => "display: none;" })
10 10 return html
11 11 end
12 12 end
... ...
app/helpers/navigation_helper.rb
... ... @@ -22,7 +22,7 @@ module NavigationHelper
22 22 matches.each {|c| s[c] = :all}
23 23 s
24 24 else
25   - {matches => :all}
  25 + { matches => :all }
26 26 end
27 27  
28 28 active = nil
... ...
app/models/notification_services/flowdock_service.rb
... ... @@ -21,7 +21,7 @@ if defined? Flowdock
21 21 end
22 22  
23 23 def create_notification(problem)
24   - flow = Flowdock::Flow.new(:api_token => api_token, :source => "Errbit", :from => {:name => "Errbit", :address => ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com'})
  24 + flow = Flowdock::Flow.new(:api_token => api_token, :source => "Errbit", :from => { :name => "Errbit", :address => ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' })
25 25 subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}"
26 26 url = app_problem_url problem.app, problem
27 27 flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url)
... ...
app/models/notification_services/hubot_service.rb
... ... @@ -26,6 +26,6 @@ class NotificationServices::HubotService &lt; NotificationService
26 26 end
27 27  
28 28 def create_notification(problem)
29   - HTTParty.post(url, :body => {:message => message_for_hubot(problem), :room => room_id})
  29 + HTTParty.post(url, :body => { :message => message_for_hubot(problem), :room => room_id })
30 30 end
31 31 end
... ...
app/models/notification_services/webhook_service.rb
... ... @@ -14,7 +14,7 @@ class NotificationServices::WebhookService &lt; NotificationService
14 14 end
15 15  
16 16 def message_for_webhook(problem)
17   - {:problem => {:url => problem_url(problem)}.merge(problem.as_json).to_json}
  17 + { :problem => { :url => problem_url(problem) }.merge(problem.as_json).to_json }
18 18 end
19 19  
20 20 def create_notification(problem)
... ...
app/models/problem.rb
... ... @@ -139,7 +139,7 @@ class Problem
139 139 # find only notices related to this problem
140 140 Notice.collection.find.aggregate([
141 141 { "$match" => { err_id: { "$in" => err_ids } } },
142   - { "$group" => { _id: "$#{v}", count: {"$sum" => 1} } }
  142 + { "$group" => { _id: "$#{v}", count: { "$sum" => 1 } } }
143 143 ]).each do |agg|
144 144 send(k)[Digest::MD5.hexdigest(agg[:_id] || 'N/A')] = {
145 145 'value' => agg[:_id] || 'N/A',
... ... @@ -194,7 +194,7 @@ class Problem
194 194 end
195 195  
196 196 def unmerge!
197   - attrs = {:error_class => error_class, :environment => environment}
  197 + attrs = { :error_class => error_class, :environment => environment }
198 198 problem_errs = errs.to_a
199 199  
200 200 # associate and return all the problems
... ... @@ -241,7 +241,7 @@ class Problem
241 241 end
242 242  
243 243 def self.search(value)
244   - Problem.where({'$text' => {'$search' => value}})
  244 + Problem.where({ '$text' => { '$search' => value } })
245 245 end
246 246  
247 247 private
... ...
lib/hoptoad/v2.rb
... ... @@ -12,15 +12,15 @@ module Hoptoad
12 12 case node
13 13 when Hash
14 14 if node.key?('var') && node.key?('key')
15   - {normalize_key(node['key']) => rekey(node['var'])}
  15 + { normalize_key(node['key']) => rekey(node['var']) }
16 16 elsif node.key?('var')
17 17 rekey(node['var'])
18 18 elsif node.key?('__content__') && node.key?('key')
19   - {normalize_key(node['key']) => rekey(node['__content__'])}
  19 + { normalize_key(node['key']) => rekey(node['__content__']) }
20 20 elsif node.key?('__content__')
21 21 rekey(node['__content__'])
22 22 elsif node.key?('key')
23   - {normalize_key(node['key']) => nil}
  23 + { normalize_key(node['key']) => nil }
24 24 else
25 25 node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))}
26 26 end
... ...
lib/tasks/errbit/demo.rake
... ... @@ -52,8 +52,8 @@ namespace :errbit do
52 52 'action' => 'error',
53 53 'url' => "http://example.com/post/#{[111, 222, 333].sample}"
54 54 },
55   - :server_environment => {'environment-name' => Rails.env.to_s},
56   - :notifier => {:name => "seeds.rb"},
  55 + :server_environment => { 'environment-name' => Rails.env.to_s },
  56 + :notifier => { :name => "seeds.rb" },
57 57 :app_user => {
58 58 :id => "1234",
59 59 :username => "jsmith",
... ...
spec/controllers/api/v1/notices_controller_spec.rb
... ... @@ -29,7 +29,7 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do
29 29  
30 30 describe "given a date range" do
31 31 it "should return only the notices created during the date range" do
32   - get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27"}
  32 + get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27" }
33 33 expect(response).to be_success
34 34 notices = JSON.load response.body
35 35 expect(notices.length).to eq 3
... ... @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: &#39;controller&#39; do
37 37 end
38 38  
39 39 it "should return all notices" do
40   - get :index, {:auth_token => @user.authentication_token}
  40 + get :index, { :auth_token => @user.authentication_token }
41 41 expect(response).to be_success
42 42 notices = JSON.load response.body
43 43 expect(notices.length).to eq 4
... ...
spec/controllers/api/v1/problems_controller_spec.rb
... ... @@ -82,7 +82,7 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
82 82  
83 83 describe "given a date range" do
84 84 it "should return only the problems open during the date range" do
85   - get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"}
  85 + get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27" }
86 86 expect(response).to be_success
87 87 problems = JSON.load response.body
88 88 expect(problems.length).to eq 2
... ... @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: &#39;controller&#39; do
90 90 end
91 91  
92 92 it "should return all problems" do
93   - get :index, {:auth_token => @user.authentication_token}
  93 + get :index, { :auth_token => @user.authentication_token }
94 94 expect(response).to be_success
95 95 problems = JSON.load response.body
96 96 expect(problems.length).to eq 4
... ...
spec/controllers/apps_controller_spec.rb
1 1 describe AppsController, type: 'controller' do
2 2 it_requires_authentication
3   - it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete}
  3 + it_requires_admin_privileges :for => { :new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete }
4 4  
5 5 let(:admin) { Fabricate(:admin) }
6 6 let(:user) { Fabricate(:user) }
... ... @@ -247,7 +247,7 @@ describe AppsController, type: &#39;controller&#39; do
247 247 context "changing name" do
248 248 it "should redirect to app page" do
249 249 id = @app.id
250   - put :update, :id => id, :app => {:name => "new name"}
  250 + put :update, :id => id, :app => { :name => "new name" }
251 251 expect(response).to redirect_to(app_path(id))
252 252 end
253 253 end
... ... @@ -288,7 +288,7 @@ describe AppsController, type: &#39;controller&#39; do
288 288 context "unknown tracker type" do
289 289 before(:each) do
290 290 put :update, :id => @app.id, :app => { :issue_tracker_attributes => {
291   - :type_tracker => 'unknown', :options => {:project_id => '1234', :api_token => '123123', :account => 'myapp'}
  291 + :type_tracker => 'unknown', :options => { :project_id => '1234', :api_token => '123123', :account => 'myapp' }
292 292 } }
293 293 @app.reload
294 294 end
... ...
spec/controllers/problems_controller_spec.rb
... ... @@ -2,7 +2,7 @@ describe ProblemsController, type: &#39;controller&#39; do
2 2 it_requires_authentication :for => {
3 3 :index => :get, :show => :get, :resolve => :put, :search => :get
4 4 },
5   - :params => {:app_id => 'dummyid', :id => 'dummyid'}
  5 + :params => { :app_id => 'dummyid', :id => 'dummyid' }
6 6  
7 7 let(:app) { Fabricate(:app) }
8 8 let(:err) { Fabricate(:err, :problem => problem) }
... ...
spec/controllers/users/omniauth_callbacks_controller_spec.rb
... ... @@ -5,7 +5,7 @@ describe Users::OmniauthCallbacksController, type: &#39;controller&#39; do
5 5 env = {
6 6 "omniauth.auth" => Hashie::Mash.new(
7 7 :provider => 'github',
8   - :extra => { :raw_info => { :login => login }},
  8 + :extra => { :raw_info => { :login => login } },
9 9 :credentials => { :token => token }
10 10 )
11 11 }
... ...
spec/controllers/users_controller_spec.rb
... ... @@ -46,47 +46,47 @@ describe UsersController, type: &#39;controller&#39; do
46 46 context "PUT /users/:my_id/id" do
47 47 context "when the update is successful" do
48 48 it "sets a message to display" do
49   - put :update, :id => user.to_param, :user => {:name => 'Kermit'}
  49 + put :update, :id => user.to_param, :user => { :name => 'Kermit' }
50 50 expect(request.flash[:success]).to include('updated')
51 51 end
52 52  
53 53 it "redirects to the user's page" do
54   - put :update, :id => user.to_param, :user => {:name => 'Kermit'}
  54 + put :update, :id => user.to_param, :user => { :name => 'Kermit' }
55 55 expect(response).to redirect_to(user_path(user))
56 56 end
57 57  
58 58 it "should not be able to become an admin" do
59 59 expect {
60   - put :update, :id => user.to_param, :user => {:admin => true}
  60 + put :update, :id => user.to_param, :user => { :admin => true }
61 61 }.to_not change {
62 62 user.reload.admin
63 63 }.from(false)
64 64 end
65 65  
66 66 it "should be able to set per_page option" do
67   - put :update, :id => user.to_param, :user => {:per_page => 555}
  67 + put :update, :id => user.to_param, :user => { :per_page => 555 }
68 68 expect(user.reload.per_page).to eq 555
69 69 end
70 70  
71 71 it "should be able to set time_zone option" do
72   - put :update, :id => user.to_param, :user => {:time_zone => "Warsaw"}
  72 + put :update, :id => user.to_param, :user => { :time_zone => "Warsaw" }
73 73 expect(user.reload.time_zone).to eq "Warsaw"
74 74 end
75 75  
76 76 it "should be able to not set github_login option" do
77   - put :update, :id => user.to_param, :user => {:github_login => " "}
  77 + put :update, :id => user.to_param, :user => { :github_login => " " }
78 78 expect(user.reload.github_login).to eq nil
79 79 end
80 80  
81 81 it "should be able to set github_login option" do
82   - put :update, :id => user.to_param, :user => {:github_login => "awesome_name"}
  82 + put :update, :id => user.to_param, :user => { :github_login => "awesome_name" }
83 83 expect(user.reload.github_login).to eq "awesome_name"
84 84 end
85 85 end
86 86  
87 87 context "when the update is unsuccessful" do
88 88 it "renders the edit page" do
89   - put :update, :id => user.to_param, :user => {:name => nil}
  89 + put :update, :id => user.to_param, :user => { :name => nil }
90 90 expect(response).to render_template(:edit)
91 91 end
92 92 end
... ... @@ -131,7 +131,7 @@ describe UsersController, type: &#39;controller&#39; do
131 131  
132 132 context "POST /users" do
133 133 context "when the create is successful" do
134   - let(:attrs) { {:user => Fabricate.to_params(:user)} }
  134 + let(:attrs) { { :user => Fabricate.to_params(:user) } }
135 135  
136 136 it "sets a message to display" do
137 137 post :create, attrs
... ... @@ -179,7 +179,7 @@ describe UsersController, type: &#39;controller&#39; do
179 179 }
180 180  
181 181 context "with normal params" do
182   - let(:user_params) { {:name => 'Kermit'} }
  182 + let(:user_params) { { :name => 'Kermit' } }
183 183 it "sets a message to display" do
184 184 expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.reload.name)
185 185 expect(response).to redirect_to(user_path(user))
... ... @@ -188,7 +188,7 @@ describe UsersController, type: &#39;controller&#39; do
188 188 end
189 189 context "when the update is unsuccessful" do
190 190 it "renders the edit page" do
191   - put :update, :id => user.to_param, :user => {:name => nil}
  191 + put :update, :id => user.to_param, :user => { :name => nil }
192 192 expect(response).to render_template(:edit)
193 193 end
194 194 end
... ... @@ -230,14 +230,14 @@ describe UsersController, type: &#39;controller&#39; do
230 230 ActionController::Parameters.new(user_param)
231 231 )
232 232 }
233   - let(:user_param) { {'user' => { :name => 'foo', :admin => true }} }
  233 + let(:user_param) { { 'user' => { :name => 'foo', :admin => true } } }
234 234 it 'not have admin field' do
235   - expect(controller.send(:user_params)).to eq({'name' => 'foo'})
  235 + expect(controller.send(:user_params)).to eq({ 'name' => 'foo' })
236 236 end
237 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 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 241 end
242 242 end
243 243 end
... ...
spec/decorators/issue_tracker_decorator_spec.rb
... ... @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do
11 11  
12 12 def self.fields
13 13 {
14   - :foo => {:label => 'foo'},
15   - :bar => {:label => 'bar'}
  14 + :foo => { :label => 'foo' },
  15 + :bar => { :label => 'bar' }
16 16 }
17 17 end
18 18  
... ...
spec/decorators/issue_tracker_field_decorator.rb
1 1 describe IssueTrackerFieldDecorator do
2 2 describe "#label" do
3 3 it 'return the label of field_info by default' do
4   - expect(IssueTrackerFieldDecorator.new(:foo, {:label => 'hello'}).label).to eq 'hello'
  4 + expect(IssueTrackerFieldDecorator.new(:foo, { :label => 'hello' }).label).to eq 'hello'
5 5 end
6 6  
7 7 it 'return the key of field if no label define' do
... ...
spec/decorators/issue_tracker_type_decorator_spec.rb
... ... @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do
11 11  
12 12 def self.fields
13 13 {
14   - :foo => {:label => 'foo'},
15   - :bar => {:label => 'bar'}
  14 + :foo => { :label => 'foo' },
  15 + :bar => { :label => 'bar' }
16 16 }
17 17 end
18 18  
... ... @@ -45,7 +45,7 @@ describe IssueTrackerDecorator do
45 45 decorator.fields do |itf|
46 46 expect(itf).to be_a(IssueTrackerFieldDecorator)
47 47 expect([:foo, :bar]).to be_include(itf.object)
48   - expect([{:label => 'foo'}, {:label => 'bar'}]).to be_include(itf.field_info)
  48 + expect([{ :label => 'foo' }, { :label => 'bar' }]).to be_include(itf.field_info)
49 49 end
50 50 end
51 51 end
... ...
spec/errbit_plugin/mock_issue_tracker.rb
... ... @@ -10,8 +10,8 @@ module ErrbitPlugin
10 10  
11 11 def self.fields
12 12 {
13   - :foo => {:label => 'foo'},
14   - :bar => {:label => 'bar'}
  13 + :foo => { :label => 'foo' },
  14 + :bar => { :label => 'bar' }
15 15 }
16 16 end
17 17  
... ...
spec/interactors/problem_destroy_spec.rb
... ... @@ -40,7 +40,7 @@ describe ProblemDestroy do
40 40 end
41 41  
42 42 it 'delete all notice of associate to this errs' do
43   - expect(Notice).to receive(:delete_all).with({:err_id => { '$in' => [err_1.id, err_2.id] }})
  43 + expect(Notice).to receive(:delete_all).with({ :err_id => { '$in' => [err_1.id, err_2.id] } })
44 44 problem_destroy.execute
45 45 end
46 46 end
... ...
spec/interactors/resolved_problem_clearer_spec.rb
... ... @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do
20 20 end
21 21 it 'not repair database' do
22 22 allow(Mongoid.default_client).to receive(:command).and_call_original
23   - expect(Mongoid.default_client).to_not receive(:command).with({:repairDatabase => 1})
  23 + expect(Mongoid.default_client).to_not receive(:command).with({ :repairDatabase => 1 })
24 24 resolved_problem_clearer.execute
25 25 end
26 26 end
... ... @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do
28 28 context "with problem resolve" do
29 29 before do
30 30 allow(Mongoid.default_client).to receive(:command).and_call_original
31   - allow(Mongoid.default_client).to receive(:command).with({:repairDatabase => 1})
  31 + allow(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 })
32 32 problems.first.resolve!
33 33 problems.second.resolve!
34 34 end
... ... @@ -44,7 +44,7 @@ describe ResolvedProblemClearer do
44 44 end
45 45  
46 46 it 'repair database' do
47   - expect(Mongoid.default_client).to receive(:command).with({:repairDatabase => 1})
  47 + expect(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 })
48 48 resolved_problem_clearer.execute
49 49 end
50 50 end
... ...
spec/lib/airbrake_api/v3/notice_parser_spec.rb
... ... @@ -7,7 +7,7 @@ describe AirbrakeApi::V3::NoticeParser do
7 7 }.to raise_error(AirbrakeApi::ParamsError)
8 8  
9 9 expect {
10   - AirbrakeApi::V3::NoticeParser.new({'errors' => []}).report
  10 + AirbrakeApi::V3::NoticeParser.new({ 'errors' => [] }).report
11 11 }.to raise_error(AirbrakeApi::ParamsError)
12 12 end
13 13  
... ... @@ -20,7 +20,7 @@ describe AirbrakeApi::V3::NoticeParser do
20 20 expect(report.error_class).to eq('Error')
21 21 expect(report.message).to eq('Error: TestError')
22 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({ 'Id' => 1, 'Name' => 'John Doe', 'Email' => 'john.doe@example.org', 'Username' => 'john' })
24 24 expect(notice.session).to include('isAdmin' => true)
25 25 expect(notice.params).to include('returnTo' => 'dashboard')
26 26 expect(notice.env_vars).to include(
... ...
spec/models/notice_spec.rb
... ... @@ -21,8 +21,8 @@ describe Notice, type: &#39;model&#39; do
21 21  
22 22 describe "key sanitization" do
23 23 before do
24   - @hash = { "some.key" => { "$nested.key" => {"$Path" => "/", "some$key" => "key"}}}
25   - @hash_sanitized = { "some&#46;key" => { "&#36;nested&#46;key" => {"&#36;Path" => "/", "some$key" => "key"}}}
  24 + @hash = { "some.key" => { "$nested.key" => { "$Path" => "/", "some$key" => "key" } } }
  25 + @hash_sanitized = { "some&#46;key" => { "&#36;nested&#46;key" => { "&#36;Path" => "/", "some$key" => "key" } } }
26 26 end
27 27 [:server_environment, :request, :notifier].each do |key|
28 28 it "replaces . with &#46; and $ with &#36; in keys used in #{key}" do
... ... @@ -37,7 +37,7 @@ describe Notice, type: &#39;model&#39; do
37 37 let(:notice) { Fabricate.build(:notice, request: request) }
38 38  
39 39 context "when it has a request url" do
40   - let(:request) { {'url' => "http://example.com/resource/12", 'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0'}} }
  40 + let(:request) { { 'url' => "http://example.com/resource/12", 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } }
41 41  
42 42 it 'has a curl representation' do
43 43 cmd = notice.to_curl
... ... @@ -46,7 +46,7 @@ describe Notice, type: &#39;model&#39; do
46 46 end
47 47  
48 48 context "when it has not a request url" do
49   - let(:request) { {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0'}} }
  49 + let(:request) { { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } }
50 50  
51 51 it 'has a curl representation' do
52 52 cmd = notice.to_curl
... ... @@ -57,9 +57,9 @@ describe Notice, type: &#39;model&#39; do
57 57  
58 58 describe "user agent" do
59 59 it "should be parsed and human-readable" do
60   - notice = Fabricate.build(:notice, :request => {'cgi-data' => {
  60 + notice = Fabricate.build(:notice, :request => { 'cgi-data' => {
61 61 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'
62   - }})
  62 + } })
63 63 expect(notice.user_agent.browser).to eq 'Chrome'
64 64 expect(notice.user_agent.version.to_s).to match(/^10\.0/)
65 65 end
... ... @@ -72,7 +72,7 @@ describe Notice, type: &#39;model&#39; do
72 72  
73 73 describe "user agent string" do
74 74 it "should be parsed and human-readable" do
75   - notice = Fabricate.build(:notice, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}})
  75 + notice = Fabricate.build(:notice, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
76 76 expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)'
77 77 end
78 78  
... ... @@ -84,17 +84,17 @@ describe Notice, type: &#39;model&#39; do
84 84  
85 85 describe "host" do
86 86 it "returns host if url is valid" do
87   - notice = Fabricate.build(:notice, :request => {'url' => "http://example.com/resource/12"})
  87 + notice = Fabricate.build(:notice, :request => { 'url' => "http://example.com/resource/12" })
88 88 expect(notice.host).to eq 'example.com'
89 89 end
90 90  
91 91 it "returns 'N/A' when url is not valid" do
92   - notice = Fabricate.build(:notice, :request => {'url' => "file:///path/to/some/resource/12"})
  92 + notice = Fabricate.build(:notice, :request => { 'url' => "file:///path/to/some/resource/12" })
93 93 expect(notice.host).to eq 'N/A'
94 94 end
95 95  
96 96 it "returns 'N/A' when url is not valid" do
97   - notice = Fabricate.build(:notice, :request => {'url' => "some string"})
  97 + notice = Fabricate.build(:notice, :request => { 'url' => "some string" })
98 98 expect(notice.host).to eq 'N/A'
99 99 end
100 100  
... ...
spec/models/notification_service/hubot_service_spec.rb
... ... @@ -6,7 +6,7 @@ describe NotificationServices::HubotService, type: &#39;model&#39; do
6 6 problem = notice.problem
7 7  
8 8 # faraday stubbing
9   - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:message => an_instance_of(String), :room => notification_service.room_id}).and_return(true)
  9 + expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => { :message => an_instance_of(String), :room => notification_service.room_id }).and_return(true)
10 10  
11 11 notification_service.create_notification(problem)
12 12 end
... ...
spec/models/notification_service/slack_service_spec.rb
... ... @@ -47,7 +47,7 @@ describe NotificationServices::SlackService, type: &#39;model&#39; do
47 47 }
48 48 ]
49 49 }.to_json
50   - expect(HTTParty).to receive(:post).with(notification_service.service_url, :body => payload, :headers => {"Content-Type" => "application/json"}).and_return(true)
  50 + expect(HTTParty).to receive(:post).with(notification_service.service_url, :body => payload, :headers => { "Content-Type" => "application/json" }).and_return(true)
51 51  
52 52 notification_service.create_notification(problem)
53 53 end
... ...
spec/models/problem_spec.rb
... ... @@ -273,7 +273,7 @@ describe Problem, type: &#39;model&#39; do
273 273 expect {
274 274 @err.notices.first.destroy
275 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 277 end
278 278  
279 279 it "removing a notice from the problem with broken counter should not raise an error" do
... ... @@ -296,11 +296,11 @@ describe Problem, type: &#39;model&#39; do
296 296 end
297 297  
298 298 it "removing a notice removes string from #hosts" do
299   - Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"})
  299 + Fabricate(:notice, :err => @err, :request => { 'url' => "http://example.com/resource/12" })
300 300 expect {
301 301 @err.notices.first.destroy
302 302 @problem.reload
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 304 end
305 305 end
306 306  
... ... @@ -316,12 +316,12 @@ describe Problem, type: &#39;model&#39; do
316 316 end
317 317  
318 318 it "removing a notice removes string from #user_agents" do
319   - Fabricate(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}})
  319 + Fabricate(:notice, :err => @err, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } })
320 320 expect {
321 321 @err.notices.first.destroy
322 322 @problem.reload
323 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}
  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 325 }).to({})
326 326 end
327 327 end
... ... @@ -438,19 +438,19 @@ describe Problem, type: &#39;model&#39; do
438 438  
439 439 it 'update stats messages' do
440 440 expect(problem.messages).to eq({
441   - Digest::MD5.hexdigest(notice.message) => {'value' => notice.message, 'count' => 1}
  441 + Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 1 }
442 442 })
443 443 end
444 444  
445 445 it 'update stats hosts' do
446 446 expect(problem.hosts).to eq({
447   - Digest::MD5.hexdigest(notice.host) => {'value' => notice.host, 'count' => 1}
  447 + Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 1 }
448 448 })
449 449 end
450 450  
451 451 it 'update stats user_agents' do
452 452 expect(problem.user_agents).to eq({
453   - Digest::MD5.hexdigest(notice.user_agent_string) => {'value' => notice.user_agent_string, 'count' => 1}
  453 + Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 1 }
454 454 })
455 455 end
456 456 end
... ... @@ -478,19 +478,19 @@ describe Problem, type: &#39;model&#39; do
478 478  
479 479 it 'update stats messages' do
480 480 expect(problem.messages).to eq({
481   - Digest::MD5.hexdigest(notice.message) => {'value' => notice.message, 'count' => 3}
  481 + Digest::MD5.hexdigest(notice.message) => { 'value' => notice.message, 'count' => 3 }
482 482 })
483 483 end
484 484  
485 485 it 'update stats hosts' do
486 486 expect(problem.hosts).to eq({
487   - Digest::MD5.hexdigest(notice.host) => {'value' => notice.host, 'count' => 3}
  487 + Digest::MD5.hexdigest(notice.host) => { 'value' => notice.host, 'count' => 3 }
488 488 })
489 489 end
490 490  
491 491 it 'update stats user_agents' do
492 492 expect(problem.user_agents).to eq({
493   - Digest::MD5.hexdigest(notice.user_agent_string) => {'value' => notice.user_agent_string, 'count' => 3}
  493 + Digest::MD5.hexdigest(notice.user_agent_string) => { 'value' => notice.user_agent_string, 'count' => 3 }
494 494 })
495 495 end
496 496 end
... ...
spec/support/macros.rb
... ... @@ -9,7 +9,7 @@ def it_requires_authentication(options = {})
9 9 :update => :put,
10 10 :destroy => :delete
11 11 },
12   - :params => {:id => '4c6c760494df2a18cc000015'}
  12 + :params => { :id => '4c6c760494df2a18cc000015' }
13 13 }
14 14 options.reverse_merge!(default_options)
15 15  
... ... @@ -38,7 +38,7 @@ def it_requires_admin_privileges(options = {})
38 38 :update => :put,
39 39 :destroy => :delete
40 40 },
41   - :params => {:id => 'dummyid'}
  41 + :params => { :id => 'dummyid' }
42 42 }
43 43 options.reverse_merge!(default_options)
44 44  
... ...
spec/views/notices/_user_attributes.html.haml_spec.rb
1 1 describe "notices/_user_attributes.html.haml", type: 'view' do
2 2 describe 'autolink' do
3 3 let(:notice) do
4   - user_attributes = { 'foo' => {'bar' => 'http://example.com'} }
  4 + user_attributes = { 'foo' => { 'bar' => 'http://example.com' } }
5 5 Fabricate(:notice, :user_attributes => user_attributes)
6 6 end
7 7  
... ...