summaryrefslogtreecommitdiff
path: root/test/models/asset_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/models/asset_test.rb')
-rw-r--r--test/models/asset_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/models/asset_test.rb b/test/models/asset_test.rb
index 2677681b..be4be3b9 100644
--- a/test/models/asset_test.rb
+++ b/test/models/asset_test.rb
@@ -76,4 +76,31 @@ class AssetTest < ActiveSupport::TestCase
76 assert asset.valid?, asset.errors.full_messages.to_sentence 76 assert asset.valid?, asset.errors.full_messages.to_sentence
77 assert_equal "image/png", asset.upload_content_type 77 assert_equal "image/png", asset.upload_content_type
78 end 78 end
79
80 def build_asset(name:, creator: nil)
81 asset = Asset.new(:name => name, :creator => creator)
82 asset.upload = Rack::Test::UploadedFile.new(
83 file_fixture("test_document.pdf"), "application/pdf")
84 asset.save!
85 asset
86 end
87
88 test "editor_search matches across columns" do
89 pdf = build_asset(:name => "Offener Brief")
90 other = build_asset(:name => "Nothing distinctive", :creator => "Someone")
91
92 assert_includes Asset.editor_search("brief"), pdf
93 assert_not_includes Asset.editor_search("brief"), other
94 assert_includes Asset.editor_search("pdf"), pdf,
95 "upload_content_type should be searchable"
96 assert_includes Asset.editor_search("someone"), other,
97 "creator should be searchable"
98 end
99
100 test "editor_search ANDs multiple words" do
101 build_asset(:name => "Offener Brief")
102
103 assert_not_empty Asset.editor_search("offener brief")
104 assert_empty Asset.editor_search("offener zzzznomatch")
105 end
79end 106end