diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-27 23:52:37 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-27 23:52:37 -0300 |
commit | d81f147003edcb788e18b36d6351e8787c46b2fc (patch) | |
tree | df899696cfe9db42fb1f77da65ea583e5eed6ce3 /activerecord/lib/active_record | |
parent | 1ed92a2ee192631b8beac8f51a3af209c8d1bc8a (diff) | |
parent | 908cfef6e2f2c888e02b89fc74888786efda2a45 (diff) | |
download | rails-d81f147003edcb788e18b36d6351e8787c46b2fc.tar.gz rails-d81f147003edcb788e18b36d6351e8787c46b2fc.tar.bz2 rails-d81f147003edcb788e18b36d6351e8787c46b2fc.zip |
Merge pull request #20171 from georgeclaghorn/enums-in-fixtures
Allow the use of symbols or strings to specify enum values in test fixtures
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 2c1771dd6c..1ec8f818cd 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -644,6 +644,11 @@ module ActiveRecord row[primary_key_name] = ActiveRecord::FixtureSet.identify(label, primary_key_type) end + # Resolve enums + model_class.defined_enums.each do |name, values| + row[name] = values.fetch(row[name], row[name]) + end + # If STI is used, find the correct subclass for association reflection reflection_class = if row.include?(inheritance_column_name) |