The test "Budget Investments Show milestones" was failing in certain cases where `Globalize.locale` had been changed in a previous test. Since having different values in `Globalize.locale` and `I18n.locale` has proven to be an issue on the test enviroment, this commit also changes application code in order to avoid similar situations on production. See issue #2718.
25 lines
626 B
Ruby
25 lines
626 B
Ruby
module Translatable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
before_action :delete_translations, only: [:update]
|
|
end
|
|
|
|
private
|
|
|
|
def translation_params(params)
|
|
resource_model.globalize_attribute_names.select { |k, v| params.include?(k.to_sym) && params[k].present? }
|
|
end
|
|
|
|
def delete_translations
|
|
locales = resource_model.globalize_locales.
|
|
select { |k, v| params[:delete_translations].include?(k.to_sym) && params[:delete_translations][k] == "1" }
|
|
locales.each do |l|
|
|
Globalize.with_locale(l) do
|
|
resource.translation.destroy
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|