-
Notifications
You must be signed in to change notification settings - Fork 81
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
Recommendations for fixtures? #122
Comments
I'm a newbie who is using fixture_dependencies with sequel-rails with Rails 5 and I got it working fine after a bit of Google research...
Since all of your generated test classes have Hope this helps. |
Ah, excellent. Thanks @tmepple. I'm hoping to make the |
A special note for those who like to use FixtureDependencies with MS-SQL-Server. # ...
require 'fixture_dependencies'
require 'fixture_dependencies/sequel'
FixtureDependencies.verbose = 5
FixtureDependencies.fixture_path = 'test/fixtures'
class << FixtureDependencies
# MS-SqlServer does not allow to insert new records with an already used pk unless
# IDENTITY_INSERT is ON.
# Because FixtureDependencies tries to insert once inserted records with its primary key set,
# it needs to be monkey patched to work with MS-SqlServer.
alias :model_save_S_org :model_save_S
def model_save_S(object)
object.db.run("SET IDENTITY_INSERT #{object.class.table_name} ON") if object.id.present?
model_save_S_org(object)
object.db.run("SET IDENTITY_INSERT #{object.class.table_name} OFF") if object.id.present?
end
end
class ActiveSupport::TestCase
def run(*args, &block)
Sequel::Model.db.transaction(rollback: :always, auto_savepoint: true) do
super
end
end
# ...
end |
My apologies for opening an issue to ask a question, but I can't find a Google Group or IRC channel or anything like that mentioned in the README.
What's the best way to get started with fixtures for unit tests when using SequelRails, specifically with Rails 4.2? I've been flailing around with fixture_dependencies without any luck; it appears to not have been updated to work with ActiveSupport::TestCase. Are there any recommendations I can follow to get started here? Thanks in advance.
The text was updated successfully, but these errors were encountered: