From 0839aa70d55951309441824d6d7badb5804042de Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 12 Sep 2018 16:22:40 -0700 Subject: Add default fixtures file on install --- lib/tasks/actiontext.rake | 15 ++++++++++++++- lib/templates/fixtures.yml | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lib/templates/fixtures.yml diff --git a/lib/tasks/actiontext.rake b/lib/tasks/actiontext.rake index 01f8697c61..5381c5486f 100644 --- a/lib/tasks/actiontext.rake +++ b/lib/tasks/actiontext.rake @@ -5,7 +5,7 @@ namespace :action_text do Rake::Task["install:migrations"].clear_comments desc "Copy over the migration, stylesheet, and JavaScript files" - task install: %w( environment active_storage:install copy_migration copy_stylesheet ) + task install: %w( environment active_storage:install copy_migration copy_stylesheet copy_fixtures ) task :copy_migration do if Rake::Task.task_defined?("action_text:install:migrations") @@ -25,4 +25,17 @@ namespace :action_text do FileUtils.cp STYLESHEET_TEMPLATE_PATH, STYLESHEET_APP_PATH end end + + FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__) + FIXTURE_APP_DIR_PATH = Rails.root.join("test/fixtures/action_text") + FIXTURE_APP_PATH = FIXTURE_APP_DIR_PATH.join("fixtures.yml") + + task :copy_fixtures do + if File.exist?(FIXTURE_APP_PATH) + puts "Won't copy Action Text fixtures as it already exists" + else + FileUtils.mkdir FIXTURE_APP_DIR_PATH + FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH + end + end end diff --git a/lib/templates/fixtures.yml b/lib/templates/fixtures.yml new file mode 100644 index 0000000000..8b371ea604 --- /dev/null +++ b/lib/templates/fixtures.yml @@ -0,0 +1,4 @@ +# one: +# record: name_of_fixture (ClassOfFixture) +# name: content +# body:

In a million stars!

-- cgit v1.2.3