Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime => Time #512

Merged
merged 8 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def edit

def update
if params[:confirm]
@proposal.update(confirmed_at: DateTime.current)
@proposal.update(confirmed_at: Time.current)
redirect_to event_event_proposals_url(slug: @event.slug, uuid: @proposal), flash: { success: "Thank you for confirming your participation" }
elsif @proposal.speaker_update_and_notify(proposal_params)
redirect_to event_proposal_url(event_slug: @event.slug, uuid: @proposal)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/staff/program_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ def program_session_params
end

def json_filename
"#{current_event.slug}-program-#{DateTime.current.to_fs(:db_just_date)}.json"
"#{current_event.slug}-program-#{Time.current.to_fs(:db_just_date)}.json"
end
end
2 changes: 1 addition & 1 deletion app/controllers/staff/time_slots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ def time_slot_decorated
end

def json_filename
"#{current_event.slug}-schedule-#{DateTime.current.to_fs(:db_just_date)}.json"
"#{current_event.slug}-schedule-#{Time.current.to_fs(:db_just_date)}.json"
end
end
4 changes: 2 additions & 2 deletions app/decorators/event_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def event_path_for
end

def cfp_days_remaining
((object.closes_at - DateTime.current).to_i / 1.day) if object.closes_at && (object.closes_at - DateTime.now).to_i / 1.day > 1
((object.closes_at - Time.current).to_i / 1.day) if object.closes_at && (object.closes_at - Time.now).to_i / 1.day > 1
end

def closes_at(format = nil)
Expand Down Expand Up @@ -123,7 +123,7 @@ def day
private

def proposal_date_range
now = DateTime.now
now = Time.now
if object.proposals.present? && object.closes_at
event_first_proposal_created_at =
object.proposals.order(created_at: :asc).pluck(:created_at).first
Expand Down
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def mention_names

def update_closes_at_if_manually_closed
if changes.key?(:state) && changes[:state] == [STATUSES[:open], STATUSES[:closed]]
self.closes_at = DateTime.now
self.closes_at = Time.now
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.create_for(user, args = {})
end

def self.mark_as_read_for_proposal(proposal_url)
all.unread.where(target_path: proposal_url).update_all(read_at: DateTime.current)
all.unread.where(target_path: proposal_url).update_all(read_at: Time.current)
end

def self.more_unread?
Expand All @@ -30,7 +30,7 @@ def self.more_unread_count
end

def mark_as_read
update(read_at: DateTime.current)
update(read_at: Time.current)
end

def read?
Expand Down
4 changes: 2 additions & 2 deletions app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def withdraw
end

def confirm
update(confirmed_at: DateTime.current)
update(confirmed_at: Time.current)
program_session.confirm if program_session.present?
end

Expand All @@ -150,7 +150,7 @@ def promote
end

def decline
update(state: WITHDRAWN, confirmed_at: DateTime.current)
update(state: WITHDRAWN, confirmed_at: Time.current)
program_session.update(state: ProgramSession::DECLINED)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
url { "http://fineevent.com/" }
guidelines { "We want all the good talks!" }
contact_email { "[email protected]" }
start_date { DateTime.now + 25.days }
end_date { DateTime.now + 30.days }
start_date { Time.now + 25.days }
end_date { Time.now + 30.days }
closes_at { 3.weeks.from_now.to_datetime }
end
end
2 changes: 1 addition & 1 deletion spec/factories/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
factory :notification do
user { nil }
message { "MyString" }
read_at { DateTime.now }
read_at { Time.now }
target_path { '/events' }

trait :unread do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
sequence(:slug) { |i| "home#{i if i > 1}" }
unpublished_body { "<p>#{Faker::Lorem.paragraph}</p>" }
published_body { "<p>#{Faker::Lorem.paragraph}</p>" }
body_published_at { DateTime.now - 1.day }
body_published_at { Time.now - 1.day }
end
end
6 changes: 3 additions & 3 deletions spec/features/admin/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
fill_in "Name", with: "My Other Event"
fill_in "Slug", with: "otherevent"
fill_in "Contact email", with: "[email protected]"
fill_in "Start date", with: DateTime.now + 10.days
fill_in "End date", with: DateTime.now + 15.days
fill_in "Closes at", with: DateTime.now + 15.days
fill_in "Start date", with: Time.now + 10.days
fill_in "End date", with: Time.now + 15.days
fill_in "Closes at", with: Time.now + 15.days
click_button "Save"

event = Event.last
Expand Down
4 changes: 2 additions & 2 deletions spec/features/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

expect(page).to have_content event.name
expect(page).to have_link 'Submit a proposal'
expect(page).to have_content "Closes at #{(DateTime.now + 21.days).strftime('%b %-d')}"
expect(page).to have_content "Closes at #{(Time.now + 21.days).strftime('%b %-d')}"
expect(page).to have_content '21 days left to submit your proposal'
expect(page).to have_content '1 proposal submitted'
end

scenario "the event title is a link if it's set" do
new_event = Event.create(name: "Coolest Event", slug: "cool", url: "", state: "open", closes_at: DateTime.current + 21.days)
new_event = Event.create(name: "Coolest Event", slug: "cool", url: "", state: "open", closes_at: 21.days.from_now)
visit event_path(new_event)

within('.page-header') do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
let!(:speaker) { create(:speaker, proposal: proposal, user: user) }

before do
proposal.update(confirmed_at: DateTime.now)
proposal.update(confirmed_at: Time.now)
visit event_proposal_path(event_slug: proposal.event.slug, uuid: proposal)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
live_events =
create_list(:event, 3, closes_at: 3.weeks.from_now, state: 'open')

create(:event, closes_at: DateTime.yesterday)
create(:event, closes_at: Date.yesterday)
create(:event)
expect(Event.live).to match_array(live_events)
end
Expand All @@ -29,7 +29,7 @@
end

it "returns false for closed events" do
event = create(:event, state: 'open', closes_at: DateTime.yesterday)
event = create(:event, state: 'open', closes_at: Date.yesterday)
expect(event).to_not be_open

event = create(:event, state: nil, closes_at: 3.weeks.from_now)
Expand Down Expand Up @@ -111,7 +111,7 @@
describe "#unmet_requirements_for_scheduling" do
it "doesn't show any missing prereqs for valid event" do
event =
create(:event, start_date: DateTime.now, end_date: DateTime.tomorrow)
create(:event, start_date: Date.today, end_date: Date.tomorrow)
create(:room, event: event)

expect(event.unmet_requirements_for_scheduling).to be_empty
Expand Down
8 changes: 4 additions & 4 deletions spec/models/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@

describe "#mark_as_read" do
let(:user) { create(:user) }
it "sets read_at to DateTime.now" do
now = DateTime.current
allow(DateTime).to receive(:current) { now }
it "sets read_at to Time.now" do
now = Time.current
allow(Time).to receive(:current) { now }
notification = create(:notification, user: user)
notification.mark_as_read
expect(notification.reload).to be_read
expect(notification.read_at.to_time.to_s).to eq(now.to_time.to_s)
expect(notification.read_at.to_s).to eq(now.to_s)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

describe "#confirmed?" do
it "returns true if proposal has been confirmed" do
proposal = create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: DateTime.now)
proposal = create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: Time.now)
expect(proposal).to be_confirmed
end

Expand All @@ -98,10 +98,10 @@
end

it "updates the state of it's program session" do
create(:proposal_with_track, state: Proposal::WAITLISTED, confirmed_at: DateTime.now)
create(:proposal_with_track, state: Proposal::WAITLISTED, confirmed_at: Time.now)
create(:proposal_with_track, state: Proposal::WAITLISTED)
create(:proposal_with_track, state: Proposal::ACCEPTED)
create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: DateTime.now)
create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: Time.now)

Proposal.all.each do |prop|
create(:program_session, proposal: prop, track: prop.track)
Expand Down