From 1ba497d6acf4697585ab147399722ef301479d6d Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Tue, 16 Nov 2021 13:14:22 +0100 Subject: [PATCH] Fixes #3851 - Default values of new group dialog is different in german vs. english. --- db/migrate/20211115135421_issue3851.rb | 25 ++++++++++++++++++++ db/seeds/object_manager_attributes.rb | 10 ++++---- spec/db/migrate/issue_3851_spec.rb | 32 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20211115135421_issue3851.rb create mode 100644 spec/db/migrate/issue_3851_spec.rb diff --git a/db/migrate/20211115135421_issue3851.rb b/db/migrate/20211115135421_issue3851.rb new file mode 100644 index 000000000..458882c2a --- /dev/null +++ b/db/migrate/20211115135421_issue3851.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +class Issue3851 < ActiveRecord::Migration[6.0] + def change + return if !Setting.exists?(name: 'system_init_done') + + fix_follow_up_assignment + fix_follow_up_possible + end + + def fix_follow_up_assignment + follow_up_assignment = ObjectManager::Attribute.for_object('Group').find_by(name: 'follow_up_assignment') + follow_up_assignment.data_option['default'] = 'true' + follow_up_assignment.screens['create']['-all-']['null'] = false + follow_up_assignment.screens['edit']['-all-']['null'] = false + follow_up_assignment.save! + end + + def fix_follow_up_possible + follow_up_possible = ObjectManager::Attribute.for_object('Group').find_by(name: 'follow_up_possible') + follow_up_possible.screens['create']['-all-']['null'] = false + follow_up_possible.screens['edit']['-all-']['null'] = false + follow_up_possible.save! + end +end diff --git a/db/seeds/object_manager_attributes.rb b/db/seeds/object_manager_attributes.rb index af7971427..307d76369 100644 --- a/db/seeds/object_manager_attributes.rb +++ b/db/seeds/object_manager_attributes.rb @@ -1634,12 +1634,12 @@ ObjectManager::Attribute.add( screens: { create: { '-all-' => { - null: true, + null: false, }, }, edit: { '-all-' => { - null: true, + null: false, }, }, }, @@ -1656,7 +1656,7 @@ ObjectManager::Attribute.add( display: 'Assign Follow-Ups', data_type: 'select', data_option: { - default: 'yes', + default: 'true', options: { true: 'yes', false: 'no', @@ -1670,12 +1670,12 @@ ObjectManager::Attribute.add( screens: { create: { '-all-' => { - null: true, + null: false, }, }, edit: { '-all-' => { - null: true, + null: false, }, }, }, diff --git a/spec/db/migrate/issue_3851_spec.rb b/spec/db/migrate/issue_3851_spec.rb new file mode 100644 index 000000000..683536e9f --- /dev/null +++ b/spec/db/migrate/issue_3851_spec.rb @@ -0,0 +1,32 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe Issue3851, type: :db_migration do + let(:follow_up_assignment) { ObjectManager::Attribute.for_object('Group').find_by(name: 'follow_up_assignment') } + let(:follow_up_possible) { ObjectManager::Attribute.for_object('Group').find_by(name: 'follow_up_possible') } + + before do + migrate + end + + it 'shows field follow_up_assignment with correct default' do + expect(follow_up_assignment.data_option['default']).to eq('true') + end + + it 'shows field follow_up_assignment required in create' do + expect(follow_up_assignment.screens['create']['-all-']['null']).to eq(false) + end + + it 'shows field follow_up_assignment required in edit' do + expect(follow_up_assignment.screens['edit']['-all-']['null']).to eq(false) + end + + it 'shows field follow_up_possible required in create' do + expect(follow_up_possible.screens['create']['-all-']['null']).to eq(false) + end + + it 'shows field follow_up_possible required in edit' do + expect(follow_up_possible.screens['edit']['-all-']['null']).to eq(false) + end +end