-
Notifications
You must be signed in to change notification settings - Fork 484
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
always return Postgres table names with schema to avoid awfulness #282
always return Postgres table names with schema to avoid awfulness #282
Conversation
WattsInABox
commented
Jul 22, 2014
- without the schema, the migrations table gets truncated since the default AR method returns ‘public.schema_migrations’
- also a possibility is truncation of tables other than desired once since without the schema, Postgres has no way of knowing which table to truncate if two schemas have the same table
describe '#database_cleaner_table_cache' do | ||
it 'should default to the list of tables with their schema' do | ||
connection.instance_variable_set(:@database_cleaner_tables, nil) | ||
connection.should receive(:tables_with_schema) |
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'd prefer we didn't set an expectation on the internals of the class, but test the desired output state.
Thanks for this @BillyWatson, could you possibly tweak the spec like I suggested (roll them together) we don't need to test private methods, and we definitely don't need to partially mock this. |
Will do |
👍 |
98b2620
to
c47b68f
Compare
Running the specs twice makes the new spec to fail. It begins with
I think that the problem does not lie with this PR though, it just got surfaced because of it. UPDATE: I have prepared a fix for this in a local branch. I will wait until this PR has been merged to push my branch and prepare a new PR. |
It could be a problem with mine, if I was supposed to trigger some cleanup or yeah, you could be right if the cleanup is supposed to be automagical. |
@@ -35,6 +35,14 @@ module ConnectionAdapters | |||
end | |||
end | |||
|
|||
describe '#database_cleaner_table_cache' do | |||
it 'should default to the list of tables with their schema' do | |||
connection.instance_variable_set(:@database_cleaner_tables, nil) |
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.
We shouldn't do this... It'd be better to figure out a way to test this without tampering with internals.
- without the schema, the migrations table gets truncated since the default AR method returns ‘public.schema_migrations’ - also a possibility is truncation of tables other than desired once since without the schema, Postgres has no way of knowing which table to truncate if two schemas have the same table
c47b68f
to
77bca12
Compare
Updated the diff by changing the test:
|
…tions_table_in_postgresql always return Postgres table names with schema to avoid awfulness
LGTM |