Skip to content

Commit 5ec7678

Browse files
committed
Fix string spec
1 parent d7eb476 commit 5ec7678

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

spec/mongoid/criteria_spec.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,13 +2756,33 @@ def self.ages; self; end
27562756
Band.create!(name: "Boards of Canada", sales: sales)
27572757
end
27582758

2759-
let(:from_db) do
2759+
it "cannot find values when querying using a BigDecimal value" do
27602760
Mongoid.map_big_decimal_to_decimal128 = true
2761-
Band.where(sales: sales.to_s).first
2761+
from_db = Band.where(sales: sales).first
2762+
expect(from_db).to eq(nil)
27622763
end
27632764

2764-
it "finds the document by the big decimal value" do
2765-
expect(from_db).to eq(band)
2765+
it "cannot find values when querying using a string value" do
2766+
Mongoid.map_big_decimal_to_decimal128 = true
2767+
from_db = Band.where(sales: sales.to_s).first
2768+
expect(from_db).to eq(nil)
2769+
end
2770+
2771+
context "after converting value" do
2772+
before do
2773+
Mongoid.map_big_decimal_to_decimal128 = true
2774+
band.set(sales: band.sales)
2775+
end
2776+
2777+
it "can find values when querying using a BigDecimal value" do
2778+
from_db = Band.where(sales: sales).first
2779+
expect(from_db).to eq(band)
2780+
end
2781+
2782+
it "can find values when querying using a string value" do
2783+
from_db = Band.where(sales: sales.to_s).first
2784+
expect(from_db).to eq(band)
2785+
end
27662786
end
27672787
end
27682788
end

0 commit comments

Comments
 (0)