diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 756237e..397efba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -50,19 +50,6 @@ Rails/Output: - 'app/interactors/problem_recacher.rb' - 'db/seeds.rb' -# Offense count: 14 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Rails/TimeZone: - Exclude: - - 'app/models/problem.rb' - - 'lib/tasks/errbit/demo.rake' - - 'spec/controllers/api/v1/notices_controller_spec.rb' - - 'spec/controllers/problems_controller_spec.rb' - - 'spec/models/error_report_spec.rb' - - 'spec/models/problem_spec.rb' - - 'spec/views/apps/index.html.haml_spec.rb' - - 'spec/views/users/show.html.haml_spec.rb' - # Offense count: 12 # Configuration parameters: Include. Rails/Validation: diff --git a/app/models/problem.rb b/app/models/problem.rb index 7314772..d85b7bc 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -13,8 +13,8 @@ class Problem }.freeze - field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.now } - field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.now } + field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now } + field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now } field :last_deploy_at, :type => Time field :resolved, :type => Boolean, :default => false field :resolved_at, :type => Time @@ -173,7 +173,7 @@ class Problem end def resolve! - self.update_attributes!(:resolved => true, :resolved_at => Time.now) + self.update_attributes!(:resolved => true, :resolved_at => Time.zone.now) end def unresolve! diff --git a/lib/tasks/errbit/demo.rake b/lib/tasks/errbit/demo.rake index 10f8f85..1d319d4 100644 --- a/lib/tasks/errbit/demo.rake +++ b/lib/tasks/errbit/demo.rake @@ -3,7 +3,7 @@ namespace :errbit do task :demo => :environment do require 'fabrication' - app = Fabricate(:app, :name => "Demo App #{Time.now.strftime("%N")}") + app = Fabricate(:app, :name => "Demo App #{Time.zone.now.strftime("%N")}") # Report a number of errors for the application app.problems.delete_all diff --git a/spec/controllers/api/v1/notices_controller_spec.rb b/spec/controllers/api/v1/notices_controller_spec.rb index 9d0c3a4..79c7bb6 100644 --- a/spec/controllers/api/v1/notices_controller_spec.rb +++ b/spec/controllers/api/v1/notices_controller_spec.rb @@ -6,10 +6,10 @@ describe Api::V1::NoticesController, type: 'controller' do describe "GET /api/v1/notices" do before do - Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) - Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) - Fabricate(:notice, :created_at => Time.new(2012, 8, 21)) - Fabricate(:notice, :created_at => Time.new(2012, 8, 30)) + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-21')) + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-30')) end it "should return JSON if JSON is requested" do diff --git a/spec/controllers/problems_controller_spec.rb b/spec/controllers/problems_controller_spec.rb index 78bbbab..65fd97b 100644 --- a/spec/controllers/problems_controller_spec.rb +++ b/spec/controllers/problems_controller_spec.rb @@ -139,7 +139,7 @@ describe ProblemsController, type: 'controller' do context 'pagination' do let!(:notices) do 3.times.reduce([]) do |coll, i| - coll << Fabricate(:notice, :err => err, :created_at => (Time.now + i)) + coll << Fabricate(:notice, :err => err, :created_at => (i.seconds.from_now)) end end diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb index 049bd9f..14b5b57 100644 --- a/spec/models/error_report_spec.rb +++ b/spec/models/error_report_spec.rb @@ -156,7 +156,7 @@ describe ErrorReport do error_report.generate_notice! problem = error_report.problem problem.update( - resolved_at: Time.now, + resolved_at: Time.zone.now, resolved: true ) diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index 64dba07..bd00c87 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -236,7 +236,7 @@ describe Problem, type: 'model' do context "#last_deploy_at" do before do @app = Fabricate(:app) - @last_deploy = Time.at(10.days.ago.localtime.to_i) + @last_deploy = 10.days.ago Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") end @@ -247,11 +247,13 @@ describe Problem, type: 'model' do it "is updated when a deploy is created" do problem = Fabricate(:problem, :app => @app, :environment => "production") - next_deploy = Time.at(5.minutes.ago.localtime.to_i) + next_deploy = 5.minutes.ago expect { @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) problem.reload - }.to change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) + }.to change { problem.last_deploy_at.iso8601 }. + from(@last_deploy.iso8601). + to(next_deploy.iso8601) end end diff --git a/spec/views/apps/index.html.haml_spec.rb b/spec/views/apps/index.html.haml_spec.rb index 2818a07..5b513c4 100644 --- a/spec/views/apps/index.html.haml_spec.rb +++ b/spec/views/apps/index.html.haml_spec.rb @@ -1,6 +1,6 @@ describe "apps/index.html.haml", type: 'view' do before do - app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.now, :revision => "123456789abcdef")]) + app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.zone.now, :revision => "123456789abcdef")]) allow(view).to receive(:apps).and_return([app]) allow(controller).to receive(:current_user).and_return(stub_model(User)) end diff --git a/spec/views/users/show.html.haml_spec.rb b/spec/views/users/show.html.haml_spec.rb index 02e88a7..1012e11 100644 --- a/spec/views/users/show.html.haml_spec.rb +++ b/spec/views/users/show.html.haml_spec.rb @@ -1,6 +1,6 @@ describe 'users/show.html.haml', type: 'view' do let(:user) do - stub_model(User, :created_at => Time.now, :email => "test@example.com") + stub_model(User, :created_at => Time.zone.now, :email => "test@example.com") end before do -- libgit2 0.21.2