You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You asked me to put together a bug report for the issue I was seeing, so here it is.
Expected Behaviour
ActiveEntity embeds should be persisted along with all other attributes when create is called on the parent.
Actual Behaviour
The embeds are created in memory but not persisted to redis.
Minimal Reproduction
Here we have two AllFutures models; TodoList which has many TodoListItem.
Note: Redis should be running.
# frozen_string_literal: truerequire"bundler/inline"gemfile(true)dosource"https://rubygems.org"gem"rails","~> 7.0.0"gem"kredis","~> 1.0"gem"all_futures",github: "leastbad/all_futures",branch: "master"endrequire"rack/test"require"action_controller/railtie"require"active_record"require"active_support/all"classTestApp < Rails::Applicationconfig.root=__dir__config.hosts << "example.org"config.session_store:cookie_store,key: "cookie_store_key"secrets.secret_key_base="secret_key_base"Kredis::Connections.connections[:shared]=Redis.new(url: ENV.fetch("REDIS_URL","redis://localhost:6379/1"))config.logger=Logger.new($stdout)Rails.logger=config.loggerend# Required or AllFutures::Finder find method blows up at model.instance_variable_set "@created_at", Time.zone.parse(record["created_at"])Time.zone="Europe/London"classTodoList < AllFutures::Baseattribute:title,:textembeds_many:todo_itemsaccepts_nested_attributes_for:todo_items,reject_if: :all_blankendclassTodoItem < AllFutures::Baseattribute:description,:textendrequire"minitest/autorun"classBugTest < Minitest::Test# The parent TodoList persists as expecteddeftest_that_parent_record_persiststodo_list=TodoList.create(title: "Hey")asserttodo_list.persisted?found=TodoList.find(todo_list.id)assertfound.present?assert_equal"Hey",found.titleenddeftest_that_child_record_persiststodo_list=TodoList.create(title: "Hey",todo_items: [{description: "Todo 1"}])asserttodo_list.persisted?# The todo items list has been correctly cast to instances of TodoItemassert_equalTodoItem,todo_list.todo_items.first.classassert_equal"Todo 1",todo_list.todo_items.first.descriptionfound=TodoList.find(todo_list.id)assertfound.present?# Expected to fail as the embed was not persistedassert_equalTodoItem,found.todo_items.first.classendend
Please let me know if I can do anything else to assist. Thanks
The text was updated successfully, but these errors were encountered:
You asked me to put together a bug report for the issue I was seeing, so here it is.
Expected Behaviour
ActiveEntity embeds should be persisted along with all other attributes when create is called on the parent.
Actual Behaviour
The embeds are created in memory but not persisted to redis.
Minimal Reproduction
Here we have two AllFutures models; TodoList which has many TodoListItem.
Note: Redis should be running.
Please let me know if I can do anything else to assist. Thanks
The text was updated successfully, but these errors were encountered: