mobility-actiontext 0.6.0 → 1.1.1

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: d7c9e89d17b9b01aa84055f4c34a75e258c1cffd7c35198dae1957b53fde7b5f
4
+ data.tar.gz: 255c73717d866912ebc0b020df39d1641f58f458130b89b67e35cba965a27391
5
5
  SHA512:
6
- metadata.gz: f2b425c119565f978ed06b45e54bb9c452d648a4ff39026b35dbd50cce2d567f555685de9d56d68b0c02d2559a5f4dbee453e76edf61846321b40972387bf704
7
- data.tar.gz: 6eced781dcc3440abcb988f898979caca2511eda42486d11a141fa457f26802532d609bbeaa32a8127f036eb563850a3a6035c0a84ec05d6bad1a906c43f4aae
6
+ metadata.gz: b9c02385dc9cbd7fd035e5a9e81e651c5948b20c65fd5c86768b5dcd12ffce04a7a1293784a685629c0b12e31ac1ffb5340ea93cc4205f9290aea812364309e6
7
+ data.tar.gz: b5cf0bd2baf3c180a40047767899b48921b5d42cc67f8ca7d3e741fbe0e751b2fc54595e7e58cdbbd8faf8dac6ea15e94fabf999948de744eec314851894eace
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Mobility Action Text Changelog
2
2
 
