diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-12 16:22:40 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-12 16:22:40 -0700 |
commit | 0839aa70d55951309441824d6d7badb5804042de (patch) | |
tree | 20fbc645096e54e862b4922647fac739c61b0730 /lib | |
parent | 531d7dd584267e81ba57d4de7f0fe21b18a83cbb (diff) | |
download | rails-0839aa70d55951309441824d6d7badb5804042de.tar.gz rails-0839aa70d55951309441824d6d7badb5804042de.tar.bz2 rails-0839aa70d55951309441824d6d7badb5804042de.zip |
Add default fixtures file on install
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/actiontext.rake | 15 | ||||
-rw-r--r-- | lib/templates/fixtures.yml | 4 |
2 files changed, 18 insertions, 1 deletions
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: <p>In a <i>million</i> stars!</p> |