From ebc82eb63e188dbf2ae2158845a0bd8db2b1cc1e Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Tue, 26 Nov 2019 16:39:14 +1100 Subject: [PATCH] DEV: correct spec failures in PG 12 PG 12 changes internals in a subtle way, time jitter is noticed in a few new spots (which is normal) and default ordering is a bit different which is meant to be random anyway. --- .../schema_migration_details_spec.rb | 4 ++-- spec/models/top_topic_spec.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/components/freedom_patches/schema_migration_details_spec.rb b/spec/components/freedom_patches/schema_migration_details_spec.rb index 02e0a898c3a..05a7a0d9a6a 100644 --- a/spec/components/freedom_patches/schema_migration_details_spec.rb +++ b/spec/components/freedom_patches/schema_migration_details_spec.rb @@ -15,13 +15,13 @@ describe FreedomPatches::SchemaMigrationDetails do end it "logs information on migration" do - migration = TestMigration.new("awesome_migration", "20160225050318") + migration = TestMigration.new("awesome_migration", "20110225050318") ActiveRecord::Base.connection_pool.with_connection do |conn| migration.exec_migration(conn, :up) end - info = SchemaMigrationDetail.find_by(version: "20160225050318") + info = SchemaMigrationDetail.find_by(version: "20110225050318") expect(info.duration).to be > 0 expect(info.git_version).to eq Discourse.git_version diff --git a/spec/models/top_topic_spec.rb b/spec/models/top_topic_spec.rb index 33fc873a1a7..34e651eb2d8 100644 --- a/spec/models/top_topic_spec.rb +++ b/spec/models/top_topic_spec.rb @@ -91,8 +91,8 @@ describe TopTopic do top_topics = TopTopic.all expect(top_topics.where(topic_id: topic_1.id).pluck_first(:yearly_score)).to eq(27) - expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to eq(18.301029995664) - expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to eq(11.2041199826559) + expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(18.301029995664) + expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(11.2041199826559) # when 'top_topics_formula_first_post_likes_multiplier' setting is changed SiteSetting.top_topics_formula_log_views_multiplier = 2 # unchanged @@ -109,8 +109,8 @@ describe TopTopic do top_topics = TopTopic.all expect(top_topics.where(topic_id: topic_1.id).pluck_first(:yearly_score)).to eq(69) - expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to eq(33.301029995664) - expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to eq(10.602059991328) + expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(33.301029995664) + expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(10.602059991328) # when 'top_topics_formula_least_likes_per_post_multiplier' setting is changed SiteSetting.top_topics_formula_log_views_multiplier = 2 # unchanged @@ -127,8 +127,8 @@ describe TopTopic do top_topics = TopTopic.all expect(top_topics.where(topic_id: topic_1.id).pluck_first(:yearly_score)).to eq(30) - expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to eq(21.301029995664) - expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to eq(10.602059991328) + expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(21.301029995664) + expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(10.602059991328) # handles invalid string value SiteSetting.top_topics_formula_log_views_multiplier = "not good" @@ -139,8 +139,8 @@ describe TopTopic do top_topics = TopTopic.all expect(top_topics.where(topic_id: topic_1.id).pluck_first(:yearly_score)).to eq(27) - expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to eq(18.301029995664) - expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to eq(10.602059991328) + expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(18.301029995664) + expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(10.602059991328) end end