+ '7a6ef4c162a5c6413070a8bd0bffc818+150'],
+ format: "json"},
+ session_for(:active))
+
+ assert_response 302 # collection created and redirected to new collection page
+
+ assert_includes(response.headers['Location'], '/collections/')
+ new_collection_uuid = response.headers['Location'].split('/')[-1]
+
+ use_token :active
+ collection = Collection.select([:uuid, :manifest_text]).where(uuid: new_collection_uuid).first
+ manifest_text = collection['manifest_text']
+ assert_includes(manifest_text, "foo")
+ assert_includes(manifest_text, "bar")
+ assert_includes(manifest_text, "baz")
+ assert_includes(manifest_text, "0:0:file1 0:0:file2 0:0:file3")
+ assert_includes(manifest_text, "dir1/subdir")
+ assert_includes(manifest_text, "dir2")
+ end
+
+ test "combine files with repeated names into new collection" do
+ post(:combine_selected_files_into_collection, {
+ selection: ['zzzzz-4zz18-znfnqtbbv4spc3w/foo',
+ 'zzzzz-4zz18-00000nonamecoll/foo',
+ 'zzzzz-4zz18-abcd6fx123409f7/foo',
+ 'zzzzz-4zz18-ehbhgtheo8909or/bar',
+ 'zzzzz-4zz18-y9vne9npefyxh8g/baz',
+ '7a6ef4c162a5c6413070a8bd0bffc818+150'],
+ format: "json"},
+ session_for(:active))
+
+ assert_response 302 # collection created and redirected to new collection page
+
+ assert_includes(response.headers['Location'], '/collections/')
+ new_collection_uuid = response.headers['Location'].split('/')[-1]
+
+ use_token :active
+ collection = Collection.select([:uuid, :manifest_text]).where(uuid: new_collection_uuid).first
+ manifest_text = collection['manifest_text']
+ assert_includes(manifest_text, "foo(1)")
+ assert_includes(manifest_text, "foo(2)")
+ assert_includes(manifest_text, "bar")
+ assert_includes(manifest_text, "baz")
+ assert_includes(manifest_text, "0:0:file1 0:0:file2 0:0:file3")
+ assert_includes(manifest_text, "dir1/subdir")
+ assert_includes(manifest_text, "dir2")
+ end
+
+ test "combine collections with repeated filenames in almost similar directories and expect files with proper suffixes" do
+ post(:combine_selected_files_into_collection, {
+ selection: ['zzzzz-4zz18-duplicatenames1',
+ 'zzzzz-4zz18-duplicatenames2',
+ 'zzzzz-4zz18-znfnqtbbv4spc3w/foo',
+ 'zzzzz-4zz18-00000nonamecoll/foo',],