diff --git a/app/models/project_media.rb b/app/models/project_media.rb index e29adddb8..e1c18a7a8 100644 --- a/app/models/project_media.rb +++ b/app/models/project_media.rb @@ -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 @@ -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) diff --git a/test/lib/check_search_test.rb b/test/lib/check_search_test.rb index a4207ae9d..8a59c5bd2 100644 --- a/test/lib/check_search_test.rb +++ b/test/lib/check_search_test.rb @@ -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 diff --git a/test/models/fact_check_test.rb b/test/models/fact_check_test.rb index 88b8a70d0..5e5ad7413 100644 --- a/test/models/fact_check_test.rb +++ b/test/models/fact_check_test.rb @@ -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 diff --git a/test/models/project_media_7_test.rb b/test/models/project_media_7_test.rb index d83e68c18..9466ddadc 100644 --- a/test/models/project_media_7_test.rb +++ b/test/models/project_media_7_test.rb @@ -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 diff --git a/test/models/project_test.rb b/test/models/project_test.rb index e278d7ef5..15a4046ce 100644 --- a/test/models/project_test.rb +++ b/test/models/project_test.rb @@ -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 diff --git a/test/workers/project_media_trash_worker_test.rb b/test/workers/project_media_trash_worker_test.rb index 4b86da65b..0833eeefa 100644 --- a/test/workers/project_media_trash_worker_test.rb +++ b/test/workers/project_media_trash_worker_test.rb @@ -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