Skip to content

Commit e667850

Browse files
p-mongop
andauthored
RUBY-2928 unpend test in Mongoid (#5217)
Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 38370cd commit e667850

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

spec/mongoid/contextual/mongo_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,9 @@
571571

572572
context 'when storing BigDecimal as decimal128' do
573573
config_override :map_big_decimal_to_decimal128, true
574+
min_bson_version '4.15.0'
574575

575576
it "returns the non-demongoized distinct field values" do
576-
pending 'RUBY-2928'
577-
578577
expect(context.distinct(:sales).sort).to eq([ BSON::Decimal128.new("1E2"), BSON::Decimal128.new("2E3") ])
579578
end
580579
end

spec/support/constraints.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ def driver_version(precision)
2727
Mongo::VERSION.split('.')[0...precision].map(&:to_i)
2828
end
2929

30+
def min_bson_version(version)
31+
required_version = version.split('.').map(&:to_i)
32+
actual_version = bson_version(required_version.length)
33+
before(:all) do
34+
if (actual_version <=> required_version) < 0
35+
skip "bson-ruby version #{version} or higher is required"
36+
end
37+
end
38+
end
39+
40+
def max_bson_version(version)
41+
required_version = version.split('.').map(&:to_i)
42+
actual_version = bson_version(required_version.length)
43+
before(:all) do
44+
if (actual_version <=> required_version) > 0
45+
skip "bson-ruby version #{version} or lower is required"
46+
end
47+
end
48+
end
49+
50+
def bson_version(precision)
51+
BSON::VERSION.split('.')[0...precision].map(&:to_i)
52+
end
53+
3054
def min_rails_version(version)
3155
unless version =~ /\A\d+\.\d+\z/
3256
raise ArgumentError, "Version can only be major.minor: #{version}"

0 commit comments

Comments
 (0)