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