Fix user decimals for comma decimal separators

https://community.openproject.org/wp/42219
pull/10627/head
Oliver Günther 3 years ago
parent 16123f5dd7
commit dff8d963f2
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      modules/costs/app/views/hourly_rates/_rate.html.erb
  2. 34
      modules/costs/spec/features/users_hourly_rates_spec.rb

@ -53,7 +53,7 @@ See COPYRIGHT and LICENSE files for more details.
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label>
<%= 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 %>
<span class="form-label">
<%= Setting.plugin_costs['costs_currency'] %>

@ -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

Loading…
Cancel
Save