From 2e022215352695e34515af7fbe7cb8ff69731b37 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 18 Mar 2022 16:33:31 +0100 Subject: [PATCH] =?UTF-8?q?Fixes=20#4018=20-=20Upgraded=20to=205.1.0:=20pe?= =?UTF-8?q?nding=20time=20doesn=E2=80=99t=20show=20a=20date.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0318125144_issue4018_remove_old_translations.rb | 10 ++++++++++ .../issue_4018_remove_old_translations_spec.rb | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20220318125144_issue4018_remove_old_translations.rb create mode 100644 spec/db/migrate/issue_4018_remove_old_translations_spec.rb diff --git a/db/migrate/20220318125144_issue4018_remove_old_translations.rb b/db/migrate/20220318125144_issue4018_remove_old_translations.rb new file mode 100644 index 000000000..ed0851dbe --- /dev/null +++ b/db/migrate/20220318125144_issue4018_remove_old_translations.rb @@ -0,0 +1,10 @@ +# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ + +class Issue4018RemoveOldTranslations < ActiveRecord::Migration[6.0] + def change + # return if it's a new setup + return if !Setting.exists?(name: 'system_init_done') + + Translation.where(source: 'FORMAT_DATE', is_synchronized_from_codebase: false).find_each(&:destroy) + end +end diff --git a/spec/db/migrate/issue_4018_remove_old_translations_spec.rb b/spec/db/migrate/issue_4018_remove_old_translations_spec.rb new file mode 100644 index 000000000..b07f4c236 --- /dev/null +++ b/spec/db/migrate/issue_4018_remove_old_translations_spec.rb @@ -0,0 +1,14 @@ +# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe Issue4018RemoveOldTranslations, type: :db_migration do + before do + create(:translation, source: 'FORMAT_DATE', target_initial: 'Datum', target: 'Datum', is_synchronized_from_codebase: false) + end + + it 'does remove old translations for source "FORMAT_DATE"' do + migrate + expect(Translation.where(locale: 'de-de', source: 'FORMAT_DATE').count).to eq(1) + end +end