aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/fixture_set/file.rb
diff options
context:
space:
mode:
authorTongfei Gao <gaotongfei1995@gmail.com>2019-05-18 20:58:22 +0800
committerTongfei Gao <gaotongfei1995@gmail.com>2019-07-27 16:40:16 +0800
commitc09a4fd23d7d52552132edde7ad155f366c560b8 (patch)
tree689a66272dffccef08230af259a687ed4be960cd /activerecord/lib/active_record/fixture_set/file.rb
parentd1ffe59ab5fd6e811833c127d43b32e87b5d7131 (diff)
downloadrails-c09a4fd23d7d52552132edde7ad155f366c560b8.tar.gz
rails-c09a4fd23d7d52552132edde7ad155f366c560b8.tar.bz2
rails-c09a4fd23d7d52552132edde7ad155f366c560b8.zip
Allow specify fixtures to be ignored
Allow specifying what fixtures can be ignored by setting `ignore` in fixtures YAML file: # users.yml _fixture: ignore: - base base: &base admin: false introduction: "This is a default description" admin: <<: *base admin: true visitor: <<: *base In the above example, "base" fixture will be ignored when creating users fixture. This is helpful when you want to inherit attributes and it makes your fixtures more "DRY".
Diffstat (limited to 'activerecord/lib/active_record/fixture_set/file.rb')
-rw-r--r--activerecord/lib/active_record/fixture_set/file.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixture_set/file.rb b/activerecord/lib/active_record/fixture_set/file.rb
index f1ea0e022f..b2030a5bb9 100644
--- a/activerecord/lib/active_record/fixture_set/file.rb
+++ b/activerecord/lib/active_record/fixture_set/file.rb
@@ -29,6 +29,10 @@ module ActiveRecord
config_row["model_class"]
end
+ def ignored_fixtures
+ config_row["ignore"]
+ end
+
private
def rows
@rows ||= raw_rows.reject { |fixture_name, _| fixture_name == "_fixture" }
@@ -40,7 +44,7 @@ module ActiveRecord
if row
row.last
else
- { 'model_class': nil }
+ { 'model_class': nil, 'ignore': nil }
end
end
end