Merge branch 'master' into 5110-workbench-full-text-search
[arvados.git] / services / api / test / unit / collection_test.rb
index d066fe3173ec94a07dcd9d2938b516ce9205a7c7..59f9d3d41a52149e0d7f6a1532373df037b01a6d 100644 (file)
@@ -93,7 +93,10 @@ class CollectionTest < ActiveSupport::TestCase
     [
       ['foo', true],
       ['foo bar', false],                     # no collection matching both
+      ['foo&bar', false],                     # no collection matching both
+      ['foo|bar', true],                      # works only no spaces between the words
       ['Gnu public', true],                   # both prefixes found, though not consecutively
+      ['Gnu&public', true],                   # both prefixes found, though not consecutively
       ['file4', true],                        # prefix match
       ['file4.txt', true],                    # whole string match
       ['filex', false],                       # no such prefix
@@ -109,9 +112,19 @@ class CollectionTest < ActiveSupport::TestCase
       results = Collection.where("#{Collection.full_text_tsvector} @@ to_tsquery(?)",
                                  "#{search_filters}")
       if expect_results
-        assert_equal true, results.length>0, "No results found for '#{search_filter}'"
+        refute_empty results
       else
-        assert_equal 0, results.length, "Found #{results.length} results for '#{search_filter}'"
+        assert_empty results
+      end
+    end
+  end
+
+  [0, 2, 4, nil].each do |ask|
+    test "replication_desired reports #{ask or 2} if redundancy is #{ask}" do
+      act_as_user users(:active) do
+        c = collections(:collection_owned_by_active)
+        c.update_attributes redundancy: ask
+        assert_equal (ask or 2), c.replication_desired
       end
     end
   end