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 a1cc0469f..ac3657230 100644 --- a/db/seeds/object_manager_attributes.rb +++ b/db/seeds/object_manager_attributes.rb @@ -1691,12 +1691,12 @@ ObjectManager::Attribute.add( screens: { create: { '-all-' => { - null: true, + null: false, }, }, edit: { '-all-' => { - null: true, + null: false, }, }, }, @@ -1713,7 +1713,7 @@ ObjectManager::Attribute.add( display: __('Assign Follow-Ups'), data_type: 'select', data_option: { - default: 'yes', + default: 'true', options: { true: 'yes', false: 'no', @@ -1727,12 +1727,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