Skip to content

Commit

Permalink
Merge branch 'develop' into fix/CV2-5808-search-escape-single-quote
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Dec 16, 2024
2 parents 6f3d2d3 + d08f344 commit 286f3e0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/project_media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def apply_rules_and_actions_on_update
self.team.apply_rules_and_actions(self, rule_ids)
end

def self.handle_fact_check_for_existing_claim(existing_pm,new_pm)
def self.handle_fact_check_for_existing_claim(existing_pm, new_pm)
if existing_pm.fact_check.blank?
existing_pm.append_fact_check_from(new_pm)
return existing_pm
Expand All @@ -440,6 +440,7 @@ def self.handle_fact_check_for_existing_claim(existing_pm,new_pm)
return new_pm
end
end
new_pm
end

def append_fact_check_from(new_pm)
Expand Down
5 changes: 5 additions & 0 deletions test/lib/check_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ def teardown
search = CheckSearch.new({ keyword: query }.to_json, nil, @team.id)
assert_equal "Something is going to happen on Foo's house", search.instance_variable_get('@options')['keyword']
end

test "should search for array field containing nil values" do
search = CheckSearch.new({ users: [1, nil] }.to_json, nil, @team.id)
assert_not_nil search.send(:doc_conditions)
end
end
5 changes: 5 additions & 0 deletions test/models/fact_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,9 @@ def setup
assert_nil pm.reload.fact_check_id
end
end

test "should be formatted as tipline search result" do
fc = create_fact_check
assert_kind_of TiplineSearchResult, fc.as_tipline_search_result
end
end
9 changes: 9 additions & 0 deletions test/models/project_media_7_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,13 @@ def setup
sleep 1
assert_equal [pm1.fact_check_id, pm2.fact_check_id, pm3.fact_check_id].sort, pm_i.get_similar_articles.map(&:id).sort
end

test "should not return null when handling fact-check for existing media" do
t = create_team
pm1 = create_project_media team: t
c = create_claim_description project_media: pm1
create_fact_check claim_description: c, language: 'en'
pm2 = ProjectMedia.new team: t, set_fact_check: { 'language' => 'en' }
assert_not_nil ProjectMedia.handle_fact_check_for_existing_claim(pm1, pm2)
end
end
7 changes: 7 additions & 0 deletions test/models/project_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,11 @@ def setup
p = create_project team: t
assert p.inactive
end

test "should get and set current project" do
p = create_project
assert_nil Project.current
Project.current = p
assert_equal p, Project.current
end
end
2 changes: 1 addition & 1 deletion test/workers/project_media_trash_worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

class ProjectMediaTrashWorkerTest < ActiveSupport::TestCase
def setup
super
require 'sidekiq/testing'
Sidekiq::Testing.inline!
Team.current = User.current = nil
end

test "should destroy trashed items" do
Expand Down

0 comments on commit 286f3e0

Please sign in to comment.