Skip to content

Commit

Permalink
CV2-6040: add flag to foce status update for item with published report
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Feb 6, 2025
1 parent 968b33d commit 23210b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/bot/smooch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ def self.inherit_status_and_send_report(rid)
s = target.annotations.where(annotation_type: 'verification_status').last&.load
status = parent.last_verification_status
if !s.nil? && s.status != status
RequestStore.store[:bypass_status_publish_check] = true
s.status = status
s.save
RequestStore.store[:bypass_status_publish_check] = false
end

# A relationship created by the Smooch Bot or Alegre Bot is related to search results (unless it's a suggestion that was confirmed), so the user has already received the report as a search result... no need to send another report
Expand Down
1 change: 1 addition & 0 deletions app/models/workflow/verification_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def apply_rules
end

def check_if_item_is_published
return if RequestStore.store[: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 = {
Expand Down
16 changes: 16 additions & 0 deletions test/models/bot/smooch_2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ def teardown
end
end

test "should inherit status from parent even child is published" do
pm_s = create_project_media team: @team
pm_t = create_project_media team: @team
r = create_relationship source_id: pm_s.id, target_id: pm_t.id, relationship_type: Relationship.confirmed_type
s = pm_t.annotations.where(annotation_type: 'verification_status').last.load
s.status = 'verified'
s.save!
publish_report(pm_t)
s = s.reload
RequestStore.store[:bypass_status_publish_check] = true
s.status = 'in_progress'
s.save!
RequestStore.store[:bypass_status_publish_check] = false
assert_equal 'in_progress', s.reload.status
end

test "should send message to user when status changes" do
u = create_user is_admin: true
uid = random_string
Expand Down

0 comments on commit 23210b1

Please sign in to comment.