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
Following up on this deranged sequence of comments I clone the repo and added a test to prove the point (at least as I see it)
# spec/mobility/backends/active_record/container_spec.rbcontext"with cache plugin"doplugins:active_record,:reader,:writer,:cachebefore{translatesContainerPost,:title,:content,backend: :container}let(:backend){post.mobility_backends[:title]}include_accessor_examples'ContainerPost'include_dup_examples'ContainerPost'include_cache_key_examples'ContainerPost'it'correctly updates the cache when translations are changed'dopost=ContainerPost.newpost.title="foo"expect(post.title).toeq("foo")post.title="bar"expect(post.title).toeq("bar")post.saveendend
which fails
ORM=active_record DB=postgres rspec spec/mobility/backends/active_record/container_spec.rb:55 ✔ 6s
Skipping AllocationStats.
Run options:
include {:focus=>true, :locations=>{"./spec/mobility/backends/active_record/container_spec.rb"=>[55]}}
exclude {:orm=>#<Proc: ./spec/spec_helper.rb:95>, :db=>#<Proc: ./spec/spec_helper.rb:95>}
Randomized with seed 25927
Mobility::Backends::ActiveRecord::Container
with cache plugin
correctly updates the cache when translations are changed (FAILED - 1)
behaves like model with translated attribute accessors
sets translations in multiple locales when creating and saving model
gets and sets translations in multiple locales
sets translations in multiple locales when updating model
gets and sets translations in one locale
behaves like dupable model
dups new record
dups persisted model
behaves like cache key
changes cache key when translation updated
Failures:
1) Mobility::Backends::ActiveRecord::Container with cache plugin correctly updates the cache when translations are changed
Failure/Error: expect(post.title).to eq("bar")
expected: "bar"
got: "foo"
(compared using ==)
# ./spec/mobility/backends/active_record/container_spec.rb:72:in `block (3 levels) in <top (required)>'
Finished in 0.31598 seconds (files took 2.19 seconds to load)
8 examples, 1 failure
Failed examples:
rspec ./spec/mobility/backends/active_record/container_spec.rb:65 # Mobility::Backends::ActiveRecord::Container with cache plugin correctly updates the cache when translations are changed
The fix is - naively - easy
diff --git a/lib/mobility/backends/active_record/container.rb b/lib/mobility/backends/active_record/container.rb
index 5f14540..1fce61a 100644
--- a/lib/mobility/backends/active_record/container.rb+++ b/lib/mobility/backends/active_record/container.rb@@ -37,7 +37,8 @@ Implements the {Mobility::Backends::Container} backend for ActiveRecord models.
# @return [String,Integer,Boolean] Updated value
def write(locale, value, _ = nil)
set_attribute_translation(locale, value)
- read(locale)++ value
end
# @!endgroup
The tests (for container) pass and I'm happy to open a PR with these two changes, but I wanted to run by you first :)
The text was updated successfully, but these errors were encountered:
Following up on this deranged sequence of comments I clone the repo and added a test to prove the point (at least as I see it)
which fails
The fix is - naively - easy
The tests (for container) pass and I'm happy to open a PR with these two changes, but I wanted to run by you first :)
The text was updated successfully, but these errors were encountered: