Skip to content

Conversation

sirwolfgang
Copy link
Contributor

This is a part of fixing the #697

@sirwolfgang sirwolfgang force-pushed the main branch 2 times, most recently from 80bfef3 to 99a2216 Compare April 25, 2024 08:24
sunny
sunny previously approved these changes May 2, 2024
Copy link
Member

@sunny sunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Can you add an entry to the CHANGELOG as well? 🙏🏻

@sirwolfgang
Copy link
Contributor Author

This is blocked by RubyMoney/money#1095

@yukideluxe
Copy link
Member

@sirwolfgang rebase this one with main if you have a chance, please! I just fixed the CI actions 😳

@sirwolfgang
Copy link
Contributor Author

@yukideluxe Rebased, lmk if I need to make changes to the testing stuff. Seems look right, but it's been a min

@yukideluxe
Copy link
Member

@yukideluxe Rebased, lmk if I need to make changes to the testing stuff. Seems look right, but it's been a min

I guess we need to release money first and then change the minimum requirement here https://github.com/RubyMoney/money-rails/blob/main/money-rails.gemspec#L29 to make the tests pass!

We intend to do a release by the end of THIS WEEK, and I'll make sure your change in money gets included 😊 I'll keep ya posted ✌🏻

@yukideluxe
Copy link
Member

@sirwolfgang I am back! I did some changes here that I am pretty sure will get this branch green so we can just merge 🙏🏻 Care to resolve the conflicts so we can try?! 😊

@sirwolfgang
Copy link
Contributor Author

@yukideluxe Done

@@ -35,7 +35,7 @@ def register_currency=(currency_options)
end

def set_currency_column_for_default_currency!
iso_code = default_currency.iso_code
iso_code = default_currency && default_currency.iso_code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Money only supports Ruby > 3.1, it is possible to use the safe navigation operator.

This kind of issues can be spotted with RuboCop

Suggested change
iso_code = default_currency && default_currency.iso_code
iso_code = default_currency&.iso_code

Comment on lines +952 to +962
context 'without a default currency' do
let(:product) { OtherProduct.new }

around do |example|
default_currency = Money.default_currency
Money.default_currency = nil

example.run

Money.default_currency = default_currency
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to use ensure here in case the test does not pass

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using around like this still calls whatever is called after example.run even when the test fails or raises exceptions, so this is fine 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and apologies for the misleading comment.

I have a branch with improvements to the spec, I'll remove the ensure from here

around(:each) do |example|
begin
Money.locale_backend = :currency
example.run
ensure
Money.locale_backend = :i18n
end
end

Copy link
Member

@yukideluxe yukideluxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am merging this because it has been open for a while! We can work on followup improvements – like https://github.com/RubyMoney/money-rails/pull/698/files#r2202413849 – in another PR 🙏🏻

Thanks <3

@yukideluxe yukideluxe merged commit 3015da3 into RubyMoney:main Jul 13, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants