Sha256: 645482f1a0f7b8eabf5304f3800be312f96774b587699d1887cd2890a03f9ec0
Contents?: true
Size: 1.2 KB
Versions: 10
Compression:
Stored size: 1.2 KB
Contents
require "rails_helper" describe ActiveRecordCommaTypeCast, type: :model do let(:line) { create(:billing_machine_invoice_line) } it "should accept , as decimal separator" do line.update!(quantity: "12,34") expect(line.reload.quantity).to eq 12.34 end it "should accept . as decimal separator" do line.update!(quantity: "12.34") expect(line.reload.quantity).to eq 12.34 end it "should accept space as group separator" do line.update!(quantity: "123 456,78") expect(line.reload.quantity).to eq 123456.78 line.update!(quantity: "123 456.78") expect(line.reload.quantity).to eq 123456.78 end it "should accept nbsp as group separator" do line.update!(quantity: "123 456,78") expect(line.reload.quantity).to eq 123456.78 line.update!(quantity: "123 456.78") expect(line.reload.quantity).to eq 123456.78 end it "should accept negative numbers" do line.update!(quantity: "-12,34") expect(line.reload.quantity).to eq -12.34 line.update!(quantity: "-12.34") expect(line.reload.quantity).to eq -12.34 end it "should accept trailing chars" do line.update!(quantity: "abc 12.34 def") expect(line.reload.quantity).to eq 12.34 end end
Version data entries
10 entries across 10 versions & 1 rubygems