mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 15:54:48 -05:00
FEATURE: remove the timecop gem
We should only have one way of mocking time, misuse of timecop was causing build stability issues
This commit is contained in:
@@ -21,26 +21,25 @@ describe TopicTimestampChanger do
|
||||
let(:new_timestamp) { old_timestamp - 2.day }
|
||||
|
||||
it 'changes the timestamp of the topic and opening post' do
|
||||
Timecop.freeze do
|
||||
TopicTimestampChanger.new(topic: topic, timestamp: new_timestamp.to_f).change!
|
||||
freeze_time
|
||||
TopicTimestampChanger.new(topic: topic, timestamp: new_timestamp.to_f).change!
|
||||
|
||||
topic.reload
|
||||
[:created_at, :updated_at, :bumped_at].each do |column|
|
||||
expect(topic.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
|
||||
p1.reload
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p1.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
|
||||
p2.reload
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p2.public_send(column)).to be_within(1.second).of(new_timestamp + 1.day)
|
||||
end
|
||||
|
||||
expect(topic.last_posted_at).to be_within(1.second).of(p2.reload.created_at)
|
||||
topic.reload
|
||||
[:created_at, :updated_at, :bumped_at].each do |column|
|
||||
expect(topic.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
|
||||
p1.reload
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p1.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
|
||||
p2.reload
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p2.public_send(column)).to be_within(1.second).of(new_timestamp + 1.day)
|
||||
end
|
||||
|
||||
expect(topic.last_posted_at).to be_within(1.second).of(p2.reload.created_at)
|
||||
end
|
||||
|
||||
describe 'when posts have timestamps in the future' do
|
||||
@@ -48,15 +47,16 @@ describe TopicTimestampChanger do
|
||||
let(:p3) { Fabricate(:post, topic: topic, created_at: new_timestamp + 3.day) }
|
||||
|
||||
it 'should set the new timestamp as the default timestamp' do
|
||||
Timecop.freeze do
|
||||
p3
|
||||
TopicTimestampChanger.new(topic: topic, timestamp: new_timestamp.to_f).change!
|
||||
freeze_time
|
||||
|
||||
p3.reload
|
||||
p3
|
||||
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p3.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
TopicTimestampChanger.new(topic: topic, timestamp: new_timestamp.to_f).change!
|
||||
|
||||
p3.reload
|
||||
|
||||
[:created_at, :updated_at].each do |column|
|
||||
expect(p3.public_send(column)).to be_within(1.second).of(new_timestamp)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user