3
+ ### 1.1.1 (2022-04-03)
4
+
5
+ - Fix rich text associations for locales with hyphens.
6
+
7
+ ### 1.1.0 (2022-03-24)
8
+
9
+ - Add rich text associations for each locale ([#25](https://github.com/sedubois/mobility-actiontext/pull/25)).
10
+
11
+ ### 1.0.0 (2022-02-28)
12
+ - Fix eager loading of single translation using `with_rich_text_#{name}` ([#24](https://github.com/sedubois/mobility-actiontext/pull/24)).
13
+
14
+ The version update to 1.0.0 indicates the plugin has no more known issues.
15
+
3
16
  ### 0.6.0 (2022-02-27)
4
17
  - Include all translations on eager load using `with_all_rich_text` ([#23](https://github.com/sedubois/mobility-actiontext/pull/23)).
5
18
 
data/Gemfile.lock CHANGED
@@ -1,68 +1,68 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility-actiontext (0.6.0)
4
+ mobility-actiontext (1.1.1)
5
5
  actiontext (>= 6.0)
6
6
  mobility (~> 1.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.0.2.2)
12
- actionview (= 7.0.2.2)
13
- activesupport (= 7.0.2.2)
11
+ actionpack (7.0.2.3)
12
+ actionview (= 7.0.2.3)
13
+ activesupport (= 7.0.2.3)
14
14
  rack (~> 2.0, >= 2.2.0)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actiontext (7.0.2.2)
19
- actionpack (= 7.0.2.2)
20
- activerecord (= 7.0.2.2)
21
- activestorage (= 7.0.2.2)
22
- activesupport (= 7.0.2.2)
18
+ actiontext (7.0.2.3)
19
+ actionpack (= 7.0.2.3)
20
+ activerecord (= 7.0.2.3)
21
+ activestorage (= 7.0.2.3)
22
+ activesupport (= 7.0.2.3)
23
23
  globalid (>= 0.6.0)
24
24
  nokogiri (>= 1.8.5)
25
- actionview (7.0.2.2)
26
- activesupport (= 7.0.2.2)
25
+ actionview (7.0.2.3)
26
+ activesupport (= 7.0.2.3)
27
27
  builder (~> 3.1)
28
28
  erubi (~> 1.4)
29
29
  rails-dom-testing (~> 2.0)
30
30
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
31
- activejob (7.0.2.2)
32
- activesupport (= 7.0.2.2)
31
+ activejob (7.0.2.3)
32
+ activesupport (= 7.0.2.3)
33
33
  globalid (>= 0.3.6)
34
- activemodel (7.0.2.2)
35
- activesupport (= 7.0.2.2)
36
- activerecord (7.0.2.2)
37
- activemodel (= 7.0.2.2)
38
- activesupport (= 7.0.2.2)
39
- activestorage (7.0.2.2)
40
- actionpack (= 7.0.2.2)
41
- activejob (= 7.0.2.2)
42
- activerecord (= 7.0.2.2)
43
- activesupport (= 7.0.2.2)
34
+ activemodel (7.0.2.3)
35
+ activesupport (= 7.0.2.3)
36
+ activerecord (7.0.2.3)
37
+ activemodel (= 7.0.2.3)
38
+ activesupport (= 7.0.2.3)
39
+ activestorage (7.0.2.3)
40
+ actionpack (= 7.0.2.3)
41
+ activejob (= 7.0.2.3)
42
+ activerecord (= 7.0.2.3)
43
+ activesupport (= 7.0.2.3)
44
44
  marcel (~> 1.0)
45
45
  mini_mime (>= 1.1.0)
46
- activesupport (7.0.2.2)
46
+ activesupport (7.0.2.3)
47
47
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
48
  i18n (>= 1.6, < 2)
49
49
  minitest (>= 5.1)
50
50
  tzinfo (~> 2.0)
51
51
  builder (3.2.4)
52
- concurrent-ruby (1.1.9)
52
+ concurrent-ruby (1.1.10)
53
53
  crass (1.0.6)
54
54
  erubi (1.10.0)
55
55
  globalid (1.0.0)
56
56
  activesupport (>= 5.0)
57
57
  i18n (1.10.0)
58
58
  concurrent-ruby (~> 1.0)
59
- loofah (2.14.0)
59
+ loofah (2.16.0)
60
60
  crass (~> 1.0.2)
61
61
  nokogiri (>= 1.5.9)
62
62
  marcel (1.0.2)
63
63
  mini_mime (1.1.2)
64
64
  minitest (5.15.0)
65
- mobility (1.2.5)
65
+ mobility (1.2.6)
66
66
  i18n (>= 0.6.10, < 2)
67
67
  request_store (~> 1.0)
68
68
  nokogiri (1.13.3-x86_64-darwin)
@@ -95,4 +95,4 @@ DEPENDENCIES
95
95
  sqlite3 (~> 1.4)
96
96
 
97
97
  BUNDLED WITH
98
- 2.3.7
98
+ 2.3.10
data/README.md CHANGED
@@ -77,7 +77,15 @@ This is done through the `Mobility::Backends::ActionText::Translation` model ext
77
77
 
78
78
  ## Development
79
79
 
80
- After checking out the repo, run `bundle install` to install dependencies. Then, run `cd test_app && bundle exec rails test` to run the tests.
80
+ After checking out the repo, run `bundle install` to install dependencies.
81
+
82
+ Execute tests by running:
83
+
84
+ ```sh
85
+ cd test_app
86
+ bundle install
87
+ bundle exec rails test
88
+ ```
81
89
 
82
90
  To release a new version, update `lib/mobility/action_text/version.rb` and `CHANGELOG.md`, run `bundle && cd test_app && bundle`, commit, then run `bundle exec rake release`. This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
91
 
@@ -88,4 +96,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/sedubo
88
96
  ## License
89
97
 
90
98
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
91
-
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mobility
4
4
  module ActionText
5
- VERSION = '0.6.0'
5
+ VERSION = '1.1.1'
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
 
@@ -77,6 +83,12 @@ module Mobility
77
83
  has_one :"rich_text_#{name}", -> { where(name: name, locale: Mobility.locale) },
78
84
  class_name: 'Mobility::Backends::ActionText::RichTextTranslation',
79
85
  as: :record, inverse_of: :record, autosave: true, dependent: :destroy
86
+ Mobility.available_locales.each do |locale|
87
+ has_one :"rich_text_#{name}_#{locale.to_s.underscore}",
88
+ -> { where(name: name, locale: locale) },
89
+ class_name: 'Mobility::Backends::ActionText::RichTextTranslation',
90
+ as: :record, inverse_of: :record, autosave: true, dependent: :destroy
91
+ end
80
92
  scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") }
81
93
  scope :"with_rich_text_#{name}_and_embeds",
82
94
  -> { includes("rich_text_#{name}": { embeds_attachments: :blob }) }
@@ -15,7 +15,9 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
  spec.metadata['source_code_uri'] = 'https://github.com/sedubois/mobility-actiontext'
18
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/sedubois/mobility-actiontext/issues'
18
19
  spec.metadata['changelog_uri'] = 'https://github.com/sedubois/mobility-actiontext/blob/main/CHANGELOG.md'
20
+ spec.metadata['rubygems_mfa_required'] = 'true'
19
21
 
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
data/test_app/Gemfile CHANGED
@@ -31,7 +31,7 @@ group :development do
31
31
  gem 'web-console', '>= 4.1.0'
32
32
  # Display performance information such as SQL time and flame graphs for each request in your browser.
33
33
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
34
- gem 'rack-mini-profiler', '~> 2.0'
34
+ gem 'rack-mini-profiler'
35
35
  gem 'listen', '~> 3.3'
36
36
  end
37
37
 
@@ -1,74 +1,74 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- mobility-actiontext (0.6.0)
4
+ mobility-actiontext (1.1.1)
5
5
  actiontext (>= 6.0)
6
6
  mobility (~> 1.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.2.2)
12
- actionpack (= 7.0.2.2)
13
- activesupport (= 7.0.2.2)
11
+ actioncable (7.0.2.3)
12
+ actionpack (= 7.0.2.3)
13
+ activesupport (= 7.0.2.3)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.2.2)
17
- actionpack (= 7.0.2.2)
18
- activejob (= 7.0.2.2)
19
- activerecord (= 7.0.2.2)
20
- activestorage (= 7.0.2.2)
21
- activesupport (= 7.0.2.2)
16
+ actionmailbox (7.0.2.3)
17
+ actionpack (= 7.0.2.3)
18
+ activejob (= 7.0.2.3)
19
+ activerecord (= 7.0.2.3)
20
+ activestorage (= 7.0.2.3)
21
+ activesupport (= 7.0.2.3)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.0.2.2)
27
- actionpack (= 7.0.2.2)
28
- actionview (= 7.0.2.2)
29
- activejob (= 7.0.2.2)
30
- activesupport (= 7.0.2.2)
26
+ actionmailer (7.0.2.3)
27
+ actionpack (= 7.0.2.3)
28
+ actionview (= 7.0.2.3)
29
+ activejob (= 7.0.2.3)
30
+ activesupport (= 7.0.2.3)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.2.2)
37
- actionview (= 7.0.2.2)
38
- activesupport (= 7.0.2.2)
36
+ actionpack (7.0.2.3)
37
+ actionview (= 7.0.2.3)
38
+ activesupport (= 7.0.2.3)
39
39
  rack (~> 2.0, >= 2.2.0)
40
40
  rack-test (>= 0.6.3)
41
41
  rails-dom-testing (~> 2.0)
42
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.2.2)
44
- actionpack (= 7.0.2.2)
45
- activerecord (= 7.0.2.2)
46
- activestorage (= 7.0.2.2)
47
- activesupport (= 7.0.2.2)
43
+ actiontext (7.0.2.3)
44
+ actionpack (= 7.0.2.3)
45
+ activerecord (= 7.0.2.3)
46
+ activestorage (= 7.0.2.3)
47
+ activesupport (= 7.0.2.3)
48
48
  globalid (>= 0.6.0)
49
49
  nokogiri (>= 1.8.5)
50
- actionview (7.0.2.2)
51
- activesupport (= 7.0.2.2)
50
+ actionview (7.0.2.3)
51
+ activesupport (= 7.0.2.3)
52
52
  builder (~> 3.1)
53
53
  erubi (~> 1.4)
54
54
  rails-dom-testing (~> 2.0)
55
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.2.2)
57
- activesupport (= 7.0.2.2)
56
+ activejob (7.0.2.3)
57
+ activesupport (= 7.0.2.3)
58
58
  globalid (>= 0.3.6)
59
- activemodel (7.0.2.2)
60
- activesupport (= 7.0.2.2)
61
- activerecord (7.0.2.2)
62
- activemodel (= 7.0.2.2)
63
- activesupport (= 7.0.2.2)
64
- activestorage (7.0.2.2)
65
- actionpack (= 7.0.2.2)
66
- activejob (= 7.0.2.2)
67
- activerecord (= 7.0.2.2)
68
- activesupport (= 7.0.2.2)
59
+ activemodel (7.0.2.3)
60
+ activesupport (= 7.0.2.3)
61
+ activerecord (7.0.2.3)
62
+ activemodel (= 7.0.2.3)
63
+ activesupport (= 7.0.2.3)
64
+ activestorage (7.0.2.3)
65
+ actionpack (= 7.0.2.3)
66
+ activejob (= 7.0.2.3)
67
+ activerecord (= 7.0.2.3)
68
+ activesupport (= 7.0.2.3)
69
69
  marcel (~> 1.0)
70
70
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.2.2)
71
+ activesupport (7.0.2.3)
72
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
73
  i18n (>= 1.6, < 2)
