Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement overwrite to dump all columns and skip default excluded #3

Merged
1 commit merged into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/seed_dump/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def dump_using_environment(env = {})
options = {
append: append,
batch_size: retrieve_batch_size_value(env),
exclude: retrieve_exclude_value(env),
exclude: retrieve_dump_all_value(env) ? [] : retrieve_exclude_value(env),
insert_all: retrieve_insert_all_value(env),
file: retrieve_file_value(env),
import: retrieve_import_value(env)
Expand Down Expand Up @@ -101,6 +101,13 @@ def retrieve_insert_all_value(env)
parse_boolean_value(env['INSERT_ALL'])
end

# Internal: Returns a Boolean indicating whether the value for the "DUMP_ALL"
# key in the given Hash is equal to the String "true" (ignoring case),
# false if no value exists.
def retrieve_dump_all_value(env)
parse_boolean_value(env['DUMP_ALL'])
end

# Internal: Retrieves an Array of Class constants parsed from the value for
# the "MODELS_EXCLUDE" key in the given Hash, and an empty Array if such
# key exists.
Expand Down
10 changes: 9 additions & 1 deletion spec/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
end

describe 'INSERT_ALL' do
it "specifies append as true if the INSERT_ALL env var is 'true'" do
it "specifies insert_all as true if the INSERT_ALL env var is 'true'" do
described_class.should_receive(:dump).with(anything, include(insert_all: true))

described_class.dump_using_environment('INSERT_ALL' => 'true')
end
end

describe 'DUMP_ALL' do
it 'sets empty array if dump all is true' do
described_class.should_receive(:dump).with(anything, include(exclude: []))

described_class.dump_using_environment('DUMP_ALL' => 'true')
end
end

describe 'APPEND' do
it "specifies append as true if the APPEND env var is 'true'" do
described_class.should_receive(:dump).with(anything, include(append: true))
Expand Down