diff --git a/spec/components/freedom_patches/schema_migration_details_spec.rb b/spec/components/freedom_patches/schema_migration_details_spec.rb index 02e0a898c3..05a7a0d9a6 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 33fc873a1a..34e651eb2d 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