diff options
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/asset_test.rb | 27 | ||||
| -rw-r--r-- | test/models/event_test.rb | 25 |
2 files changed, 52 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 | ||
| 79 | end | 106 | end |
diff --git a/test/models/event_test.rb b/test/models/event_test.rb index a5449a2a..49af8e38 100644 --- a/test/models/event_test.rb +++ b/test/models/event_test.rb | |||
| @@ -178,4 +178,29 @@ class EventTest < ActiveSupport::TestCase | |||
| 178 | assert event.save | 178 | assert event.save |
| 179 | assert_equal event.start_time, event.occurrences.first&.start_time | 179 | assert_equal event.start_time, event.occurrences.first&.start_time |
| 180 | end | 180 | end |
| 181 | |||
| 182 | test "editor_search matches across columns" do | ||
| 183 | match = Event.create!(:title => "Chaosradio Spezial", :location => "Zentrale") | ||
| 184 | other = Event.create!(:title => "Nothing distinctive") | ||
| 185 | |||
| 186 | assert_includes Event.editor_search("chaosradio"), match | ||
| 187 | assert_not_includes Event.editor_search("chaosradio"), other | ||
| 188 | assert_includes Event.editor_search("zentrale"), match, | ||
| 189 | "location should be searchable" | ||
| 190 | end | ||
| 191 | |||
| 192 | test "editor_search ANDs multiple words" do | ||
| 193 | Event.create!(:title => "Chaosradio Spezial") | ||
| 194 | |||
| 195 | assert_not_empty Event.editor_search("chaosradio spezial") | ||
| 196 | assert_empty Event.editor_search("chaosradio zzzznomatch") | ||
| 197 | end | ||
| 198 | |||
| 199 | test "editor_search finds an event by its tag" do | ||
| 200 | event = Event.create!(:title => "Nothing distinctive") | ||
| 201 | event.tag_list.add("open-day") | ||
| 202 | event.save! | ||
| 203 | |||
| 204 | assert_includes Event.editor_search("open-day"), event | ||
| 205 | end | ||
| 181 | end | 206 | end |
