Remove Database Cleaner and share FactoryBot factories #1028
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Threads sharing a DB connection has been fixed in Rails 5.1 by Rails team and Capybara author, so Database Cleaner can be removed.
Changes:
database_cleaner
gem removed and all its calls from therails_helper
hooksconfig.use_transactional_fixtures
set totrue
factory_bot
gem replaced by thefactory_bot_rails
FactoryBot.definition_file_paths
is defined in the CamaleonCMS::Engine, thus sharing the factories from thecamaleon_cms
gem with the main applicationconfig.serve_static_files
replaced byconfig.public_file_server.enabled
(a change from Rails 5.1 also)Capybara::Webkit
is no longer used, so removed the related code from thespec_helper
init_site
method fromspec/support/common.rb
has been slightly refactored to callCamaleonCms::Site.delete_all
before every test run, and to nullify the@site
,@post
ivars, as well as theCamaleonCMS::Site
class ivar@main_site
. The latter being a class ivar has been persisting through all the specs, causing failuresdatabase_cleaner
removal, the DB now is not cleaned entirely after every test, so theSite
associations likeposts
,post_types
,categories
, etc., have been refactored to be dynamically fetched as@site
associations.site
factory slug should be made rendom to not cause validation issues, after which theCamaleonCms::Site.delete_all
before each test will be possible to remove, and the@site
and@post
ivars refactored to RSpeclet
memoizers.