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

Time.now => Time.current #513

Merged
merged 3 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
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 - Time.current).to_i / 1.day) if object.closes_at && (object.closes_at - Time.now).to_i / 1.day > 1
((object.closes_at - Time.current).to_i / 1.day) if object.closes_at && (object.closes_at - Time.current).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 = Time.now
now = Time.current
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 = Time.now
self.closes_at = Time.current
end
end
end
Expand Down
22 changes: 11 additions & 11 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,52 @@ def create_seed_data
admin = User.where(name: "Admin", email: "an@admin.com", admin: true).first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
organizer = User.where(name: "Event MC", email: "mc@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
track_director = User.where(name: "Track Director", email: "track@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
reviewer = User.where(name: "Reviewer", email: "review@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_reviewer = User.where(name: "Speak and Review", email: "both@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_1 = User.where(name: "Jenny Talksalot", email: "speak1@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_2 = User.where(name: "Pamela Speakerson", email: "speak2@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_3 = User.where(name: "Jim Talksman", email: "speak3@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_4 = User.where(name: "Mark Speaksmith", email: "speak4@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end
speaker_5 = User.where(name: "Erin McTalky", email: "speak5@seed.event").first_or_create do |u|
u.password = pwd
u.password_confirmation = pwd
u.confirmed_at = Time.now
u.confirmed_at = Time.current
end

### SeedConf -- event is in the middle of the CFP
Expand Down Expand Up @@ -493,7 +493,7 @@ def create_seed_data
# Program Sessions
if schedule_event.proposals.count == 0
120.times do |i|
speaker_user = User.create!(name: Faker::Name.name, email: Faker::Internet.email, password: pwd, password_confirmation: pwd, confirmed_at: Time.now)
speaker_user = User.create!(name: Faker::Name.name, email: Faker::Internet.email, password: pwd, password_confirmation: pwd, confirmed_at: Time.current)

accepted_proposal = schedule_event.proposals.create!({
event: seed_event,
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
end

it "leaves state unchanged for confirmed proposals" do
proposal.update_attribute(:confirmed_at, Time.now)
proposal.update_attribute(:confirmed_at, Time.current)
post :withdraw, params: {event_slug: event.slug, uuid: proposal.uuid}
expect(proposal.reload).not_to be_withdrawn
end
Expand All @@ -126,7 +126,7 @@
end

it "sets the state to withdrawn for confirmed proposals" do
proposal.update_attribute(:confirmed_at, Time.now)
proposal.update_attribute(:confirmed_at, Time.current)
post :decline, params: {event_slug: proposal.event.slug, uuid: proposal.uuid}
expect(proposal.reload).to be_withdrawn
end
Expand Down
6 changes: 3 additions & 3 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 { "admin@example.com" }
start_date { Time.now + 25.days }
end_date { Time.now + 30.days }
closes_at { 3.weeks.from_now.to_datetime }
start_date { 25.days.from_now }
end_date { 30.days.from_now }
closes_at { 3.weeks.from_now }
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 { Time.now }
read_at { Time.current }
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 { Time.now - 1.day }
body_published_at { 1.day.ago }
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: "me@example.com"
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
fill_in "Start date", with: 10.days.from_now
fill_in "End date", with: 15.days.from_now
fill_in "Closes at", with: 15.days.from_now
click_button "Save"

event = Event.last
Expand Down
2 changes: 1 addition & 1 deletion spec/features/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(page).to have_content event.name
expect(page).to have_link 'Submit a proposal'
expect(page).to have_content "Closes at #{(Time.now + 21.days).strftime('%b %-d')}"
expect(page).to have_content "Closes at #{(21.days.from_now).strftime('%b %-d')}"
expect(page).to have_content '21 days left to submit your proposal'
expect(page).to have_content '1 proposal submitted'
end
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: Time.now)
proposal.update(confirmed_at: Time.current)
visit event_proposal_path(event_slug: proposal.event.slug, uuid: proposal)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

describe "#mark_as_read" do
let(:user) { create(:user) }
it "sets read_at to Time.now" do
it "sets read_at to Time.current" do
now = Time.current
allow(Time).to receive(:current) { now }
notification = create(:notification, user: user)
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: Time.now)
proposal = create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: Time.current)
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: Time.now)
create(:proposal_with_track, state: Proposal::WAITLISTED, confirmed_at: Time.current)
create(:proposal_with_track, state: Proposal::WAITLISTED)
create(:proposal_with_track, state: Proposal::ACCEPTED)
create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: Time.now)
create(:proposal_with_track, state: Proposal::ACCEPTED, confirmed_at: Time.current)

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