Chatwoot/spec/cypress/app_commands/activerecord_fixtures.rb
Sojan Jose d6f309ce22
Chore: Initialize Cypress tests (#1078)
Addresses: #412

Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
2020-07-21 20:11:22 +05:30

22 lines
931 B
Ruby

# you can delete this file if you don't use Rails Test Fixtures
fixtures_dir = command_options.try(:[], 'fixtures_dir')
fixture_files = command_options.try(:[], 'fixtures')
if defined?(ActiveRecord)
require 'active_record/fixtures'
fixtures_dir ||= ActiveRecord::Tasks::DatabaseTasks.fixtures_path
fixture_files ||= Dir["#{fixtures_dir}/**/*.yml"].map { |f| f[(fixtures_dir.size + 1)..-5] }
logger.debug "loading fixtures: { dir: #{fixtures_dir}, files: #{fixture_files} }"
ActiveRecord::FixtureSet.reset_cache
ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
'Fixtures Done' # this gets returned
else # this else part can be removed
logger.error 'Looks like activerecord_fixtures has to be modified to suite your need'
Post.create(title: 'MyCypressFixtures')
Post.create(title: 'MyCypressFixtures2')
Post.create(title: 'MyRailsFixtures')
Post.create(title: 'MyRailsFixtures2')
end