diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c27549feb..c9a834849 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -130,15 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 11 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: strict, flexible -Rails/TimeZone: - Exclude: - - 'lib/score_calculator.rb' - - 'spec/controllers/admin/api/stats_controller_spec.rb' - - 'spec/models/ahoy/data_source_spec.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: Include. diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb index 32086392a..0b68c025a 100644 --- a/lib/score_calculator.rb +++ b/lib/score_calculator.rb @@ -1,6 +1,6 @@ module ScoreCalculator - EPOC = Time.new(2015, 6, 15) + EPOC = Time.new(2015, 6, 15).in_time_zone COMMENT_WEIGHT = 1.0/5 # 1 positive vote / x comments TIME_UNIT = 24.hours.to_f diff --git a/spec/controllers/admin/api/stats_controller_spec.rb b/spec/controllers/admin/api/stats_controller_spec.rb index 7ba63ffb3..e032014d7 100644 --- a/spec/controllers/admin/api/stats_controller_spec.rb +++ b/spec/controllers/admin/api/stats_controller_spec.rb @@ -17,9 +17,9 @@ describe Admin::Api::StatsController do context 'events present' do before :each do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") - time_3 = DateTime.parse("2015-01-03") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone + time_3 = DateTime.parse("2015-01-03").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1 @@ -52,8 +52,8 @@ describe Admin::Api::StatsController do context 'visits present' do it 'should return visits formated for working with c3.js' do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone create :visit, started_at: time_1 create :visit, started_at: time_1 @@ -71,8 +71,8 @@ describe Admin::Api::StatsController do context 'visits and events present' do it 'should return combined events and visits formated for working with c3.js' do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_2 @@ -94,8 +94,8 @@ describe Admin::Api::StatsController do context 'budget investments present' do it 'should return budget investments formated for working with c3.js' do - time_1 = DateTime.parse("2017-04-01") - time_2 = DateTime.parse("2017-04-02") + time_1 = DateTime.parse("2017-04-01").in_time_zone + time_2 = DateTime.parse("2017-04-02").in_time_zone budget_investment1 = create(:budget_investment, budget: @budget, created_at: time_1) budget_investment2 = create(:budget_investment, budget: @budget, created_at: time_2) diff --git a/spec/lib/graphql_spec.rb b/spec/lib/graphql_spec.rb index 725cc109a..b3b8b377f 100644 --- a/spec/lib/graphql_spec.rb +++ b/spec/lib/graphql_spec.rb @@ -321,7 +321,7 @@ describe 'ConsulSchema' do it 'does not include hidden comments' do visible_comment = create(:comment) - hidden_comment = create(:comment, hidden_at: Time.now) + hidden_comment = create(:comment, hidden_at: Time.current) response = execute('{ comments { edges { node { body } } } }') received_comments = extract_fields(response, 'comments', 'body') @@ -331,7 +331,7 @@ describe 'ConsulSchema' do it 'does not include comments from hidden proposals' do visible_proposal = create(:proposal) - hidden_proposal = create(:proposal, hidden_at: Time.now) + hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_comment = create(:comment, commentable: visible_proposal) hidden_proposal_comment = create(:comment, commentable: hidden_proposal) @@ -344,7 +344,7 @@ describe 'ConsulSchema' do it 'does not include comments from hidden debates' do visible_debate = create(:debate) - hidden_debate = create(:debate, hidden_at: Time.now) + hidden_debate = create(:debate, hidden_at: Time.current) visible_debate_comment = create(:comment, commentable: visible_debate) hidden_debate_comment = create(:comment, commentable: hidden_debate) @@ -567,7 +567,7 @@ describe 'ConsulSchema' do it 'does not include votes of hidden proposals' do visible_proposal = create(:proposal) - hidden_proposal = create(:proposal, hidden_at: Time.now) + hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_vote = create(:vote, votable: visible_proposal) hidden_proposal_vote = create(:vote, votable: hidden_proposal) @@ -580,7 +580,7 @@ describe 'ConsulSchema' do it 'does not include votes of hidden comments' do visible_comment = create(:comment) - hidden_comment = create(:comment, hidden_at: Time.now) + hidden_comment = create(:comment, hidden_at: Time.current) visible_comment_vote = create(:vote, votable: visible_comment) hidden_comment_vote = create(:vote, votable: hidden_comment) diff --git a/spec/models/ahoy/data_source_spec.rb b/spec/models/ahoy/data_source_spec.rb index deb1fd056..cea416498 100644 --- a/spec/models/ahoy/data_source_spec.rb +++ b/spec/models/ahoy/data_source_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' describe Ahoy::DataSource do describe '#build' do before :each do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") - time_3 = DateTime.parse("2015-01-03") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone + time_3 = DateTime.parse("2015-01-03").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1