Merge pull request #10627 from opf/fix/user-rate-decimal

Fix user decimals for comma decimal separators
pull/10631/head
ulferts 3 years ago committed by GitHub
commit 8cbe2a7c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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> <label class="hidden-for-sighted" for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label>
<%= rate_form.text_field :rate, <%= rate_form.text_field :rate,
index: id_or_index, index: id_or_index,
value: rate.rate ? rate.rate.round(2) : "", value: rate.rate ? unitless_currency_number(rate.rate.round(2)) : "",
required: true %> required: true %>
<span class="form-label"> <span class="form-label">
<%= Setting.plugin_costs['costs_currency'] %> <%= Setting.plugin_costs['costs_currency'] %>

@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details. # 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 describe 'hourly rates on user edit', type: :feature, js: true do
let(:user) { create :admin } let(:user) { create :admin }
@ -36,7 +36,7 @@ describe 'hourly rates on user edit', type: :feature, js: true do
end end
before do before do
allow(User).to receive(:current).and_return user login_as user
end end
context 'with no rates' do 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 describe 'deleting all rates' do
before do before do
click_link 'Update' # go to update view for rates click_link 'Update' # go to update view for rates
SeleniumHubWaiter.wait SeleniumHubWaiter.wait
find('.icon-delete').click # delete last existing rate find('.icon-delete').click # delete last existing rate
click_on 'Save' # save change click_on 'Save' # save change
end end
# regression test: clicking save used to result in a error # 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 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 end

Loading…
Cancel
Save