mobility-actiontext 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62723fa69cae996e74c0b33dfe0d5babf7395d6384c3c548fc7e06c33fcec9ce
4
- data.tar.gz: 28ec6773c56d337a844d6b27bd13aebaea539bc0a1fafad50a9cfe0257243c82
3
+ metadata.gz: 07d1047f391d3c0dde02a646adc682b3a09f1e99a2e4beb04c7ba3b971a41e0d
4
+ data.tar.gz: a49bf73b5b911d02a71eacc5f84f9f18ed91865befb9b2872a29025bb7be6813
5
5
  SHA512:
6
- metadata.gz: f2b425c119565f978ed06b45e54bb9c452d648a4ff39026b35dbd50cce2d567f555685de9d56d68b0c02d2559a5f4dbee453e76edf61846321b40972387bf704
7
- data.tar.gz: 6eced781dcc3440abcb988f898979caca2511eda42486d11a141fa457f26802532d609bbeaa32a8127f036eb563850a3a6035c0a84ec05d6bad1a906c43f4aae
6
+ metadata.gz: 56786adb17b842818b65b6de35403a987c8b49dc570c4a00a367995160590c58f284374e74c391bc6aee37d05b2c1cf081aee878ce83232d877daeba86292ed6
7
+ data.tar.gz: e82e781d93cd99fce6bb5e85fff45334b39cedc50a6772476a4fa22ed1319f0beabf9c20df1b319fe514f6e70743dff9880dcdac5814bbfc2c460bb32886843a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Mobility Action Text Changelog
2
2
 
3
+ ### 1.0.0 (2022-02-28)
4
+ - Fix eager loading of single translation using `with_rich_text_#{name}` ([#24](https://github.com/sedubois/mobility-actiontext/pull/24)).
5
+
6
+ The version update to 1.0.0 indicates the plugin has no more known issues.
7
+
3
8
  ### 0.6.0 (2022-02-27)
4
9
  - Include all translations on eager load using `with_all_rich_text` ([#23](https://github.com/sedubois/mobility-actiontext/pull/23)).
5
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility-actiontext (0.6.0)
4
+ mobility-actiontext (1.0.0)
5
5
  actiontext (>= 6.0)
6
6
  mobility (~> 1.2)
7
7
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mobility
4
4
  module ActionText
5
- VERSION = '0.6.0'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
@@ -28,6 +28,12 @@ module Mobility
28
28
  # override to return record instead of value
29
29
  def read(locale, **options)
30
30
  return super if self.options[:plain]
31
+
32
+ if model.association_cached?("rich_text_#{attribute}")
33
+ eager_loaded = model.public_send("rich_text_#{attribute}")
34
+ return eager_loaded if eager_loaded.locale == locale.to_s
35
+ end
36
+
31
37
  translation_for(locale, **options)
32
38
  end
33
39
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- mobility-actiontext (0.6.0)
4
+ mobility-actiontext (1.0.0)
5
5
  actiontext (>= 6.0)
6
6
  mobility (~> 1.2)
7
7
 
@@ -100,11 +100,15 @@ module Mobility
100
100
 
101
101
  assert_no_queries do
102
102
  assert_equal 'Hello world!', post.content.to_plain_text
103
-
104
- skip('FIXME: this should execute no queries')
105
103
  end
106
104
  end
107
105
 
106
+ test 'correct translation is returned if single translation for different locale was eager loaded' do
107
+ post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_rich_text_content.last } }
108
+
109
+ assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
110
+ end
111
+
108
112
  test 'post content is eager loaded with all rich text' do
109
113
  post = assert_queries(2) { Post.with_all_rich_text.last }
110
114
 
@@ -113,6 +117,12 @@ module Mobility
113
117
  end
114
118
  end
115
119
 
120
+ test 'correct translation is returned if all translations for different locale were eager loaded' do
121
+ post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_all_rich_text.last } }
122
+
123
+ assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
124
+ end
125
+
116
126
  test 'post non_i18n_content is eager loaded with all rich text' do
117
127
  post = assert_queries(2) { Post.with_all_rich_text.last }
118
128
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility-actiontext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Dubois
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-27 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actiontext