diff --git a/Gemfile b/Gemfile index 616df8484..b04181d24 100644 --- a/Gemfile +++ b/Gemfile @@ -87,7 +87,6 @@ group :test do gem "mocha", :require => "mocha/setup" gem "ffaker" gem "simplecov", :require => false - gem "timecop" gem "webmock" gem "minitest-ci" gem "mock_redis" diff --git a/Gemfile.lock b/Gemfile.lock index d5c85d3fb..fc9af36fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -391,7 +391,6 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (2.0.9) - timecop (0.9.1) tins (1.21.1) twitter (6.2.0) addressable (~> 2.3) @@ -510,7 +509,6 @@ DEPENDENCIES streamio-ffmpeg stripe term-ansicolor - timecop twitter unicorn unicorn-worker-killer diff --git a/db/populate.rb b/db/populate.rb index e98ca3148..c7162525b 100644 --- a/db/populate.rb +++ b/db/populate.rb @@ -1,5 +1,4 @@ require 'set' -require 'timecop' CurrentUser.ip_addr = "127.0.0.1" Delayed::Worker.delay_jobs = false @@ -40,7 +39,7 @@ end if User.count == 0 puts "Creating users" - Timecop.travel(1.month.ago) do + begin user = User.create( :name => "admin", :password => "password1", diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index da95627e6..284bef9de 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -139,7 +139,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest should "update an artist" do old_timestamp = @wiki_page.updated_at - travel_to(1.minute.from_now) do + travel(1.minute) do put_auth artist_path(@artist.id), @user, params: {artist: {notes: "rex", url_string: "http://example.com\nhttp://monet.com"}} end @artist.reload @@ -153,7 +153,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest old_timestamp = @wiki_page.updated_at old_updater_id = @wiki_page.updater_id - travel_to(1.minutes.from_now) do + travel(1.minute) do as(@another_user) do @artist.update(notes: "testing") end diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 95bf7c487..a558b235a 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -76,10 +76,10 @@ class NotesControllerTest < ActionDispatch::IntegrationTest context "revert action" do setup do as_user do - travel_to(1.day.from_now) do + travel(1.day) do @note.update(:body => "111") end - travel_to(2.days.from_now) do + travel(2.days) do @note.update(:body => "222") end end diff --git a/test/functional/post_replacements_controller_test.rb b/test/functional/post_replacements_controller_test.rb index e92e0e01b..15780fd10 100644 --- a/test/functional/post_replacements_controller_test.rb +++ b/test/functional/post_replacements_controller_test.rb @@ -31,7 +31,7 @@ class PostReplacementsControllerTest < ActionDispatch::IntegrationTest @post.reload end - travel_to(Time.now + PostReplacement::DELETION_GRACE_PERIOD + 1.day) do + travel(PostReplacement::DELETION_GRACE_PERIOD + 1.day) do Delayed::Worker.new.work_off end diff --git a/test/functional/post_versions_controller_test.rb b/test/functional/post_versions_controller_test.rb index 824f185aa..682fb1bda 100644 --- a/test/functional/post_versions_controller_test.rb +++ b/test/functional/post_versions_controller_test.rb @@ -10,10 +10,10 @@ class PostVersionsControllerTest < ActionDispatch::IntegrationTest setup do @user.as_current do @post = create(:post) - travel_to(2.hours.from_now) do + travel(2.hours) do @post.update(:tag_string => "1 2", :source => "xxx") end - travel_to(4.hours.from_now) do + travel(4.hours) do @post.update(:tag_string => "2 3", :rating => "e") end @versions = @post.versions diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index 7304f47e4..08cf5578e 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -167,10 +167,10 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest as_user do @wiki_page = create(:wiki_page, :body => "1") end - travel_to(1.day.from_now) do + travel(1.day) do @wiki_page.update(:body => "1 2") end - travel_to(2.days.from_now) do + travel(2.days) do @wiki_page.update(:body => "1 2 3") end end diff --git a/test/unit/artist_commentary_test.rb b/test/unit/artist_commentary_test.rb index 74c7e0ebd..e41ee5be6 100644 --- a/test/unit/artist_commentary_test.rb +++ b/test/unit/artist_commentary_test.rb @@ -71,7 +71,7 @@ class ArtistCommentaryTest < ActiveSupport::TestCase end should "create a new version if outside merge window" do - travel_to(2.hours.from_now) do + travel(2.hours) do @artcomm.update(original_title: "bar") assert_equal(2, @post.artist_commentary.versions.size) diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 89877fcd6..7d650f7a4 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -19,7 +19,7 @@ class ArtistTest < ActiveSupport::TestCase context "An artist" do setup do - user = Timecop.travel(1.month.ago) {FactoryBot.create(:user)} + user = travel_to(1.month.ago) {FactoryBot.create(:user)} CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -458,7 +458,7 @@ class ArtistTest < ActiveSupport::TestCase assert_difference("ArtistVersion.count") do artist.other_names = "xxx" - Timecop.travel(1.day.from_now) do + travel(1.day) do artist.save end end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index 218e2e670..2455d7113 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -143,7 +143,7 @@ class CommentTest < ActiveSupport::TestCase Danbooru.config.stubs(:comment_threshold).returns(1) p = FactoryBot.create(:post) c1 = FactoryBot.create(:comment, :post => p) - Timecop.travel(2.seconds.from_now) do + travel(2.seconds) do c2 = FactoryBot.create(:comment, :post => p) end p.reload @@ -158,7 +158,7 @@ class CommentTest < ActiveSupport::TestCase post.reload assert_equal(c1.created_at.to_s, post.last_commented_at.to_s) - Timecop.travel(2.seconds.from_now) do + travel(2.seconds) do c2 = FactoryBot.create(:comment, :post => post) post.reload assert_equal(c2.created_at.to_s, post.last_commented_at.to_s) diff --git a/test/unit/forum_post_test.rb b/test/unit/forum_post_test.rb index 5589922ab..a8478b4c0 100644 --- a/test/unit/forum_post_test.rb +++ b/test/unit/forum_post_test.rb @@ -80,7 +80,7 @@ class ForumPostTest < ActiveSupport::TestCase 9.times do @posts << FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) end - Timecop.travel(2.seconds.from_now) do + travel(2.seconds) do @posts << FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) end end @@ -135,7 +135,7 @@ class ForumPostTest < ActiveSupport::TestCase should "update the topic when created" do @original_topic_updated_at = @topic.updated_at - Timecop.travel(1.second.from_now) do + travel(1.second) do post = FactoryBot.create(:forum_post, :topic_id => @topic.id) end @topic.reload @@ -149,14 +149,14 @@ class ForumPostTest < ActiveSupport::TestCase end # updating the original post - Timecop.travel(1.second.from_now) do + travel(1.second) do posts.first.update_attributes(:body => "xxx") end @topic.reload assert_equal(posts.first.updated_at.to_s, @topic.updated_at.to_s) # updating a non-original post - Timecop.travel(2.seconds.from_now) do + travel(2.seconds) do posts.last.update_attributes(:body => "xxx") end assert_equal(posts.first.updated_at.to_s, @topic.updated_at.to_s) diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index d20ce611d..9eaa9f91e 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -76,7 +76,7 @@ class NoteTest < ActiveSupport::TestCase should "create a version" do assert_difference("NoteVersion.count", 1) do - Timecop.travel(1.day.from_now) do + travel(1.day) do @note = FactoryBot.create(:note, :post => @post) end end @@ -135,7 +135,7 @@ class NoteTest < ActiveSupport::TestCase should "create a version" do assert_difference("NoteVersion.count", 1) do - Timecop.travel(1.day.from_now) do + travel(1.day) do @note.update_attributes(:body => "fafafa") end end @@ -181,7 +181,7 @@ class NoteTest < ActiveSupport::TestCase assert_equal(2, NoteVersion.count) assert_equal([1, 2], @note.versions.map(&:version)) assert_equal([@user.id, @vandal.id], @note.versions.map(&:updater_id)) - Timecop.travel(1.day.from_now) do + travel(1.day) do Note.undo_changes_by_user(@vandal.id) end @note.reload diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index fa1fd8fdc..5380fe86b 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -4,7 +4,7 @@ require 'test_helper' class PoolTest < ActiveSupport::TestCase setup do - Timecop.travel(1.month.ago) do + travel_to(1.month.ago) do @user = FactoryBot.create(:user) CurrentUser.user = @user end @@ -281,7 +281,7 @@ class PoolTest < ActiveSupport::TestCase should "create new versions for each distinct user" do assert_equal(1, @pool.versions.size) - user2 = Timecop.travel(1.month.ago) {FactoryBot.create(:user)} + user2 = travel_to(1.month.ago) {FactoryBot.create(:user)} CurrentUser.scoped(user2, "127.0.0.2") do @pool.post_ids = [@p1.id] diff --git a/test/unit/post_approval_test.rb b/test/unit/post_approval_test.rb index 5453b6e0e..c6603a918 100644 --- a/test/unit/post_approval_test.rb +++ b/test/unit/post_approval_test.rb @@ -49,7 +49,7 @@ class PostApprovalTest < ActiveSupport::TestCase @post.approve!(@approver2) assert_not_equal(@approver.id, @post.approver_id) CurrentUser.user = @user3 - travel_to(PostFlag::COOLDOWN_PERIOD.from_now + 1.minute) do + travel(PostFlag::COOLDOWN_PERIOD + 1.minute) do @post.flag!("blah blah") end diff --git a/test/unit/post_archive_test.rb b/test/unit/post_archive_test.rb index 54c3fad38..f171c04cf 100644 --- a/test/unit/post_archive_test.rb +++ b/test/unit/post_archive_test.rb @@ -5,7 +5,7 @@ class PostArchiveTest < ActiveSupport::TestCase context "A post" do setup do - Timecop.travel(1.month.ago) do + travel_to(1.month.ago) do @user = FactoryBot.create(:user) end CurrentUser.user = @user diff --git a/test/unit/post_disapproval_test.rb b/test/unit/post_disapproval_test.rb index af2248e75..e2fe42aef 100644 --- a/test/unit/post_disapproval_test.rb +++ b/test/unit/post_disapproval_test.rb @@ -52,7 +52,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase setup do @post = FactoryBot.create(:post) @user = FactoryBot.create(:user) - Timecop.travel(2.months.ago) do + travel_to(2.months.ago) do @disapproval = PostDisapproval.create(:user => @user, :post => @post) end end diff --git a/test/unit/post_event_test.rb b/test/unit/post_event_test.rb index 2b709149d..372f6d193 100644 --- a/test/unit/post_event_test.rb +++ b/test/unit/post_event_test.rb @@ -4,7 +4,7 @@ class PostEventTest < ActiveSupport::TestCase def setup super - Timecop.travel(2.weeks.ago) do + travel_to(2.weeks.ago) do CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" end diff --git a/test/unit/post_pruner_test.rb b/test/unit/post_pruner_test.rb index 7941671bc..a8cdeec4e 100644 --- a/test/unit/post_pruner_test.rb +++ b/test/unit/post_pruner_test.rb @@ -8,7 +8,7 @@ class PostPrunerTest < ActiveSupport::TestCase CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - Timecop.travel(2.weeks.ago) do + travel_to(2.weeks.ago) do @flagger = FactoryBot.create(:gold_user) end @old_post = FactoryBot.create(:post, :created_at => 5.days.ago, :is_pending => true) diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 63a9755f8..e85ab296e 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -18,7 +18,7 @@ class PostTest < ActiveSupport::TestCase def setup super - Timecop.travel(2.weeks.ago) do + travel_to(2.weeks.ago) do @user = FactoryBot.create(:user) end CurrentUser.user = @user @@ -1278,7 +1278,7 @@ class PostTest < ActiveSupport::TestCase should "create a new version if it's been over an hour since the last update" do post = FactoryBot.create(:post) - Timecop.travel(6.hours.from_now) do + travel(6.hours) do assert_difference("PostArchive.count", 1) do post.update_attributes(:tag_string => "zzz") end @@ -2660,7 +2660,7 @@ class PostTest < ActiveSupport::TestCase context "a post that is rating locked" do setup do @post = FactoryBot.create(:post, :rating => "s") - Timecop.travel(2.hours.from_now) do + travel(2.hours) do @post.update(rating: "q", is_rating_locked: true) end end diff --git a/test/unit/post_version_test.rb b/test/unit/post_version_test.rb index 40c93d55f..5a788dce3 100644 --- a/test/unit/post_version_test.rb +++ b/test/unit/post_version_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostVersionTest < ActiveSupport::TestCase context "A post" do setup do - Timecop.travel(1.month.ago) do + travel_to(1.month.ago) do @user = FactoryBot.create(:user) end CurrentUser.user = @user @@ -68,7 +68,7 @@ class PostVersionTest < ActiveSupport::TestCase context "that has been updated" do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - Timecop.travel(1.minute.ago) do + travel_to(1.minute.ago) do @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") end @post.update_attributes(:tag_string => "bbb ccc xxx", :source => "") diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index e26cb116a..5e245067d 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -5,7 +5,7 @@ class TagAliasTest < ActiveSupport::TestCase setup do @admin = FactoryBot.create(:admin_user) - Timecop.travel(1.month.ago) do + travel_to(1.month.ago) do user = FactoryBot.create(:user) CurrentUser.user = user end diff --git a/test/unit/tag_test.rb b/test/unit/tag_test.rb index bf93b2edd..5ccfd3608 100644 --- a/test/unit/tag_test.rb +++ b/test/unit/tag_test.rb @@ -16,7 +16,7 @@ class TagTest < ActiveSupport::TestCase setup do Tag.stubs(:trending_count_limit).returns(0) - Timecop.travel(1.week.ago) do + travel_to(1.week.ago) do FactoryBot.create(:post, :tag_string => "aaa") FactoryBot.create(:post, :tag_string => "bbb") end diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index bcf1e5575..c9dedfbe5 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -84,7 +84,7 @@ class WikiPageTest < ActiveSupport::TestCase assert_difference("WikiPageVersion.count") do @wiki_page.title = "yyy" - Timecop.travel(1.day.from_now) do + travel(1.day) do @wiki_page.save end end @@ -92,7 +92,7 @@ class WikiPageTest < ActiveSupport::TestCase should "revert to a prior version" do @wiki_page.title = "yyy" - Timecop.travel(1.day.from_now) do + travel(1.day) do @wiki_page.save end version = WikiPageVersion.first