Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions spec/active_record/monetizable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def assert_monetized_attributes(monetized_attributes, expected_attributes)
end

it "raises an exception if it can't change currency" do
expect {
expect do
Product.new.price = Money.new(10, "RUB")
}.to raise_error(
end.to raise_error(
MoneyRails::ActiveRecord::Monetizable::ReadOnlyCurrencyException,
"Can't change readonly currency 'USD' to 'RUB' for field 'price'",
)
Expand Down Expand Up @@ -1045,16 +1045,16 @@ def assert_monetized_attributes(monetized_attributes, expected_attributes)
after { MoneyRails.raise_error_on_money_parsing = false }

it "raises a MoneyRails::Error when given an invalid value" do
expect {
expect do
product.write_monetized :price, :price_cents, "10-50", false, nil, {}
}.to raise_error(MoneyRails::Error)
end.to raise_error(MoneyRails::Error)
end

it "raises a MoneyRails::Error error when trying to set invalid currency" do
allow(product).to receive(:currency_for_price).and_return("INVALID_CURRENCY")
expect {
expect do
product.write_monetized :price, :price_cents, 10, false, nil, {}
}.to raise_error(MoneyRails::Error)
end.to raise_error(MoneyRails::Error)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@
it "accepts default currency which doesn't have minor unit" do
old_currency = MoneyRails.default_currency

expect {
expect do
MoneyRails.default_currency = :jpy
}.to_not raise_error
end.to_not raise_error

expect(MoneyRails.amount_column[:postfix]).to eq("_cents")

Expand Down
12 changes: 6 additions & 6 deletions spec/mongoid/mongoid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
let(:priceable_from_num) { Priceable.create(price: 1) }
let(:priceable_from_string) { Priceable.create(price: "1 EUR") }
let(:priceable_from_hash) { Priceable.create(price: { cents: 100, currency_iso: "EUR" }) }
let(:priceable_from_blank_strings_hash) {
let(:priceable_from_blank_strings_hash) do
Priceable.create(price: { cents: "", currency_iso: "" })
}
let(:priceable_from_hash_with_indifferent_access) {
end
let(:priceable_from_hash_with_indifferent_access) do
Priceable.create(price: { cents: 100, currency_iso: "EUR" }.with_indifferent_access)
}
end
let(:priceable_from_string_with_hyphen) { Priceable.create(price: "1-2 EUR") }
let(:priceable_from_string_with_unknown_currency) { Priceable.create(price: "1 TLDR") }
let(:priceable_with_infinite_precision) { Priceable.create(price: Money.new(BigDecimal("100.1"), "EUR")) }
let(:priceable_with_hash_field) {
let(:priceable_with_hash_field) do
Priceable.create(price_hash: {
key1: Money.new(100, "EUR"),
key2: Money.new(200, "USD"),
})
}
end

context "mongoize" do
it "correctly mongoizes nil to nil" do
Expand Down