Fix all Rails/TimeZone rubocop issues and remove files from rubocop_todo list

This commit is contained in:
Bertocq
2017-06-21 20:47:53 +02:00
parent 6529e37ae8
commit d759aca522
5 changed files with 18 additions and 27 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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