diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8b95d8ee4..0e33734a6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -687,18 +687,6 @@ RSpec/VerifiedDoubles: - 'spec/mongoid/validatable/associated_spec.rb' - 'spec/rails/mongoid_spec.rb' -# Offense count: 11 -# Configuration parameters: EnforcedStyle, AllowToTime. -# SupportedStyles: strict, flexible -Rails/Date: - Exclude: - - 'spec/mongoid/association/embedded/embeds_many/proxy_spec.rb' - - 'spec/mongoid/attributes_spec.rb' - - 'spec/mongoid/extensions/time_spec.rb' - - 'spec/mongoid/extensions/time_with_zone_spec.rb' - - 'spec/mongoid/persistable/maxable_spec.rb' - - 'spec/mongoid/persistable/minable_spec.rb' - # Offense count: 20 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforceForPrefixed. diff --git a/docs/reference/fields.txt b/docs/reference/fields.txt index 6687a6a42..5828960b7 100644 --- a/docs/reference/fields.txt +++ b/docs/reference/fields.txt @@ -287,7 +287,7 @@ assignment to a ``Time`` field: field :registered_at, type: Time end - Voter.new(registered_at: Date.today) + Voter.new(registered_at: Date.current) # => # In the above example, the value was interpreted as the beginning of today in diff --git a/docs/reference/queries.txt b/docs/reference/queries.txt index 79ecd9cc9..1fdd81e4f 100644 --- a/docs/reference/queries.txt +++ b/docs/reference/queries.txt @@ -1814,7 +1814,7 @@ values, respectively, are straightforward: .. code-block:: ruby - Voter.where(born_on: Date.today).selector + Voter.where(born_on: Date.current).selector # => {"born_on"=>2020-12-18 00:00:00 UTC} Voter.where(registered_at: Time.now).selector @@ -1825,16 +1825,16 @@ in all possible scenarios: .. code-block:: ruby - Voter.where(born_on: Date.today).selector + Voter.where(born_on: Date.current).selector # => {"born_on"=>2020-12-18 00:00:00 UTC} - Voter.where(registered_at: Date.today).selector + Voter.where(registered_at: Date.current).selector # => {"registered_at"=>2020-12-18 00:00:00 -0500} - Voter.where(voted_at: Date.today).selector + Voter.where(voted_at: Date.current).selector # => {"voted_at"=>Fri, 18 Dec 2020} - Voter.where(deregistered_at: Date.today).selector + Voter.where(deregistered_at: Date.current).selector # => {"deregistered_at"=>2020-12-18 00:00:00 UTC} When using the ``registered_at`` field which is of type ``Time``, the date diff --git a/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb b/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb index cc353976f..7f67db4d5 100644 --- a/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +++ b/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb @@ -2136,7 +2136,7 @@ class TrackingIdValidationHistory before do owner.pet = Pet.new(name: 'Fido') - owner.pet.vet_visits << VetVisit.new(date: Date.today) + owner.pet.vet_visits << VetVisit.new(date: Date.current) owner.save! owner.pet.vet_visits.destroy_all end @@ -2146,7 +2146,7 @@ class TrackingIdValidationHistory end it 'allows addition and a resave' do - owner.pet.vet_visits << VetVisit.new(date: Date.today) + owner.pet.vet_visits << VetVisit.new(date: Date.current) owner.save! expect(owner.pet.vet_visits.first).to be_persisted end diff --git a/spec/mongoid/attributes_spec.rb b/spec/mongoid/attributes_spec.rb index d84a2934f..a45e986ea 100644 --- a/spec/mongoid/attributes_spec.rb +++ b/spec/mongoid/attributes_spec.rb @@ -1858,7 +1858,7 @@ end let(:vet_visit) do - VetVisit.new(date: Date.today) + VetVisit.new(date: Date.current) end before do @@ -1884,7 +1884,7 @@ end let!(:vet_visit) do - pet.vet_visits.create!(date: Date.today) + pet.vet_visits.create!(date: Date.current) end before do diff --git a/spec/mongoid/extensions/time_spec.rb b/spec/mongoid/extensions/time_spec.rb index 48da3a422..b15097104 100644 --- a/spec/mongoid/extensions/time_spec.rb +++ b/spec/mongoid/extensions/time_spec.rb @@ -61,7 +61,7 @@ context 'when demongoizing a Date' do it 'returns an ActiveSupport::TimeWithZone' do - expect(Time.demongoize(Date.today).class).to eq(ActiveSupport::TimeWithZone) + expect(Time.demongoize(Date.current).class).to eq(ActiveSupport::TimeWithZone) end end @@ -603,7 +603,7 @@ context 'when given a Date' do let(:date) do - Date.today + Date.current end it 'converts to a utc time' do diff --git a/spec/mongoid/extensions/time_with_zone_spec.rb b/spec/mongoid/extensions/time_with_zone_spec.rb index b54f7d6a2..d9cdfcdea 100644 --- a/spec/mongoid/extensions/time_with_zone_spec.rb +++ b/spec/mongoid/extensions/time_with_zone_spec.rb @@ -270,7 +270,7 @@ context 'when given a Date' do let(:date) do - Date.today + Date.current end it 'converts to a utc time' do diff --git a/spec/mongoid/persistable/maxable_spec.rb b/spec/mongoid/persistable/maxable_spec.rb index f1bec3dff..6df8eab5a 100644 --- a/spec/mongoid/persistable/maxable_spec.rb +++ b/spec/mongoid/persistable/maxable_spec.rb @@ -58,7 +58,7 @@ context 'when given > initial' do let(:given_name) { 'Z' } let(:given_members) { 10 } - let(:given_founded) { Date.today } + let(:given_founded) { Date.current } it_behaves_like 'a max-able root document' end @@ -67,7 +67,7 @@ context 'when the document is an embedded document' do let(:initial_city) { 'Manhattan' } let(:initial_number) { 100 } - let(:initial_end_date) { Date.today } + let(:initial_end_date) { Date.current } let(:person) { Person.create! } let(:address) do diff --git a/spec/mongoid/persistable/minable_spec.rb b/spec/mongoid/persistable/minable_spec.rb index 5dd6c0169..608f5bca1 100644 --- a/spec/mongoid/persistable/minable_spec.rb +++ b/spec/mongoid/persistable/minable_spec.rb @@ -58,7 +58,7 @@ context 'when given > initial' do let(:given_name) { 'Z' } let(:given_members) { 10 } - let(:given_founded) { Date.today } + let(:given_founded) { Date.current } it_behaves_like 'a min-able root document' end @@ -67,7 +67,7 @@ context 'when the document is an embedded document' do let(:initial_city) { 'Manhattan' } let(:initial_number) { 100 } - let(:initial_end_date) { Date.today } + let(:initial_end_date) { Date.current } let(:person) { Person.create! } let(:address) do