74
74
  minitest (>= 5.1)
@@ -76,7 +76,7 @@ GEM
76
76
  bindex (0.8.1)
77
77
  builder (3.2.4)
78
78
  byebug (11.1.3)
79
- concurrent-ruby (1.1.9)
79
+ concurrent-ruby (1.1.10)
80
80
  crass (1.0.6)
81
81
  digest (3.1.0)
82
82
  erubi (1.10.0)
@@ -85,14 +85,13 @@ GEM
85
85
  activesupport (>= 5.0)
86
86
  i18n (1.10.0)
87
87
  concurrent-ruby (~> 1.0)
88
- io-wait (0.2.1)
89
88
  jbuilder (2.11.5)
90
89
  actionview (>= 5.0.0)
91
90
  activesupport (>= 5.0.0)
92
91
  listen (3.7.1)
93
92
  rb-fsevent (~> 0.10, >= 0.10.3)
94
93
  rb-inotify (~> 0.9, >= 0.9.10)
95
- loofah (2.14.0)
94
+ loofah (2.16.0)
96
95
  crass (~> 1.0.2)
97
96
  nokogiri (>= 1.5.9)
98
97
  mail (2.7.1)
@@ -101,7 +100,7 @@ GEM
101
100
  method_source (1.0.0)
102
101
  mini_mime (1.1.2)
