Skip to content

Commit 34860ae

Browse files
authored
Merge pull request #513 from amatsuda/Time.now
Time.now => Time.current
2 parents 47545f4 + 54dc858 commit 34860ae

File tree

12 files changed

+30
-30
lines changed

12 files changed

+30
-30
lines changed

app/decorators/event_decorator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def event_path_for
3232
end
3333

3434
def cfp_days_remaining
35-
((object.closes_at - Time.current).to_i / 1.day) if object.closes_at && (object.closes_at - Time.now).to_i / 1.day > 1
35+
((object.closes_at - Time.current).to_i / 1.day) if object.closes_at && (object.closes_at - Time.current).to_i / 1.day > 1
3636
end
3737

3838
def closes_at(format = nil)
@@ -123,7 +123,7 @@ def day
123123
private
124124

125125
def proposal_date_range
126-
now = Time.now
126+
now = Time.current
127127
if object.proposals.present? && object.closes_at
128128
event_first_proposal_created_at =
129129
object.proposals.order(created_at: :asc).pluck(:created_at).first

app/models/event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def mention_names
231231

232232
def update_closes_at_if_manually_closed
233233
if changes.key?(:state) && changes[:state] == [STATUSES[:open], STATUSES[:closed]]
234-
self.closes_at = Time.now
234+
self.closes_at = Time.current
235235
end
236236
end
237237
end

db/seeds.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,52 @@ def create_seed_data
2727
admin = User.where(name: "Admin", email: "[email protected]", admin: true).first_or_create do |u|
2828
u.password = pwd
2929
u.password_confirmation = pwd
30-
u.confirmed_at = Time.now
30+
u.confirmed_at = Time.current
3131
end
3232
organizer = User.where(name: "Event MC", email: "[email protected]").first_or_create do |u|
3333
u.password = pwd
3434
u.password_confirmation = pwd
35-
u.confirmed_at = Time.now
35+
u.confirmed_at = Time.current
3636
end
3737
track_director = User.where(name: "Track Director", email: "[email protected]").first_or_create do |u|
3838
u.password = pwd
3939
u.password_confirmation = pwd
40-
u.confirmed_at = Time.now
40+
u.confirmed_at = Time.current
4141
end
4242
reviewer = User.where(name: "Reviewer", email: "[email protected]").first_or_create do |u|
4343
u.password = pwd
4444
u.password_confirmation = pwd
45-
u.confirmed_at = Time.now
45+
u.confirmed_at = Time.current
4646
end
4747
speaker_reviewer = User.where(name: "Speak and Review", email: "[email protected]").first_or_create do |u|
4848
u.password = pwd
4949
u.password_confirmation = pwd
50-
u.confirmed_at = Time.now
50+
u.confirmed_at = Time.current
5151
end
5252
speaker_1 = User.where(name: "Jenny Talksalot", email: "[email protected]").first_or_create do |u|
5353
u.password = pwd
5454
u.password_confirmation = pwd
55-
u.confirmed_at = Time.now
55+
u.confirmed_at = Time.current
5656
end
5757
speaker_2 = User.where(name: "Pamela Speakerson", email: "[email protected]").first_or_create do |u|
5858
u.password = pwd
5959
u.password_confirmation = pwd
60-
u.confirmed_at = Time.now
60+
u.confirmed_at = Time.current
6161
end
6262
speaker_3 = User.where(name: "Jim Talksman", email: "[email protected]").first_or_create do |u|
6363
u.password = pwd
6464
u.password_confirmation = pwd
65-
u.confirmed_at = Time.now
65+
u.confirmed_at = Time.current
6666
end
6767
speaker_4 = User.where(name: "Mark Speaksmith", email: "[email protected]").first_or_create do |u|
6868
u.password = pwd
6969
u.password_confirmation = pwd
70-
u.confirmed_at = Time.now
70+
u.confirmed_at = Time.current
7171
end
7272
speaker_5 = User.where(name: "Erin McTalky", email: "[email protected]").first_or_create do |u|
7373
u.password = pwd
7474
u.password_confirmation = pwd
75-
u.confirmed_at = Time.now
75+
u.confirmed_at = Time.current
7676
end
7777

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

498498
accepted_proposal = schedule_event.proposals.create!({
499499
event: seed_event,

spec/controllers/proposals_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
end
102102

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

128128
it "sets the state to withdrawn for confirmed proposals" do
129-
proposal.update_attribute(:confirmed_at, Time.now)
129+
proposal.update_attribute(:confirmed_at, Time.current)
130130
post :decline, params: {event_slug: proposal.event.slug, uuid: proposal.uuid}
131131
expect(proposal.reload).to be_withdrawn
132132
end

spec/factories/events.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
url { "http://fineevent.com/" }
55
guidelines { "We want all the good talks!" }
66
contact_email { "[email protected]" }
7-
start_date { Time.now + 25.days }
8-
end_date { Time.now + 30.days }
9-
closes_at { 3.weeks.from_now.to_datetime }
7+
start_date { 25.days.from_now }
8+
end_date { 30.days.from_now }
9+
closes_at { 3.weeks.from_now }
1010
end
1111
end

spec/factories/notifications.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
factory :notification do
55
user { nil }
66
message { "MyString" }
7-
read_at { Time.now }
7+
read_at { Time.current }
88
target_path { '/events' }
99

1010
trait :unread do

spec/factories/pages.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
sequence(:slug) { |i| "home#{i if i > 1}" }
66
unpublished_body { "<p>#{Faker::Lorem.paragraph}</p>" }
77
published_body { "<p>#{Faker::Lorem.paragraph}</p>" }
8-
body_published_at { Time.now - 1.day }
8+
body_published_at { 1.day.ago }
99
end
1010
end

spec/features/admin/event_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
fill_in "Name", with: "My Other Event"
1919
fill_in "Slug", with: "otherevent"
2020
fill_in "Contact email", with: "[email protected]"
21-
fill_in "Start date", with: Time.now + 10.days
22-
fill_in "End date", with: Time.now + 15.days
23-
fill_in "Closes at", with: Time.now + 15.days
21+
fill_in "Start date", with: 10.days.from_now
22+
fill_in "End date", with: 15.days.from_now
23+
fill_in "Closes at", with: 15.days.from_now
2424
click_button "Save"
2525

2626
event = Event.last

spec/features/event_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

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

spec/features/proposal_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
let!(:speaker) { create(:speaker, proposal: proposal, user: user) }
207207

208208
before do
209-
proposal.update(confirmed_at: Time.now)
209+
proposal.update(confirmed_at: Time.current)
210210
visit event_proposal_path(event_slug: proposal.event.slug, uuid: proposal)
211211
end
212212

0 commit comments

Comments
 (0)