diff --git a/app/models/annotations/dynamic.rb b/app/models/annotations/dynamic.rb index bdb509a3f0..80611923a0 100644 --- a/app/models/annotations/dynamic.rb +++ b/app/models/annotations/dynamic.rb @@ -6,7 +6,7 @@ class DuplicateFieldError < ActiveRecord::RecordNotUnique; end mount_uploaders :file, ImageUploader serialize :file, JSON - attr_accessor :set_fields, :set_attribution, :action, :action_data + attr_accessor :set_fields, :set_attribution, :action, :action_data, :bypass_status_publish_check belongs_to :annotation_type_object, class_name: 'DynamicAnnotation::AnnotationType', foreign_key: 'annotation_type', primary_key: 'annotation_type', optional: true has_many :fields, class_name: 'DynamicAnnotation::Field', foreign_key: 'annotation_id', primary_key: 'id', dependent: :destroy @@ -235,6 +235,7 @@ def update_fields next if value.blank? f = fields.select{ |x| x.field_name == field }.last || create_field(field, nil) f.value = value + f.bypass_status_publish_check = self.bypass_status_publish_check f.skip_check_ability = self.skip_check_ability unless self.skip_check_ability.nil? begin f.save! diff --git a/app/models/dynamic_annotation/field.rb b/app/models/dynamic_annotation/field.rb index 376f6e5ffa..9d85b188ed 100644 --- a/app/models/dynamic_annotation/field.rb +++ b/app/models/dynamic_annotation/field.rb @@ -2,7 +2,7 @@ class DynamicAnnotation::Field < ApplicationRecord include CheckElasticSearch has_paper_trail on: [:create, :update], save_changes: true, ignore: [:updated_at, :created_at], if: proc { |f| User.current.present? && (['verification_status_status', 'team_bot_response_formatted_data', 'language'].include?(f.field_name) || f.annotation_type == 'archiver' || f.annotation_type =~ /^task_response/) }, versions: { class_name: 'Version' } - attr_accessor :disable_es_callbacks + attr_accessor :disable_es_callbacks, :bypass_status_publish_check belongs_to :annotation, optional: true belongs_to :annotation_type_object, class_name: 'DynamicAnnotation::AnnotationType', foreign_key: 'annotation_type', primary_key: 'annotation_type', optional: true diff --git a/app/models/workflow/verification_status.rb b/app/models/workflow/verification_status.rb index 44c35d1990..f37233c40c 100644 --- a/app/models/workflow/verification_status.rb +++ b/app/models/workflow/verification_status.rb @@ -82,7 +82,7 @@ def apply_rules end def check_if_item_is_published - return if RequestStore.store[:bypass_status_publish_check] + return if self.bypass_status_publish_check published = begin (self.annotation.annotated.get_annotations('report_design').last.load.get_field_value('state') == 'published') rescue false end if published error = { diff --git a/test/models/bot/smooch_2_test.rb b/test/models/bot/smooch_2_test.rb index a9e2e63bd2..388311dba4 100644 --- a/test/models/bot/smooch_2_test.rb +++ b/test/models/bot/smooch_2_test.rb @@ -131,10 +131,9 @@ def teardown s.save! publish_report(pm_t) s = s.reload - RequestStore.store[:bypass_status_publish_check] = true s.status = 'in_progress' + s.bypass_status_publish_check = true s.save! - RequestStore.store[:bypass_status_publish_check] = false assert_equal 'in_progress', s.reload.status end