103
102
  minitest (5.15.0)
104
- mobility (1.2.5)
103
+ mobility (1.2.6)
105
104
  i18n (>= 0.6.10, < 2)
106
105
  request_store (~> 1.0)
107
106
  net-imap (0.2.3)
@@ -112,8 +111,7 @@ GEM
112
111
  digest
113
112
  net-protocol
114
113
  timeout
115
- net-protocol (0.1.2)
116
- io-wait
114
+ net-protocol (0.1.3)
117
115
  timeout
118
116
  net-smtp (0.3.1)
119
117
  digest
@@ -124,36 +122,36 @@ GEM
124
122
  racc (~> 1.4)
125
123
  nokogiri (1.13.3-x86_64-linux)
126
124
  racc (~> 1.4)
127
- puma (5.6.2)
125
+ puma (5.6.4)
128
126
  nio4r (~> 2.0)
129
127
  racc (1.6.0)
130
128
  rack (2.2.3)
131
- rack-mini-profiler (2.3.4)
129
+ rack-mini-profiler (3.0.0)
132
130
  rack (>= 1.2.0)
133
131
  rack-test (1.1.0)
134
132
  rack (>= 1.0, < 3)
135
- rails (7.0.2.2)
136
- actioncable (= 7.0.2.2)
137
- actionmailbox (= 7.0.2.2)
138
- actionmailer (= 7.0.2.2)
139
- actionpack (= 7.0.2.2)
140
- actiontext (= 7.0.2.2)
141
- actionview (= 7.0.2.2)
142
- activejob (= 7.0.2.2)
143
- activemodel (= 7.0.2.2)
144
- activerecord (= 7.0.2.2)
145
- activestorage (= 7.0.2.2)
146
- activesupport (= 7.0.2.2)
133
+ rails (7.0.2.3)
134
+ actioncable (= 7.0.2.3)
135
+ actionmailbox (= 7.0.2.3)
136
+ actionmailer (= 7.0.2.3)
137
+ actionpack (= 7.0.2.3)
138
+ actiontext (= 7.0.2.3)
139
+ actionview (= 7.0.2.3)
140
+ activejob (= 7.0.2.3)
141
+ activemodel (= 7.0.2.3)
142
+ activerecord (= 7.0.2.3)
143
+ activestorage (= 7.0.2.3)
144
+ activesupport (= 7.0.2.3)
147
145
  bundler (>= 1.15.0)
