dump 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/check.yml +102 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.rubocop.yml +24 -1
- data/.rubocop_todo.yml +27 -29
- data/Appraisals +59 -21
- data/Gemfile +6 -4
- data/LICENSE.txt +1 -1
- data/README.markdown +6 -6
- data/dump.gemspec +7 -4
- data/lib/dump/capistrano/v2.rb +21 -23
- data/lib/dump/continious_timeout.rb +4 -6
- data/lib/dump/env/filter.rb +1 -0
- data/lib/dump/env.rb +7 -7
- data/lib/dump/reader.rb +3 -5
- data/lib/dump/snapshot.rb +24 -31
- data/lib/dump/table_manipulation.rb +7 -7
- data/lib/dump/writer.rb +40 -27
- data/lib/tasks/assets.rake +1 -1
- data/lib/tasks/dump.rake +5 -5
- data/spec/.gitignore +2 -0
- data/spec/cycle_spec.rb +14 -22
- data/spec/dummy-2.3/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-3.1/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-3.2/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-4.0/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-4.1/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-4.2/config/initializers/abstract_mysql2_adapter.rb +4 -0
- data/spec/dummy-6.0/.gitignore +28 -0
- data/spec/dummy-6.0/config/application.rb +35 -0
- data/spec/dummy-6.0/config/boot.rb +5 -0
- data/spec/dummy-6.0/config/cable.yml +10 -0
- data/spec/{dummy-3.0 → dummy-6.0}/config/database.yml +13 -10
- data/spec/dummy-6.0/config/environment.rb +5 -0
- data/spec/dummy-6.0/config/environments/development.rb +55 -0
- data/spec/dummy-6.0/config/environments/production.rb +106 -0
- data/spec/dummy-6.0/config/environments/test.rb +48 -0
- data/spec/dummy-6.0/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy-6.0/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy-6.0/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy-6.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-6.0/config/initializers/inflections.rb +16 -0
- data/spec/{dummy-3.0 → dummy-6.0}/config/initializers/mime_types.rb +0 -1
- data/spec/dummy-6.0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-6.0/config/locales/en.yml +33 -0
- data/spec/dummy-6.0/config/puma.rb +38 -0
- data/spec/dummy-6.0/config/routes.rb +3 -0
- data/spec/dummy-6.0/config/spring.rb +6 -0
- data/spec/dummy-6.0/config/storage.yml +34 -0
- data/spec/dummy-6.0/config.ru +5 -0
- data/spec/dummy-6.0/db/seeds.rb +7 -0
- data/spec/dummy-6.0/log/.keep +0 -0
- data/spec/dummy-6.0/storage/.keep +0 -0
- data/spec/dummy-6.1/.gitattributes +8 -0
- data/spec/dummy-6.1/.gitignore +33 -0
- data/spec/dummy-6.1/config/application.rb +38 -0
- data/spec/dummy-6.1/config/boot.rb +5 -0
- data/spec/dummy-6.1/config/cable.yml +10 -0
- data/spec/dummy-6.1/config/database.yml +25 -0
- data/spec/dummy-6.1/config/environment.rb +5 -0
- data/spec/dummy-6.1/config/environments/development.rb +69 -0
- data/spec/dummy-6.1/config/environments/production.rb +114 -0
- data/spec/dummy-6.1/config/environments/test.rb +60 -0
- data/spec/dummy-6.1/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy-6.1/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy-6.1/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy-6.1/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy-6.1/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy-6.1/config/initializers/inflections.rb +16 -0
- data/spec/dummy-6.1/config/initializers/mime_types.rb +4 -0
- data/spec/dummy-6.1/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy-6.1/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-6.1/config/locales/en.yml +33 -0
- data/spec/dummy-6.1/config/puma.rb +43 -0
- data/spec/dummy-6.1/config/routes.rb +3 -0
- data/spec/dummy-6.1/config/spring.rb +6 -0
- data/spec/dummy-6.1/config/storage.yml +34 -0
- data/spec/dummy-6.1/config.ru +6 -0
- data/spec/dummy-6.1/db/seeds.rb +7 -0
- data/spec/dummy-6.1/log/.keep +0 -0
- data/spec/dummy-6.1/storage/.keep +0 -0
- data/spec/dummy-7.0/.gitattributes +7 -0
- data/spec/dummy-7.0/.gitignore +35 -0
- data/spec/dummy-7.0/config/application.rb +37 -0
- data/spec/dummy-7.0/config/boot.rb +3 -0
- data/spec/dummy-7.0/config/cable.yml +10 -0
- data/spec/dummy-7.0/config/database.yml +25 -0
- data/spec/dummy-7.0/config/environment.rb +5 -0
- data/spec/dummy-7.0/config/environments/development.rb +70 -0
- data/spec/dummy-7.0/config/environments/production.rb +93 -0
- data/spec/dummy-7.0/config/environments/test.rb +60 -0
- data/spec/dummy-7.0/config/initializers/assets.rb +12 -0
- data/spec/dummy-7.0/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy-7.0/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy-7.0/config/initializers/inflections.rb +16 -0
- data/spec/dummy-7.0/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy-7.0/config/locales/en.yml +33 -0
- data/spec/dummy-7.0/config/puma.rb +43 -0
- data/spec/dummy-7.0/config/routes.rb +6 -0
- data/spec/dummy-7.0/config/storage.yml +34 -0
- data/spec/dummy-7.0/config.ru +6 -0
- data/spec/dummy-7.0/db/seeds.rb +7 -0
- data/spec/dummy-7.0/log/.keep +0 -0
- data/spec/dummy-7.0/storage/.keep +0 -0
- data/spec/dummy-7.1/.gitattributes +9 -0
- data/spec/dummy-7.1/.gitignore +35 -0
- data/spec/dummy-7.1/Dockerfile +58 -0
- data/spec/dummy-7.1/config/application.rb +42 -0
- data/spec/dummy-7.1/config/boot.rb +3 -0
- data/spec/dummy-7.1/config/cable.yml +10 -0
- data/spec/dummy-7.1/config/database.yml +25 -0
- data/spec/dummy-7.1/config/environment.rb +5 -0
- data/spec/dummy-7.1/config/environments/development.rb +76 -0
- data/spec/dummy-7.1/config/environments/production.rb +97 -0
- data/spec/dummy-7.1/config/environments/test.rb +64 -0
- data/spec/dummy-7.1/config/initializers/assets.rb +12 -0
- data/spec/dummy-7.1/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy-7.1/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy-7.1/config/initializers/inflections.rb +16 -0
- data/spec/dummy-7.1/config/initializers/permissions_policy.rb +13 -0
- data/spec/dummy-7.1/config/locales/en.yml +31 -0
- data/spec/dummy-7.1/config/puma.rb +44 -0
- data/spec/dummy-7.1/config/routes.rb +10 -0
- data/spec/dummy-7.1/config/storage.yml +34 -0
- data/spec/dummy-7.1/config.ru +6 -0
- data/spec/dummy-7.1/db/seeds.rb +9 -0
- data/spec/dummy-7.1/log/.keep +0 -0
- data/spec/dummy-7.1/storage/.keep +0 -0
- data/spec/dummy-7.2/.gitattributes +9 -0
- data/spec/dummy-7.2/.gitignore +35 -0
- data/spec/dummy-7.2/.rubocop.yml +8 -0
- data/spec/dummy-7.2/Dockerfile +65 -0
- data/spec/dummy-7.2/config/application.rb +42 -0
- data/spec/dummy-7.2/config/boot.rb +3 -0
- data/spec/dummy-7.2/config/cable.yml +10 -0
- data/spec/dummy-7.2/config/database.yml +32 -0
- data/spec/dummy-7.2/config/environment.rb +5 -0
- data/spec/dummy-7.2/config/environments/development.rb +81 -0
- data/spec/dummy-7.2/config/environments/production.rb +105 -0
- data/spec/dummy-7.2/config/environments/test.rb +67 -0
- data/spec/dummy-7.2/config/initializers/assets.rb +12 -0
- data/spec/dummy-7.2/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy-7.2/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy-7.2/config/initializers/inflections.rb +16 -0
- data/spec/dummy-7.2/config/initializers/permissions_policy.rb +13 -0
- data/spec/dummy-7.2/config/locales/en.yml +31 -0
- data/spec/dummy-7.2/config/puma.rb +34 -0
- data/spec/dummy-7.2/config/routes.rb +14 -0
- data/spec/dummy-7.2/config/storage.yml +34 -0
- data/spec/dummy-7.2/config.ru +6 -0
- data/spec/dummy-7.2/db/seeds.rb +9 -0
- data/spec/dummy-7.2/log/.keep +0 -0
- data/spec/dummy-7.2/storage/.keep +0 -0
- data/spec/dummy-8.0/.gitattributes +9 -0
- data/spec/dummy-8.0/.gitignore +34 -0
- data/spec/dummy-8.0/.rubocop.yml +8 -0
- data/spec/dummy-8.0/Dockerfile +68 -0
- data/spec/dummy-8.0/config/application.rb +42 -0
- data/spec/dummy-8.0/config/boot.rb +3 -0
- data/spec/dummy-8.0/config/cable.yml +10 -0
- data/spec/dummy-8.0/config/database.yml +41 -0
- data/spec/dummy-8.0/config/environment.rb +5 -0
- data/spec/dummy-8.0/config/environments/development.rb +72 -0
- data/spec/dummy-8.0/config/environments/production.rb +89 -0
- data/spec/dummy-8.0/config/environments/test.rb +53 -0
- data/spec/dummy-8.0/config/initializers/assets.rb +7 -0
- data/spec/dummy-8.0/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy-8.0/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy-8.0/config/initializers/inflections.rb +16 -0
- data/spec/dummy-8.0/config/locales/en.yml +31 -0
- data/spec/dummy-8.0/config/puma.rb +41 -0
- data/spec/dummy-8.0/config/routes.rb +14 -0
- data/spec/dummy-8.0/config/storage.yml +34 -0
- data/spec/dummy-8.0/config.ru +6 -0
- data/spec/dummy-8.0/db/seeds.rb +9 -0
- data/spec/dummy-8.0/log/.keep +0 -0
- data/spec/dummy-8.0/storage/.keep +0 -0
- data/spec/dummy-8.1/.gitattributes +9 -0
- data/spec/dummy-8.1/.gitignore +35 -0
- data/spec/dummy-8.1/.rubocop.yml +8 -0
- data/spec/dummy-8.1/Dockerfile +71 -0
- data/spec/dummy-8.1/config/application.rb +42 -0
- data/spec/dummy-8.1/config/boot.rb +3 -0
- data/spec/dummy-8.1/config/bundler-audit.yml +5 -0
- data/spec/dummy-8.1/config/cable.yml +10 -0
- data/spec/dummy-8.1/config/ci.rb +19 -0
- data/spec/dummy-8.1/config/database.yml +40 -0
- data/spec/dummy-8.1/config/environment.rb +5 -0
- data/spec/dummy-8.1/config/environments/development.rb +78 -0
- data/spec/dummy-8.1/config/environments/production.rb +89 -0
- data/spec/dummy-8.1/config/environments/test.rb +53 -0
- data/spec/dummy-8.1/config/initializers/assets.rb +7 -0
- data/spec/dummy-8.1/config/initializers/content_security_policy.rb +29 -0
- data/spec/dummy-8.1/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy-8.1/config/initializers/inflections.rb +16 -0
- data/spec/dummy-8.1/config/locales/en.yml +31 -0
- data/spec/dummy-8.1/config/puma.rb +42 -0
- data/spec/dummy-8.1/config/routes.rb +14 -0
- data/spec/dummy-8.1/config/storage.yml +27 -0
- data/spec/dummy-8.1/config.ru +6 -0
- data/spec/dummy-8.1/db/seeds.rb +9 -0
- data/spec/dummy-8.1/log/.keep +0 -0
- data/spec/dummy-8.1/storage/.keep +0 -0
- data/spec/dummy_rails_app.rb +1 -1
- data/spec/dump/env_spec.rb +8 -23
- data/spec/dump/reader_spec.rb +12 -14
- data/spec/dump/snapshot_spec.rb +9 -13
- data/spec/dump/table_manipulation_spec.rb +3 -3
- data/spec/dump/writer_spec.rb +7 -4
- data/spec/dump_spec.rb +5 -5
- data/spec/recipes/dump_spec.rb +40 -38
- data/spec/tasks/assets_spec.rb +3 -3
- metadata +395 -50
- data/.travis.database.yml +0 -14
- data/.travis.yml +0 -34
- data/.travis_check_rubies.yml +0 -1
- data/spec/dummy-3.0/.gitignore +0 -4
- data/spec/dummy-3.0/config/application.rb +0 -42
- data/spec/dummy-3.0/config/boot.rb +0 -6
- data/spec/dummy-3.0/config/environment.rb +0 -5
- data/spec/dummy-3.0/config/environments/development.rb +0 -26
- data/spec/dummy-3.0/config/environments/production.rb +0 -49
- data/spec/dummy-3.0/config/environments/test.rb +0 -35
- data/spec/dummy-3.0/config/initializers/inflections.rb +0 -10
- data/spec/dummy-3.0/config/initializers/secret_token.rb +0 -7
- data/spec/dummy-3.0/config/initializers/session_store.rb +0 -8
- data/spec/dummy-3.0/config/locales/en.yml +0 -5
- data/spec/dummy-3.0/config/routes.rb +0 -58
- data/spec/dummy-3.0/config.ru +0 -4
- data/spec/dummy-3.0/db/seeds.rb +0 -7
- /data/spec/{dummy-3.0 → dummy-6.0}/config/initializers/backtrace_silencers.rb +0 -0
data/spec/dump/snapshot_spec.rb
CHANGED
|
@@ -30,9 +30,7 @@ describe Dump::Snapshot do
|
|
|
30
30
|
|
|
31
31
|
@file = double('file')
|
|
32
32
|
expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(nil)
|
|
33
|
-
expect(
|
|
34
|
-
expect(@file).to receive(:close)
|
|
35
|
-
expect(File).to receive(:open).and_return(@file)
|
|
33
|
+
expect(File).to receive(:open).and_yield(@file)
|
|
36
34
|
|
|
37
35
|
described_class.new('hello').lock do
|
|
38
36
|
@yield_receiver.fire
|
|
@@ -44,9 +42,7 @@ describe Dump::Snapshot do
|
|
|
44
42
|
|
|
45
43
|
@file = double('file')
|
|
46
44
|
expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(true)
|
|
47
|
-
expect(
|
|
48
|
-
expect(@file).to receive(:close)
|
|
49
|
-
expect(File).to receive(:open).and_return(@file)
|
|
45
|
+
expect(File).to receive(:open).and_yield(@file)
|
|
50
46
|
|
|
51
47
|
described_class.new('hello').lock do
|
|
52
48
|
@yield_receiver.fire
|
|
@@ -125,7 +121,7 @@ describe Dump::Snapshot do
|
|
|
125
121
|
# 0 1 2 3 4 5 6 7 8 9 10 11 12 131415 16
|
|
126
122
|
dumps_tags = [''] + %w[a a,d a,d,o a,d,s a,d,s,o a,o a,s a,s,o d d,o d,s d,s,o o s s,o z]
|
|
127
123
|
paths = dumps_tags.each_with_index.map do |dump_tags, i|
|
|
128
|
-
path = dump_path("196504140659#{
|
|
124
|
+
path = dump_path("196504140659#{i + 10}@#{dump_tags}.tgz")
|
|
129
125
|
expect(File).to receive(:file?).with(path).at_least(1).and_return(true)
|
|
130
126
|
path
|
|
131
127
|
end
|
|
@@ -264,18 +260,18 @@ describe Dump::Snapshot do
|
|
|
264
260
|
|
|
265
261
|
describe 'get_filter_tags' do
|
|
266
262
|
it 'splits string and returns uniq non blank sorted tags' do
|
|
267
|
-
expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq(:
|
|
268
|
-
expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq(:
|
|
269
|
-
expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq(:
|
|
270
|
-
expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq(:
|
|
271
|
-
expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq(:
|
|
263
|
+
expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
|
|
264
|
+
expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
|
|
265
|
+
expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
|
|
266
|
+
expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq(:any => %w[a].to_set, :all => %w[b].to_set, :none => [].to_set)
|
|
267
|
+
expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq(:any => %w[a].to_set, :all => %w[b].to_set, :none => %w[d].to_set)
|
|
272
268
|
expect{ described_class.new('').send(:get_filter_tags, 'a,+a') }.not_to raise_error
|
|
273
269
|
expect{ described_class.new('').send(:get_filter_tags, 'a,-a') }.to raise_error ArgumentError, /clashes/
|
|
274
270
|
expect{ described_class.new('').send(:get_filter_tags, '+a,-a') }.to raise_error ArgumentError, /clashes/
|
|
275
271
|
end
|
|
276
272
|
|
|
277
273
|
it 'accepts non string' do
|
|
278
|
-
expect(described_class.new('').send(:get_filter_tags, nil)).to eq(:
|
|
274
|
+
expect(described_class.new('').send(:get_filter_tags, nil)).to eq(:any => Set.new, :all => Set.new, :none => Set.new)
|
|
279
275
|
end
|
|
280
276
|
end
|
|
281
277
|
|
|
@@ -141,8 +141,8 @@ describe Dump::TableManipulation do
|
|
|
141
141
|
describe 'table_chunk_size' do
|
|
142
142
|
it 'returns chunk_size based on estimated average for row size' do
|
|
143
143
|
expect(self).to receive(:table_columns).with('first').and_return(
|
|
144
|
-
[double(:column, :type => :integer, :limit => nil)] * 3 +
|
|
145
|
-
[double(:column, :type => :string, :limit => nil)] * 3 +
|
|
144
|
+
([double(:column, :type => :integer, :limit => nil)] * 3) +
|
|
145
|
+
([double(:column, :type => :string, :limit => nil)] * 3) +
|
|
146
146
|
[double(:column, :type => :text, :limit => nil)]
|
|
147
147
|
)
|
|
148
148
|
expect(table_chunk_size('first')).to satisfy{ |n|
|
|
@@ -228,7 +228,7 @@ describe Dump::TableManipulation do
|
|
|
228
228
|
|
|
229
229
|
expect(self).to receive(:select_all_by_sql).with(sql % '>= 0').and_return(@rows[0, 100])
|
|
230
230
|
5.times do |i|
|
|
231
|
-
last_primary_key =
|
|
231
|
+
last_primary_key = (i * 100) + 100
|
|
232
232
|
expect(self).to receive(:select_all_by_sql).with(sql % "> #{last_primary_key}").and_return(@rows[last_primary_key, 100])
|
|
233
233
|
end
|
|
234
234
|
|
data/spec/dump/writer_spec.rb
CHANGED
|
@@ -30,16 +30,19 @@ describe Writer do
|
|
|
30
30
|
|
|
31
31
|
describe 'open' do
|
|
32
32
|
it 'creates dir for dump' do
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
@gzip = double('gzip', :mtime= => nil)
|
|
34
|
+
allow(Zlib::GzipWriter).to receive(:open).and_return(@gzip)
|
|
35
|
+
allow(Dir).to receive(:mkdir).with('/abc')
|
|
36
|
+
allow(Dir).to receive(:mkdir).with('/abc/def')
|
|
37
|
+
allow(Dir).to receive(:mkdir).with('/abc/def/ghi')
|
|
35
38
|
described_class.new('/abc/def/ghi/123.tgz').open
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
it 'sets stream to gzipped tar writer' do
|
|
39
|
-
allow(
|
|
42
|
+
allow(Dir).to receive(:mkdir)
|
|
40
43
|
@gzip = double('gzip')
|
|
41
44
|
@stream = double('stream')
|
|
42
|
-
expect(Zlib::GzipWriter).to receive(:open).with(Pathname('123.tgz')).
|
|
45
|
+
expect(Zlib::GzipWriter).to receive(:open).with(Pathname('123.tgz')).and_return(@gzip)
|
|
43
46
|
expect(Archive::Tar::Minitar::Output).to receive(:open).with(@gzip).and_yield(@stream)
|
|
44
47
|
expect(@gzip).to receive(:mtime=).with(Time.utc(2000))
|
|
45
48
|
|
data/spec/dump_spec.rb
CHANGED
|
@@ -11,7 +11,7 @@ describe Dump do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it 'calls Snapshot.list with options if called with version' do
|
|
14
|
-
expect(Dump::Snapshot).to receive(:list).with(:like => '123').and_return([])
|
|
14
|
+
expect(Dump::Snapshot).to receive(:list).with({:like => '123'}).and_return([])
|
|
15
15
|
described_class.versions(:like => '123')
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -205,7 +205,7 @@ describe Dump do
|
|
|
205
205
|
describe 'with version' do
|
|
206
206
|
it 'calls Snapshot.list with options' do
|
|
207
207
|
allow(Dump::Snapshot).to receive(:list)
|
|
208
|
-
expect(Dump::Snapshot).to receive(:list).with(:like => '213').and_return([])
|
|
208
|
+
expect(Dump::Snapshot).to receive(:list).with({:like => '213'}).and_return([])
|
|
209
209
|
grab_output do
|
|
210
210
|
described_class.restore(:like => '213')
|
|
211
211
|
end
|
|
@@ -249,14 +249,14 @@ describe Dump do
|
|
|
249
249
|
|
|
250
250
|
describe 'cleanup' do
|
|
251
251
|
it 'calls ask for all files in dump dir and for dumps' do
|
|
252
|
-
expect(Dump::Snapshot).to receive(:list).with(:all => true).and_return([])
|
|
252
|
+
expect(Dump::Snapshot).to receive(:list).with({:all => true}).and_return([])
|
|
253
253
|
expect(Dump::Snapshot).to receive(:list).with({}).and_return([])
|
|
254
254
|
described_class.cleanup
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
it 'calls Snapshot.list with options if called with version and tags' do
|
|
258
|
-
expect(Dump::Snapshot).to receive(:list).with(:like => '123', :tags => 'a,b,c', :all => true).and_return([])
|
|
259
|
-
expect(Dump::Snapshot).to receive(:list).with(:like => '123', :tags => 'a,b,c').and_return([])
|
|
258
|
+
expect(Dump::Snapshot).to receive(:list).with({:like => '123', :tags => 'a,b,c', :all => true}).and_return([])
|
|
259
|
+
expect(Dump::Snapshot).to receive(:list).with({:like => '123', :tags => 'a,b,c'}).and_return([])
|
|
260
260
|
described_class.cleanup(:like => '123', :tags => 'a,b,c')
|
|
261
261
|
end
|
|
262
262
|
|
data/spec/recipes/dump_spec.rb
CHANGED
|
@@ -5,6 +5,8 @@ require 'dump'
|
|
|
5
5
|
require 'capistrano'
|
|
6
6
|
|
|
7
7
|
describe 'cap dump' do
|
|
8
|
+
plus = '+'.shellescape
|
|
9
|
+
|
|
8
10
|
before do
|
|
9
11
|
@cap = Capistrano::Configuration.new
|
|
10
12
|
Capistrano::Configuration.instance = @cap
|
|
@@ -253,14 +255,14 @@ describe 'cap dump' do
|
|
|
253
255
|
|
|
254
256
|
describe 'versions' do
|
|
255
257
|
it 'calls remote rake task' do
|
|
256
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY
|
|
258
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
|
257
259
|
@cap.find_and_execute_task('dump:remote:versions')
|
|
258
260
|
end
|
|
259
261
|
|
|
260
262
|
test_passing_environment_variables(:remote, :versions, {
|
|
261
|
-
:like =>
|
|
262
|
-
:tags =>
|
|
263
|
-
:summary =>
|
|
263
|
+
:like => "rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true",
|
|
264
|
+
:tags => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true TAGS\\=some\\ data",
|
|
265
|
+
:summary => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true SUMMARY\\=some\\ data",
|
|
264
266
|
})
|
|
265
267
|
|
|
266
268
|
it 'prints result of rake task' do
|
|
@@ -272,21 +274,21 @@ describe 'cap dump' do
|
|
|
272
274
|
|
|
273
275
|
it 'uses custom rake binary' do
|
|
274
276
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
|
275
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY
|
|
277
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
|
276
278
|
@cap.find_and_execute_task('dump:remote:versions')
|
|
277
279
|
end
|
|
278
280
|
end
|
|
279
281
|
|
|
280
282
|
describe 'cleanup' do
|
|
281
283
|
it 'calls remote rake task' do
|
|
282
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY
|
|
284
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
|
|
283
285
|
@cap.find_and_execute_task('dump:remote:cleanup')
|
|
284
286
|
end
|
|
285
287
|
|
|
286
288
|
test_passing_environment_variables(:remote, :cleanup, {
|
|
287
|
-
:like =>
|
|
288
|
-
:tags =>
|
|
289
|
-
:leave =>
|
|
289
|
+
:like => "rake -s dump:cleanup LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
|
|
290
|
+
:tags => "rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
|
|
291
|
+
:leave => "rake -s dump:cleanup LEAVE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
|
|
290
292
|
})
|
|
291
293
|
|
|
292
294
|
it 'prints result of rake task' do
|
|
@@ -298,28 +300,28 @@ describe 'cap dump' do
|
|
|
298
300
|
|
|
299
301
|
it 'uses custom rake binary' do
|
|
300
302
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
|
301
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY
|
|
303
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
|
|
302
304
|
@cap.find_and_execute_task('dump:remote:cleanup')
|
|
303
305
|
end
|
|
304
306
|
end
|
|
305
307
|
|
|
306
308
|
describe 'create' do
|
|
307
309
|
it 'raises if dump creation fails' do
|
|
308
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY
|
|
310
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('')
|
|
309
311
|
expect do
|
|
310
312
|
@cap.find_and_execute_task('dump:remote:create')
|
|
311
313
|
end.to raise_error('Failed creating dump')
|
|
312
314
|
end
|
|
313
315
|
|
|
314
316
|
it 'calls remote rake task with default rails_env and tag remote' do
|
|
315
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY
|
|
317
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
|
316
318
|
grab_output do
|
|
317
319
|
@cap.find_and_execute_task('dump:remote:create')
|
|
318
320
|
end
|
|
319
321
|
end
|
|
320
322
|
|
|
321
323
|
it 'calls remote rake task with default rails_env and additional tag remote' do
|
|
322
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY
|
|
324
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote,photos").and_return('123.tgz')
|
|
323
325
|
grab_output do
|
|
324
326
|
Dump::Env.with_env :tags => 'photos' do
|
|
325
327
|
@cap.find_and_execute_task('dump:remote:create')
|
|
@@ -329,17 +331,17 @@ describe 'cap dump' do
|
|
|
329
331
|
|
|
330
332
|
it 'calls remote rake task with fetched rails_env and default DESC remote' do
|
|
331
333
|
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
|
332
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY
|
|
334
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=dev TAGS\\=remote").and_return('123.tgz')
|
|
333
335
|
grab_output do
|
|
334
336
|
@cap.find_and_execute_task('dump:remote:create')
|
|
335
337
|
end
|
|
336
338
|
end
|
|
337
339
|
|
|
338
340
|
test_passing_environment_variables(:remote, :create, {
|
|
339
|
-
:desc =>
|
|
340
|
-
:tags =>
|
|
341
|
-
:assets =>
|
|
342
|
-
:tables =>
|
|
341
|
+
:desc => "rake -s dump:create DESC\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote",
|
|
342
|
+
:tags => "rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote,some\\ data",
|
|
343
|
+
:assets => "rake -s dump:create ASSETS\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote",
|
|
344
|
+
:tables => "rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TABLES\\=some\\ data TAGS\\=remote",
|
|
343
345
|
}, :return_value => '123.tgz')
|
|
344
346
|
|
|
345
347
|
it 'prints result of rake task' do
|
|
@@ -358,7 +360,7 @@ describe 'cap dump' do
|
|
|
358
360
|
|
|
359
361
|
it 'uses custom rake binary' do
|
|
360
362
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
|
361
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY
|
|
363
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
|
362
364
|
grab_output do
|
|
363
365
|
@cap.find_and_execute_task('dump:remote:create')
|
|
364
366
|
end
|
|
@@ -367,40 +369,40 @@ describe 'cap dump' do
|
|
|
367
369
|
|
|
368
370
|
describe 'restore' do
|
|
369
371
|
it 'calls remote rake task with default rails_env' do
|
|
370
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY
|
|
372
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production")
|
|
371
373
|
@cap.find_and_execute_task('dump:remote:restore')
|
|
372
374
|
end
|
|
373
375
|
|
|
374
376
|
it 'calls remote rake task with fetched rails_env' do
|
|
375
377
|
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
|
376
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY
|
|
378
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=dev")
|
|
377
379
|
@cap.find_and_execute_task('dump:remote:restore')
|
|
378
380
|
end
|
|
379
381
|
|
|
380
382
|
test_passing_environment_variables(:remote, :restore, {
|
|
381
|
-
:like =>
|
|
382
|
-
:tags =>
|
|
383
|
-
:migrate_down =>
|
|
384
|
-
:restore_schema =>
|
|
385
|
-
:restore_tables =>
|
|
386
|
-
:restore_assets =>
|
|
383
|
+
:like => "rake -s dump:restore LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
|
|
384
|
+
:tags => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
|
|
385
|
+
:migrate_down => "rake -s dump:restore MIGRATE_DOWN\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
|
|
386
|
+
:restore_schema => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_SCHEMA\\=some\\ data",
|
|
387
|
+
:restore_tables => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_TABLES\\=some\\ data",
|
|
388
|
+
:restore_assets => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_ASSETS\\=some\\ data",
|
|
387
389
|
})
|
|
388
390
|
|
|
389
391
|
it 'uses custom rake binary' do
|
|
390
392
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
|
391
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY
|
|
393
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production")
|
|
392
394
|
@cap.find_and_execute_task('dump:remote:restore')
|
|
393
395
|
end
|
|
394
396
|
end
|
|
395
397
|
|
|
396
398
|
describe 'download' do
|
|
397
399
|
it 'runs rake versions to get avaliable versions' do
|
|
398
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY
|
|
400
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
|
|
399
401
|
@cap.find_and_execute_task('dump:remote:download')
|
|
400
402
|
end
|
|
401
403
|
|
|
402
404
|
it 'blocks sending summary to versions' do
|
|
403
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY
|
|
405
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
|
|
404
406
|
Dump::Env::DICTIONARY[:summary].each do |name|
|
|
405
407
|
Dump::Env.with_env name => 'true' do
|
|
406
408
|
@cap.find_and_execute_task('dump:remote:download')
|
|
@@ -409,10 +411,10 @@ describe 'cap dump' do
|
|
|
409
411
|
end
|
|
410
412
|
|
|
411
413
|
test_passing_environment_variables(:remote, :transfer, {
|
|
412
|
-
:like =>
|
|
413
|
-
:tags =>
|
|
414
|
-
:summary =>
|
|
415
|
-
:transfer_via =>
|
|
414
|
+
:like => "rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
|
|
415
|
+
:tags => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
|
|
416
|
+
:summary => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production", # block sending summary to versions
|
|
417
|
+
:transfer_via => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production", # tranfer_via is used internally
|
|
416
418
|
}, :cap_task => 'dump:remote:download')
|
|
417
419
|
|
|
418
420
|
it 'does not download anything if there are no versions avaliable' do
|
|
@@ -424,27 +426,27 @@ describe 'cap dump' do
|
|
|
424
426
|
it 'transfers latest version dump' do
|
|
425
427
|
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
|
426
428
|
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
|
|
427
|
-
allow(
|
|
429
|
+
allow(Dir).to receive(:mkdir)
|
|
428
430
|
@cap.find_and_execute_task('dump:remote:download')
|
|
429
431
|
end
|
|
430
432
|
|
|
431
433
|
it 'handles extra spaces around file names' do
|
|
432
434
|
allow(@cap.dump).to receive(:run_remote).and_return("\r\n\r\n\r 100.tgz \r\n\r\n\r 200.tgz \r\n\r\n\r 300.tgz \r\n\r\n\r ")
|
|
433
435
|
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
|
|
434
|
-
allow(
|
|
436
|
+
allow(Dir).to receive(:mkdir)
|
|
435
437
|
@cap.find_and_execute_task('dump:remote:download')
|
|
436
438
|
end
|
|
437
439
|
|
|
438
440
|
it 'creates local dump dir' do
|
|
439
441
|
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
|
440
442
|
allow(@cap.dump).to receive(:do_transfer)
|
|
441
|
-
|
|
443
|
+
allow(Dir).to receive(:mkdir).with('dump')
|
|
442
444
|
@cap.find_and_execute_task('dump:remote:download')
|
|
443
445
|
end
|
|
444
446
|
|
|
445
447
|
it 'runs rake versions use custom rake binary' do
|
|
446
448
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
|
447
|
-
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY
|
|
449
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
|
|
448
450
|
@cap.find_and_execute_task('dump:remote:download')
|
|
449
451
|
end
|
|
450
452
|
end
|
data/spec/tasks/assets_spec.rb
CHANGED
|
@@ -19,7 +19,7 @@ describe 'rake assets' do
|
|
|
19
19
|
end_src
|
|
20
20
|
expect(File).to receive(:readlines).with(File.join(Dump.rails_root, 'config/assets')).and_return(StringIO.new(data).readlines)
|
|
21
21
|
@rake['assets'].invoke
|
|
22
|
-
expect(ENV
|
|
22
|
+
expect(ENV.fetch('ASSETS', nil)).to eq('public/images/a:public/images/b')
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it 'ignores comments in config/assets' do
|
|
@@ -31,7 +31,7 @@ describe 'rake assets' do
|
|
|
31
31
|
end_src
|
|
32
32
|
allow(File).to receive(:readlines).and_return(StringIO.new(data).readlines)
|
|
33
33
|
@rake['assets'].invoke
|
|
34
|
-
expect(ENV
|
|
34
|
+
expect(ENV.fetch('ASSETS', nil)).to eq('public/images/a:public/images/b')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "does not change ENV['ASSETS'] if it already exists" do
|
|
@@ -42,7 +42,7 @@ describe 'rake assets' do
|
|
|
42
42
|
allow(File).to receive(:readlines).and_return(StringIO.new(data).readlines)
|
|
43
43
|
Dump::Env.with_env :assets => 'public/images' do
|
|
44
44
|
@rake['assets'].invoke
|
|
45
|
-
expect(ENV
|
|
45
|
+
expect(ENV.fetch('ASSETS', nil)).to eq('public/images')
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|