diff --git a/modules/costs/app/views/hourly_rates/_rate.html.erb b/modules/costs/app/views/hourly_rates/_rate.html.erb
index ec658b5763..7c8b176b9f 100644
--- a/modules/costs/app/views/hourly_rates/_rate.html.erb
+++ b/modules/costs/app/views/hourly_rates/_rate.html.erb
@@ -53,7 +53,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= rate_form.text_field :rate,
index: id_or_index,
- value: rate.rate ? rate.rate.round(2) : "",
+ value: rate.rate ? unitless_currency_number(rate.rate.round(2)) : "",
required: true %>
<%= Setting.plugin_costs['costs_currency'] %>
diff --git a/modules/costs/spec/features/users_hourly_rates_spec.rb b/modules/costs/spec/features/users_hourly_rates_spec.rb
index d3eeff2a9f..28461b9b46 100644
--- a/modules/costs/spec/features/users_hourly_rates_spec.rb
+++ b/modules/costs/spec/features/users_hourly_rates_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
+require_relative '../spec_helper'
describe 'hourly rates on user edit', type: :feature, js: true do
let(:user) { create :admin }
@@ -36,7 +36,7 @@ describe 'hourly rates on user edit', type: :feature, js: true do
end
before do
- allow(User).to receive(:current).and_return user
+ login_as user
end
context 'with no rates' do
@@ -62,10 +62,10 @@ describe 'hourly rates on user edit', type: :feature, js: true do
describe 'deleting all rates' do
before do
- click_link 'Update' # go to update view for rates
+ click_link 'Update' # go to update view for rates
SeleniumHubWaiter.wait
- find('.icon-delete').click # delete last existing rate
- click_on 'Save' # save change
+ find('.icon-delete').click # delete last existing rate
+ click_on 'Save' # save change
end
# regression test: clicking save used to result in a error
@@ -77,4 +77,28 @@ describe 'hourly rates on user edit', type: :feature, js: true do
end
end
end
+
+ describe 'updating rates as German user', driver: :firefox_de do
+ let(:user) { create :admin, language: 'de' }
+ let!(:rate) { create(:default_hourly_rate, user: user, rate: 1.0) }
+
+ it 'allows editing without reinterpreting the number (Regression #42219)' do
+ visit edit_hourly_rate_path(user)
+
+ # Expect the german locale output
+ expect(page).to have_field("user[existing_rate_attributes][#{rate.id}][rate]", with: '1,00')
+
+ click_link 'Satz hinzufügen'
+
+ fill_in "user_new_rate_attributes_1_valid_from", with: (Time.zone.today + 1.day).iso8601
+ fill_in "user_new_rate_attributes_1_rate", with: '5,12'
+
+ click_button 'Speichern'
+
+ view_rates
+
+ expect(page).to have_selector('.currency', text: '1,00')
+ expect(page).to have_selector('.currency', text: '5,12')
+ end
+ end
end