148
- railties (= 7.0.2.2)
146
+ railties (= 7.0.2.3)
149
147
  rails-dom-testing (2.0.3)
150
148
  activesupport (>= 4.2.0)
151
149
  nokogiri (>= 1.6)
152
150
  rails-html-sanitizer (1.4.2)
153
151
  loofah (~> 2.3)
154
- railties (7.0.2.2)
155
- actionpack (= 7.0.2.2)
156
- activesupport (= 7.0.2.2)
152
+ railties (7.0.2.3)
153
+ actionpack (= 7.0.2.3)
154
+ activesupport (= 7.0.2.3)
157
155
  method_source
158
156
  rake (>= 12.2)
159
157
  thor (~> 1.0)
@@ -174,7 +172,7 @@ GEM
174
172
  sprockets (> 3.0)
175
173
  sprockets-rails
176
174
  tilt
177
- sprockets (4.0.2)
175
+ sprockets (4.0.3)
178
176
  concurrent-ruby (~> 1.0)
179
177
  rack (> 1, < 3)
180
178
  sprockets-rails (3.4.2)
@@ -212,7 +210,7 @@ DEPENDENCIES
212
210
  mobility (~> 1.2)
213
211
  mobility-actiontext!
214
212
  puma (~> 5.0)
215
- rack-mini-profiler (~> 2.0)
213
+ rack-mini-profiler
216
214
  rails (~> 7.0.0)
217
215
  sass-rails (>= 6)
218
216
  sqlite3 (~> 1.4)
@@ -224,4 +222,4 @@ RUBY VERSION
224
222
  ruby 3.1.1p18
225
223
 
226
224
  BUNDLED WITH
227
- 2.3.7
225
+ 2.3.10
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Rails.application.config.i18n.available_locales = %i[en fr]
3
+ Rails.application.config.i18n.available_locales = %i[en fr fr-CA]
@@ -22,6 +22,12 @@ post_one_content_fr:
22
22
  locale: fr
23
23
  body: <h1>Bonjour le monde !</h1>
24
24
 
25
+ post_one_content_fr_ca:
26
+ record: one (Post)
27
+ name: content
28
+ locale: fr-CA
29
+ body: <h1>Allo le monde !</h1>
30
+
25
31
  post_one_non_i18n_content:
26
32
  record: one (Post)
27
33
  name: non_i18n_content
@@ -34,10 +34,10 @@ module Mobility
34
34
  assert_equal 2, post.plain_text_translations.count
35
35
  end
36
36
 
37
- test 'post has two rich text translations' do
37
+ test 'post has three rich text translations' do
38
38
  post = posts(:one)
39
39
 
40
- assert_equal 2, post.rich_text_translations.count
40
+ assert_equal 3, post.rich_text_translations.count
41
41
  end
42
42
 
43
43
  test 'post has plain text title' do
@@ -46,7 +46,7 @@ module Mobility
46
46
  assert_equal 'Post Title', post.title
47
47
  end
48
48
 
49
- test 'post has rich text content' do
49
+ test 'post has rich text content association' do
50
50
  post = posts(:one)
51
51
 
52
52
  assert_instance_of Mobility::Backends::ActionText::RichTextTranslation, post.rich_text_content
@@ -57,6 +57,34 @@ module Mobility
57
57
  HTML
58
58
  end
59
59
 
60
+ test 'post has rich text content associations for each locale' do
61
+ post = posts(:one)
62
+
63
+ assert_instance_of Mobility::Backends::ActionText::RichTextTranslation,
64
+ post.rich_text_content_en
65
+ assert_equal <<~HTML, post.rich_text_content_en.to_s
66
+ <div class="trix-content">
67
+ <h1>Hello world!</h1>
68
+ </div>
69
+ HTML
70
+
71
+ assert_instance_of Mobility::Backends::ActionText::RichTextTranslation,
72
+ post.rich_text_content_fr
73
+ assert_equal <<~HTML, post.rich_text_content_fr.to_s
74
+ <div class="trix-content">
75
+ <h1>Bonjour le monde !</h1>
76
+ </div>
77
+ HTML
78
+
79
+ assert_instance_of Mobility::Backends::ActionText::RichTextTranslation,
80
+ post.rich_text_content_fr_ca
81
+ assert_equal <<~HTML, post.rich_text_content_fr_ca.to_s
82
+ <div class="trix-content">
83
+ <h1>Allo le monde !</h1>
84
+ </div>
85
+ HTML
86
+ end
87
+
60
88
  test 'post has different content in different languages' do
61
89
  post = posts(:one)
62
90
 
@@ -100,11 +128,15 @@ module Mobility
100
128
 
101
129
  assert_no_queries do
102
130
  assert_equal 'Hello world!', post.content.to_plain_text
103
-
104
- skip('FIXME: this should execute no queries')
105
131
  end
106
132
  end
107
133
 
134
+ test 'correct translation is returned if single translation for different locale was eager loaded' do
135
+ post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_rich_text_content.last } }
136
+
137
+ assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
138
+ end
139
+
108
140
  test 'post content is eager loaded with all rich text' do
109
141
  post = assert_queries(2) { Post.with_all_rich_text.last }
110
142
 
@@ -113,6 +145,12 @@ module Mobility
113
145
  end
114
146
  end
115
147
 
148
+ test 'correct translation is returned if all translations for different locale were eager loaded' do
149
+ post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_all_rich_text.last } }
150
+
151
+ assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
152
+ end
153
+
116
154
  test 'post non_i18n_content is eager loaded with all rich text' do
117
155
  post = assert_queries(2) { Post.with_all_rich_text.last }
118
156
 
@@ -122,7 +160,7 @@ module Mobility
122
160
  end
123
161
 
124
162
  test 'post is being destroyed' do
125
- assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -5 do
163
+ assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -6 do
126
164
  assert posts(:one).destroy
127
165
  end
128
166
  end
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.1.1
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-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actiontext
@@ -138,7 +138,9 @@ licenses:
138
138
  metadata:
139
139
  homepage_uri: https://github.com/sedubois/mobility-actiontext
140
140
  source_code_uri: https://github.com/sedubois/mobility-actiontext
141
+ bug_tracker_uri: https://github.com/sedubois/mobility-actiontext/issues
141
142
  changelog_uri: https://github.com/sedubois/mobility-actiontext/blob/main/CHANGELOG.md
143
+ rubygems_mfa_required: 'true'
142
144
  post_install_message:
143
145
  rdoc_options: []
144
146
  require_paths: