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
Fix a fixtures test case with table prefix/suffix #4114
Fix a fixtures test case with table prefix/suffix #4114
Conversation
/cc @jonleighton |
I am not sure about this. Can you rewrite the test to use its own model class rather than modifying |
The problem is that changing |
Do you propose that i do not use an existing fixture/model and add a new one? What difference will it make? |
Yes, I am proposing that. Just feels less hackish then this weird way of resetting the table name. |
If this means to replace |
There should be some way to reload the class and reset all class instance variables, but i do not know, maybe you can suggest something along this line? |
Ok, i think i've understood what you meant: that the fixture/model be unique in the |
How about this? But i do not understand very well what this test is doing, i was just fixing a small bug. |
Yes, that looks good, but you could actually just create the class instance within the test, which will ensure that it is definitely not used elsewhere:
|
Ok, i'll try to do like this. I still think to use the same commit to order the |
Make sure the table name of a model is reset in a test case after assigning ActiveRecord::Base.table_name_prefix and ActiveRecord::Base.table_name_suffix. This was somebody else's test case, so an independent opinion on the change can be helpful.
I think i've finished. |
require 'models/task' | ||
require 'models/topic' | ||
require 'models/traffic_light' | ||
require 'models/treasure' | ||
require 'tempfile' |
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.
Sorted alphabetically.
…fixtures_test Fix a fixtures test case with table prefix/suffix
This broke the postgres tests: http://travis-ci.org/#!/rails/rails/jobs/437615 I have reverted - please submit a new PR with a fix for that. Thanks. |
I do not know when i will have time to look into it, i haven't figured out how to use PostgreSQL on my Mac OS. All errors are in the same line where database table rows are first used. It looks like the table must have been empty, but strange that this only happens with PostgreSQL. The only thing that i've changed that i can think of is that i do not have |
I've installed PostgreSQL! I'll try to debug this. |
How do i run a single test with postgresql? |
|
Thanks! |
I have no idea what it was. I went back to master and started slowly applying patches. I created OtherTopic model identical to Topic, added table creation to schema.rb, did other things, then removed them, and i ended up with my original commit that now passes the postgresql test, but was not passing it before. What should i do? |
...
3302 tests, 10188 assertions, 0 failures, 0 errors, 10 skips |
Could have something to do with the state of the test database? |
Make sure the table name of a model is reset in a test case after assigning
ActiveRecord::Base.table_name_prefix
andActiveRecord::Base.table_name_suffix
. Before this change,Topic.table_name
would use the "memoized" value without prefix and suffix.This change does not currently fix anything, but make the test case to test the right thing. I plan to submit a patch to make fixtures use the table name defined in the associated model, and there this test would fail without this fix.
This was somebody else's test case, so an independent opinion on the change can be helpful.