-
Notifications
You must be signed in to change notification settings - Fork 501
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
Add option to skip call to purge_before_load in parallel::load_schema and parallel::load_structure #529
base: master
Are you sure you want to change the base?
Add option to skip call to purge_before_load in parallel::load_schema and parallel::load_structure #529
Changes from all commits
236d227
22747d4
3e316b5
c0d3344
da1ece1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,42 @@ | |
end | ||
end | ||
|
||
describe '.purge_before_load?' do | ||
subject { ParallelTests::Tasks.purge_before_load? } | ||
context "PURGE_BEFORE_LOAD is set to 'false'" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI I'd test this like so: (less nesting / context switching and 1 change per test) it "is true" do
exoect(subject).to eq true
end
it "is false when set to false" do
with_env(PURGE_BEFORE_LOAD: 'false') do
expect(subject).to eq false
end
end
it "is true when set to true" do
with_env(PURGE_BEFORE_LOAD: 'true') do
expect(subject).to eq true
end
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll refactor it. However, I prefer to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just FYI either way works :) |
||
before { expect(ENV).to receive(:fetch).with('PURGE_BEFORE_LOAD', 'TRUE').and_return('false') } | ||
|
||
it 'returns false' do | ||
expect(subject).to be_falsey | ||
end | ||
end | ||
|
||
context 'PURGE_BEFORE_LOAD is not set' do | ||
|
||
it 'defaults to true' do | ||
expect(subject).to be_truthy | ||
end | ||
end | ||
end | ||
|
||
describe '.purge_before_load' do | ||
subject { ParallelTests::Tasks.purge_before_load } | ||
context 'Rails version is 4.3.1' do | ||
before do | ||
class Rails; end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defining a class at runtime is a bad idea :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would you stub the call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. define it global ... and then either add it there or stub it ... |
||
allow(Rails).to receive(:version).and_return('4.3.1') | ||
end | ||
|
||
context "PURGE_BEFORE_LOAD is set to 'false'" do | ||
before { expect(ENV).to receive(:fetch).with('PURGE_BEFORE_LOAD', 'TRUE').and_return('false') } | ||
|
||
it 'returns nil' do | ||
expect(subject).to be_nil | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe ".rails_env" do | ||
it "should be test when nothing was set" do | ||
expect(ParallelTests::Tasks.rails_env).to eq("test") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot use Rails.version since this might be used without rails ...
ActiveRecord::Version::STRING
should workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this be used without Rails? All tasks that call this method depend on Rails' rake tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always though as this only needing ActiveRecord to work ... tasks come from https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake ... which is a railtie ... adding rails to the mix seems to still be unnecessary to me ... maybe
ActiveRecord.version => #<Gem::Version "5.0.0.1">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bah ... does not work on rails 3 ... maybe
ActiveRecord::VERSION::STRING
is best ...