1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/fixtures
Yoshiyuki Hirano f4fbdb1b4e Allow AR::Enum definitions with boolean values
If `AR::Enum` is used for boolean field, it would be not expected
behavior for us.

fixes #38075

Problem:

In case of using boolean for enum, we can set with string (hash key)
to instance, but we cannot set with actual value (hash value).

```ruby
class Post < ActiveRecord::Base
  enum status: { enabled: true, disabled: false }
end

post.status = 'enabled'
post.status # 'enabled'

post.status = true
post.status # 'enabled'

post.status = 'disabled'
post.status # 'disabled'

post.status = false
post.status # nil (This is not expected behavior)
```

After looking into `AR::Enum::EnumType#cast`, I found that `blank?`
method converts from false value to nil (it seems it may not intentional behavior).

In this patch, I improved that if it defines enum with boolean,
it returns reasonable behavior.
2019-12-24 07:05:42 -10:00
..
admin
all remove duplicated fixture set names 2016-09-12 08:14:10 +09:00
categories
naked/yml Use bulk INSERT to insert fixtures 2017-06-20 13:18:53 -04:00
reserved_words Quote primary key in the subselect generated by mysql2 adapter 2017-12-19 20:59:09 +09:00
to_be_linked
accounts.yml
author_addresses.yml Fix test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct to NULL-agnostic way 2015-12-19 17:38:42 +09:00
author_favorites.yml
authors.yml Fix test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct to NULL-agnostic way 2015-12-19 17:38:42 +09:00
bad_posts.yml Merge pull request #20574 from repinel/fix-db-fixtures-load 2015-09-30 11:06:41 +02:00
binaries.yml Add binary helper method to fixtures. 2017-08-12 18:35:32 +09:00
books.yml Allow AR::Enum definitions with boolean values 2019-12-24 07:05:42 -10:00
bulbs.yml make it possible to access fixtures excluded by a default_scope. 2014-11-21 14:57:25 +01:00
cars.yml
categories.yml
categories_ordered.yml
categories_posts.yml
categorizations.yml
citations.yml Lazy checking whether or not values in IN clause are boundable 2018-10-24 11:26:49 +09:00
clubs.yml
collections.yml
colleges.yml
comments.yml
companies.yml
computers.yml Ensure HABTM relationships produce valid class names (Fixes #17119) 2014-11-09 11:56:07 -06:00
content.yml Add support for bidirectional destroy dependencies 2015-01-16 11:41:43 +00:00
content_positions.yml Add support for bidirectional destroy dependencies 2015-01-16 11:41:43 +00:00
courses.yml
customers.yml Fix expanding an array of composed_of objects which have multiple mappings 2018-01-29 09:24:14 +09:00
dashboards.yml
dead_parrots.yml Fixes #18492 2015-01-14 21:36:58 +05:30
developers.yml Ensure HABTM relationships produce valid class names (Fixes #17119) 2014-11-09 11:56:07 -06:00
developers_projects.yml
dog_lovers.yml
dogs.yml
doubloons.yml Fix crash when loading fixture with belongs_to association defined in abstract base class. 2015-06-04 12:38:00 -04:00
edges.yml
entrants.yml
essays.yml
faces.yml
fk_test_has_fk.yml
fk_test_has_pk.yml fk: use random digest names 2014-06-26 22:03:49 +02:00
friendships.yml
funny_jokes.yml
interests.yml
items.yml
jobs.yml
legacy_things.yml
live_parrots.yml Fixes #18492 2015-01-14 21:36:58 +05:30
mateys.yml
member_details.yml
member_types.yml
members.yml
memberships.yml Ensure to calculate column aliases after all table aliases are constructed 2018-06-19 22:21:51 +09:00
men.yml
minimalistics.yml Bring back ability to insert zero value on primary key for fixtures (#31795) 2018-01-26 12:42:28 +09:00
minivans.yml
mixed_case_monkeys.yml
mixins.yml
movies.yml
nodes.yml Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
organizations.yml
other_books.yml Allow specify fixtures to be ignored 2019-07-27 16:40:16 +08:00
other_comments.yml Merge pull request #20574 from repinel/fix-db-fixtures-load 2015-09-30 11:06:41 +02:00
other_dogs.yml fix #create_fixtures when equal table names in different databases 2016-12-21 11:09:29 +01:00
other_posts.yml Set counter caches to correct values in fixtures 2017-11-08 20:45:43 +02:00
other_topics.yml
owners.yml
parrots.yml Allow specify fixtures to be ignored 2019-07-27 16:40:16 +08:00
parrots_pirates.yml
people.yml
peoples_treasures.yml
pets.yml
pirates.yml Fix lookup of fixtures with non-string label 2015-01-06 17:15:39 +05:30
posts.yml Set counter caches to correct values in fixtures 2017-11-08 20:45:43 +02:00
price_estimates.yml Fixed where for polymorphic associations when passed an array containing different types. 2016-02-16 10:41:26 -08:00
products.yml
projects.yml
randomly_named_a9.yml
ratings.yml
readers.yml
references.yml
ships.yml
speedometers.yml
sponsors.yml Can preload associations through polymorphic associations 2018-04-20 17:28:25 -04:00
string_key_objects.yml
subscribers.yml Correct spelling 2017-02-05 19:00:18 -06:00
subscriptions.yml
taggings.yml
tags.yml
tasks.yml Fix docs to replace http with https in activerecord [ci skip] 2019-08-26 22:34:33 +09:00
topics.yml
toys.yml
traffic_lights.yml
treasures.yml
trees.yml Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
uuid_children.yml
uuid_parents.yml
variants.yml
vegetables.yml
vertices.yml
warehouse-things.yml
zines.yml