From d08f344b5e2655e28e0cde9d24203865754b2a88 Mon Sep 17 00:00:00 2001 From: Caio Almeida <117518+caiosba@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:20:24 -0300 Subject: [PATCH] Adding missing tests. (#2154) Adding missing tests in order to complete code coverage. Reference: CV2-5830. --- test/lib/check_search_test.rb | 5 +++++ test/models/fact_check_test.rb | 5 +++++ test/models/project_test.rb | 7 +++++++ test/workers/project_media_trash_worker_test.rb | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/lib/check_search_test.rb b/test/lib/check_search_test.rb index 9288ba3db3..327be12690 100644 --- a/test/lib/check_search_test.rb +++ b/test/lib/check_search_test.rb @@ -17,4 +17,9 @@ def teardown search = CheckSearch.new({ keyword: query }.to_json, nil, @team.id) assert_equal 'Something is going to happen on 04 11 reportedly', 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 88b8a70d0c..5e5ad74131 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_test.rb b/test/models/project_test.rb index e278d7ef50..15a4046ce3 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 4b86da65b9..0833eeefae 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