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 configuration to surpress active_record checks #2266
Conversation
@JonRowe this seems trivial and mostly working, I can take it from here if you like. |
02dfffb
to
71934df
Compare
@pirj Happy for you to take it from here, I might have more time to work on it later. |
Sounds good 👍 |
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.
It's so tempting to remove this.
What tests did you have in mind to cover this change, @JonRowe ? |
bf45618
to
5bab9ea
Compare
I mean I guess we could, but maybe in
We need to disable the db and check that it still works |
+1 |
This passes the build now, for tests I think the best step is to add something to the |
That's what I'm on right now. Trying to reproduce the original failure from this app to mimic it properly in the test. |
87a03e4
to
1a6b528
Compare
end | ||
end | ||
end | ||
end |
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.
It's like that since the original problem was that active_record
was defined, just wasn't used and DB wasn't set up.
I've double-checked that this test does blow up if config.use_active_record = true
inside no_active_record
app.
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 tried hard, but couldn't make this example repo work to reproduce the original issue. Mostly due to bundler 1/2 problem, and then dependencies hell with Rails version which I had to update to 5.2, and in the end with missing rake-test
's methods, probably due to version mismatch.
@@ -44,6 +44,7 @@ def setup_tasks | |||
|
|||
def final_tasks | |||
copy_file 'spec/verify_no_active_record_spec.rb' | |||
copy_file 'spec/verify_no_fixture_setup_spec.rb' |
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.
?
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.
Added another spec to the smoke app. Should it be done differently?
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.
Sorry no, I read this as being identical several times, must be getting late 😂
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 was confused as well when I've finished typing its name 😆
1a6b528
to
beda644
Compare
Fixes #1876 |
@pirj I rewrote the commits for this and re-pushed, once green I'm going to merge if you're happy? |
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.
Looks good!
@Jack12816 @mrgordon @JoostVanAverbeke does this work for you? |
Thanks! |
Add configuration to surpress active_record checks
This new environment will be used for smoke testing only. E.g. RAILS_ENV=smoke_test TEST_URL=... bundle exec rake spec:features A new environment is required since RSpec requires a DB to be running and connected to in order to run the tests. We could delete the constant ActiveRecord e.g. Object.send(:remove_const, :ActiveRecord), but I decided to use a new env that doesn't load it instead. Alternative approaches: - We could use https://github.com/nulldb/nulldb rather than not requiring ActiveRecord - There might be a way to use rspec/rspec-rails#2266 but I don't think it helps our situations, since we do need ActiveRecord.
This new environment will be used for smoke testing only. E.g. RAILS_ENV=smoke_test TEST_URL=... bundle exec rake spec:features A new environment is required since RSpec requires a DB to be running and connected to in order to run the tests. We could delete the constant ActiveRecord e.g. Object.send(:remove_const, :ActiveRecord), but I decided to use a new env that doesn't load it instead. Alternative approaches: - We could use https://github.com/nulldb/nulldb rather than not requiring ActiveRecord - There might be a way to use rspec/rspec-rails#2266 but I don't think it helps our situations, since we do need ActiveRecord.
This new environment will be used for smoke testing only. E.g. RAILS_ENV=smoke_test TEST_URL=... bundle exec rake spec:features A new environment is required since RSpec requires a DB to be running and connected to in order to run the tests. We could delete the constant ActiveRecord e.g. Object.send(:remove_const, :ActiveRecord), but I decided to use a new env that doesn't load it instead. Alternative approaches: - We could use https://github.com/nulldb/nulldb rather than not requiring ActiveRecord - There might be a way to use rspec/rspec-rails#2266 but I don't think it helps our situations, since we do need ActiveRecord.
This new environment will be used for smoke testing only. E.g. RAILS_ENV=smoke_test TEST_URL=... bundle exec rake spec:features A new environment is required since RSpec requires a DB to be running and connected to in order to run the tests. We could delete the constant ActiveRecord e.g. Object.send(:remove_const, :ActiveRecord), but I decided to use a new env that doesn't load it instead. Alternative approaches: - We could use https://github.com/nulldb/nulldb rather than not requiring ActiveRecord - There might be a way to use rspec/rspec-rails#2266 but I don't think it helps our situations, since we do need ActiveRecord.
Alternative to #2038 fixes #1876.
I'm currently missing a reliable test for this, the approach in #2038 is one I do not want to take, we've never configured a database and our specs have worked, so if this switch is required when no database is present there has to be a way to trigger that error without configuring a database?
Backtrace from stackoverflow: