From f9ffa3ef519b0c3ddf05866f345dfcacae57f282 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Wed, 22 Sep 2021 13:57:53 +0100 Subject: [PATCH] Fixes #3762 - Unable to create a ticket in web app if default for additional boolean value is FALSE. --- .../object_manager/attribute/validation/required.rb | 2 +- .../object_manager/attribute/validation/required_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/object_manager/attribute/validation/required.rb b/app/models/object_manager/attribute/validation/required.rb index 66ea91bc9..1bc6847ae 100644 --- a/app/models/object_manager/attribute/validation/required.rb +++ b/app/models/object_manager/attribute/validation/required.rb @@ -3,7 +3,7 @@ class ObjectManager::Attribute::Validation::Required < ObjectManager::Attribute::Validation::Backend def validate - return if value.present? + return if !value.nil? return if optional_for_user? invalid_because_attribute('is required but missing.') diff --git a/spec/models/object_manager/attribute/validation/required_spec.rb b/spec/models/object_manager/attribute/validation/required_spec.rb index 84f6adf89..3d8e29416 100644 --- a/spec/models/object_manager/attribute/validation/required_spec.rb +++ b/spec/models/object_manager/attribute/validation/required_spec.rb @@ -41,6 +41,14 @@ RSpec.describe ::ObjectManager::Attribute::Validation::Required do } end + context 'when boolean field with false values' do + let(:value) { false } + let(:attribute) { build(:object_manager_attribute_boolean) } + let(:action) { 'create_middle' } + + it_behaves_like 'a validation without errors' + end + context 'when action is edit' do let(:action) { 'edit' }