Skip to content

Commit

Permalink
CV2-5451: set confirmed before creation based on relationship type
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Oct 9, 2024
1 parent b6c59c6 commit 4467039
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Relationship < ApplicationRecord
validate :cant_be_related_to_itself
validates :relationship_type, uniqueness: { scope: [:source_id, :target_id], message: :already_exists }, on: :create

before_create :destroy_same_suggested_item, if: proc { |r| r.is_confirmed? }
before_create :set_confirmed, :destroy_same_suggested_item, if: proc { |r| r.is_confirmed? }
after_create :move_to_same_project_as_main, prepend: true
after_create :point_targets_to_new_source, :update_counters, prepend: true
after_update :reset_counters, prepend: true
Expand Down
11 changes: 11 additions & 0 deletions test/models/bot/smooch_2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ def teardown
r.destroy
s = child.annotations.where(annotation_type: 'verification_status').last.load
assert_equal 'undetermined', s.status
u = create_user
create_team_user team: @team, user: u, role: 'admin'
with_current_user_and_team(u, @team) do
child2 = create_project_media project: @project
s2 = child2.annotations.where(annotation_type: 'verification_status').last.load
assert_equal 'undetermined', s2.status
create_tipline_request team_id: @project.team_id, associated: child2, language: 'en', smooch_message_id: random_string, smooch_data: { app_id: @app_id, authorId: random_string, language: 'en' }
r = create_relationship source_id: parent.id, target_id: child2.id, relationship_type: Relationship.confirmed_type, user: @bot
s2 = child2.annotations.where(annotation_type: 'verification_status').last.load
assert_equal 'verified', s2.status
end
end

test "should send message to user when status changes" do
Expand Down

0 comments on commit 4467039

Please sign in to comment.