diff --git a/app/models/workflow/concerns/dynamic_annotation_field_concern.rb b/app/models/workflow/concerns/dynamic_annotation_field_concern.rb index fd34ed6d06..b4c7784b60 100644 --- a/app/models/workflow/concerns/dynamic_annotation_field_concern.rb +++ b/app/models/workflow/concerns/dynamic_annotation_field_concern.rb @@ -124,7 +124,9 @@ def can_set_workflow_status if ::Workflow::Workflow.is_field_name_a_workflow?(self.field_name) options = self.workflow_options_and_roles value = self.value&.to_sym - old_value = self.previous_value&.to_sym + old_value = self.previous_value + return true unless old_value.is_a?(String) + old_value = old_value.to_sym self.previous_status = old_value user = User.current diff --git a/test/models/dynamic_annotation/field_test.rb b/test/models/dynamic_annotation/field_test.rb index 0300209927..e72abb7022 100644 --- a/test/models/dynamic_annotation/field_test.rb +++ b/test/models/dynamic_annotation/field_test.rb @@ -265,6 +265,21 @@ def field_formatter_name_response assert_equal 'https://archive.org/web/', f.reload.value[0]['url'] end + test "should ignore permission check for changing status if previous value is empty" do + create_verification_status_stuff + pm = create_project_media + a = create_dynamic_annotation annotation_type: 'verification_status', annotated: pm, set_fields: { verification_status_status: 'undetermined' }.to_json + assert_equal 'undetermined', pm.reload.last_status + f = a.get_field('verification_status_status') + f.update_column(:value, []) + f = DynamicAnnotation::Field.find(f.id) + assert_nothing_raised do + f.value = 'false' + f.save! + end + assert_equal 'false', pm.reload.last_status + end + protected def create_geojson_field