Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 21:08:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 21:08:10 +0300
commit5d75b2b9a9d11c20667895e6aa68ea4e76658c5d (patch)
tree2aa529b0a153c805f5f4ecb357321a4e4f4c59cb /spec/lib
parent6f2065c468b05658125b746169c56764a8ccddb1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb42
-rw-r--r--spec/lib/uploaded_file_spec.rb10
2 files changed, 52 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb
new file mode 100644
index 00000000000..968dfc1ea43
--- /dev/null
+++ b/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Database::PostgresqlAdapter::SchemaVersionsCopyMixin do
+ let(:schema_migration) { double('schem_migration', table_name: table_name, all_versions: versions) }
+ let(:versions) { %w(5 2 1000 200 4 93 2) }
+ let(:table_name) { "schema_migrations" }
+
+ let(:instance) do
+ Object.new.extend(described_class)
+ end
+
+ before do
+ allow(instance).to receive(:schema_migration).and_return(schema_migration)
+ allow(instance).to receive(:quote_table_name).with(table_name).and_return("\"#{table_name}\"")
+ end
+
+ subject { instance.dump_schema_information }
+
+ it 'uses COPY FROM STDIN' do
+ expect(subject.split("\n").first).to match(/COPY "schema_migrations" \(version\) FROM STDIN;/)
+ end
+
+ it 'contains a sorted list of versions by their numeric value' do
+ version_lines = subject.split("\n")[1..-2].map(&:to_i)
+
+ expect(version_lines).to eq(versions.map(&:to_i).sort)
+ end
+
+ it 'contains a end-of-data marker' do
+ expect(subject).to end_with("\\.\n")
+ end
+
+ context 'with non-Integer versions' do
+ let(:versions) { %w(5 2 4 abc) }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(/invalid value for Integer/)
+ end
+ end
+end
diff --git a/spec/lib/uploaded_file_spec.rb b/spec/lib/uploaded_file_spec.rb
index 2bbbd67b13c..25536c07dd9 100644
--- a/spec/lib/uploaded_file_spec.rb
+++ b/spec/lib/uploaded_file_spec.rb
@@ -59,6 +59,16 @@ describe UploadedFile do
expect(subject.sha256).to eq('sha256')
expect(subject.remote_id).to eq('remote_id')
end
+
+ it 'handles a blank path' do
+ params['file.path'] = ''
+
+ # Not a real file, so can't determine size itself
+ params['file.size'] = 1.byte
+
+ expect { described_class.from_params(params, :file, upload_path) }
+ .not_to raise_error
+ end
end
end