Last active
January 16, 2020 19:30
-
-
Save yhirano55/9a062e35f79fc27a3ddbcde3572e77d8 to your computer and use it in GitHub Desktop.
Run in CI: RAILS_ENV=test bundle exec rails db:seed_fu:lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/seed_fu/lint.rake | |
namespace :db do | |
namespace :seed_fu do | |
desc 'Verify that all fixtures are valid' | |
task lint: :environment do | |
if Rails.env.test? | |
conn = ActiveRecord::Base.connection | |
%w[development test production].each do |env| | |
conn.transaction do | |
SeedFu.seed("db/fixtures/#{env}") | |
raise ActiveRecord::Rollback | |
end | |
end | |
else | |
system("bundle exec rails db:seed_fu:lint RAILS_ENV='test'") | |
fail if $?.exitstatus.nonzero? | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment