+
+ assert_includes(manifest_text, 'foo')
+ assert_includes(manifest_text, 'foo(1)')
+
+ streams = manifest_text.split "\n"
+ streams.each do |stream|
+ if stream.start_with? './dir1'
+ # dir1 stream
+ assert_includes(stream, ':alice(1)')
+ assert_includes(stream, ':alice.txt')
+ assert_includes(stream, ':alice(1).txt')
+ assert_includes(stream, ':bob.txt')
+ assert_includes(stream, ':carol.txt')
+ elsif stream.start_with? './dir2'
+ # dir2 stream
+ assert_includes(stream, ':alice.txt')
+ assert_includes(stream, ':alice(1).txt')
+ elsif stream.start_with? '. '
+ # . stream
+ assert_includes(stream, ':foo')
+ assert_includes(stream, ':foo(1)')
+ end
+ end
+ end
+
+ test "combine collections with same filename in two different streams and expect no suffixes for filenames" do
+ post(:combine_selected_files_into_collection, params: {
+ selection: ['zzzzz-4zz18-znfnqtbbv4spc3w',
+ 'zzzzz-4zz18-foonbarfilesdir'],
+ format: "json"},
+ session: 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']
+
+ streams = manifest_text.split "\n"
+ assert_equal 2, streams.length
+ streams.each do |stream|
+ if stream.start_with? './dir1'
+ assert_includes(stream, 'foo')
+ elsif stream.start_with? '. '
+ assert_includes(stream, 'foo')
+ end
+ end
+ refute_includes(manifest_text, 'foo(1)')
+ end
+
+ test "combine foo files from two different collection streams and expect proper filename suffixes" do
+ post(:combine_selected_files_into_collection, params: {
+ selection: ['zzzzz-4zz18-znfnqtbbv4spc3w/foo',
+ 'zzzzz-4zz18-foonbarfilesdir/dir1/foo'],
+ format: "json"},
+ session: 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']
+
+ streams = manifest_text.split "\n"
+ assert_equal 1, streams.length, "Incorrect number of streams in #{manifest_text}"
+ assert_includes(manifest_text, 'foo')
+ assert_includes(manifest_text, 'foo(1)')
+ end
+
+ [
+ ['collections', 'user_agreement_in_anonymously_accessible_project'],
+ ['groups', 'anonymously_accessible_project'],
+ ['jobs', 'running_job_in_publicly_accessible_project'],
+ ['pipeline_instances', 'pipeline_in_publicly_accessible_project'],
+ ['pipeline_templates', 'pipeline_template_in_publicly_accessible_project'],
+ ].each do |dm, fixture|
+ test "access show method for public #{dm} and expect to see page" do
+ Rails.configuration.Users.AnonymousUserToken = api_fixture('api_client_authorizations')['anonymous']['api_token']
+ get(:show, params: {uuid: api_fixture(dm)[fixture]['uuid']})
+ assert_response :redirect
+ if dm == 'groups'
+ assert_includes @response.redirect_url, "projects/#{fixture['uuid']}"
+ else
+ assert_includes @response.redirect_url, "#{dm}/#{fixture['uuid']}"
+ end
+ end