mobility-actiontext 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +33 -81
- data/README.md +1 -1
- data/lib/mobility/action_text/version.rb +1 -1
- data/lib/mobility/backends/action_text.rb +18 -2
- data/mobility-actiontext.gemspec +1 -1
- data/test_app/Gemfile +2 -2
- data/test_app/Gemfile.lock +104 -78
- data/test_app/app/models/post.rb +2 -0
- data/test_app/db/migrate/20210114124951_translate_rich_texts.rb +1 -1
- data/test_app/db/schema.rb +1 -1
- data/test_app/test/fixtures/action_text/rich_texts.yml +5 -0
- data/test_app/test/mobility_action_text_test.rb +29 -3
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d1047f391d3c0dde02a646adc682b3a09f1e99a2e4beb04c7ba3b971a41e0d
|
4
|
+
data.tar.gz: a49bf73b5b911d02a71eacc5f84f9f18ed91865befb9b2872a29025bb7be6813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56786adb17b842818b65b6de35403a987c8b49dc570c4a00a367995160590c58f284374e74c391bc6aee37d05b2c1cf081aee878ce83232d877daeba86292ed6
|
7
|
+
data.tar.gz: e82e781d93cd99fce6bb5e85fff45334b39cedc50a6772476a4fa22ed1319f0beabf9c20df1b319fe514f6e70743dff9880dcdac5814bbfc2c460bb32886843a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.1.1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
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
|
+
|
8
|
+
### 0.6.0 (2022-02-27)
|
9
|
+
- Include all translations on eager load using `with_all_rich_text` ([#23](https://github.com/sedubois/mobility-actiontext/pull/23)).
|
10
|
+
|
11
|
+
### 0.5.0 (2022-02-13)
|
12
|
+
- Require only actiontext in gemspec dependencies ([#20](https://github.com/sedubois/mobility-actiontext/pull/20)).
|
13
|
+
|
3
14
|
### 0.4.0 (2021-12-20)
|
4
15
|
- Add Rails 7 compatibility.
|
5
16
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,68 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mobility-actiontext (0.
|
4
|
+
mobility-actiontext (1.0.0)
|
5
|
+
actiontext (>= 6.0)
|
5
6
|
mobility (~> 1.2)
|
6
|
-
rails (>= 6.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
activesupport (= 7.0.
|
14
|
-
nio4r (~> 2.0)
|
15
|
-
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (7.0.0)
|
17
|
-
actionpack (= 7.0.0)
|
18
|
-
activejob (= 7.0.0)
|
19
|
-
activerecord (= 7.0.0)
|
20
|
-
activestorage (= 7.0.0)
|
21
|
-
activesupport (= 7.0.0)
|
22
|
-
mail (>= 2.7.1)
|
23
|
-
actionmailer (7.0.0)
|
24
|
-
actionpack (= 7.0.0)
|
25
|
-
actionview (= 7.0.0)
|
26
|
-
activejob (= 7.0.0)
|
27
|
-
activesupport (= 7.0.0)
|
28
|
-
mail (~> 2.5, >= 2.5.4)
|
29
|
-
rails-dom-testing (~> 2.0)
|
30
|
-
actionpack (7.0.0)
|
31
|
-
actionview (= 7.0.0)
|
32
|
-
activesupport (= 7.0.0)
|
11
|
+
actionpack (7.0.2.2)
|
12
|
+
actionview (= 7.0.2.2)
|
13
|
+
activesupport (= 7.0.2.2)
|
33
14
|
rack (~> 2.0, >= 2.2.0)
|
34
15
|
rack-test (>= 0.6.3)
|
35
16
|
rails-dom-testing (~> 2.0)
|
36
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
-
actiontext (7.0.
|
38
|
-
actionpack (= 7.0.
|
39
|
-
activerecord (= 7.0.
|
40
|
-
activestorage (= 7.0.
|
41
|
-
activesupport (= 7.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)
|
42
23
|
globalid (>= 0.6.0)
|
43
24
|
nokogiri (>= 1.8.5)
|
44
|
-
actionview (7.0.
|
45
|
-
activesupport (= 7.0.
|
25
|
+
actionview (7.0.2.2)
|
26
|
+
activesupport (= 7.0.2.2)
|
46
27
|
builder (~> 3.1)
|
47
28
|
erubi (~> 1.4)
|
48
29
|
rails-dom-testing (~> 2.0)
|
49
30
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
50
|
-
activejob (7.0.
|
51
|
-
activesupport (= 7.0.
|
31
|
+
activejob (7.0.2.2)
|
32
|
+
activesupport (= 7.0.2.2)
|
52
33
|
globalid (>= 0.3.6)
|
53
|
-
activemodel (7.0.
|
54
|
-
activesupport (= 7.0.
|
55
|
-
activerecord (7.0.
|
56
|
-
activemodel (= 7.0.
|
57
|
-
activesupport (= 7.0.
|
58
|
-
activestorage (7.0.
|
59
|
-
actionpack (= 7.0.
|
60
|
-
activejob (= 7.0.
|
61
|
-
activerecord (= 7.0.
|
62
|
-
activesupport (= 7.0.
|
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)
|
63
44
|
marcel (~> 1.0)
|
64
45
|
mini_mime (>= 1.1.0)
|
65
|
-
activesupport (7.0.
|
46
|
+
activesupport (7.0.2.2)
|
66
47
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
67
48
|
i18n (>= 1.6, < 2)
|
68
49
|
minitest (>= 5.1)
|
@@ -73,74 +54,45 @@ GEM
|
|
73
54
|
erubi (1.10.0)
|
74
55
|
globalid (1.0.0)
|
75
56
|
activesupport (>= 5.0)
|
76
|
-
i18n (1.
|
57
|
+
i18n (1.10.0)
|
77
58
|
concurrent-ruby (~> 1.0)
|
78
|
-
loofah (2.
|
59
|
+
loofah (2.14.0)
|
79
60
|
crass (~> 1.0.2)
|
80
61
|
nokogiri (>= 1.5.9)
|
81
|
-
mail (2.7.1)
|
82
|
-
mini_mime (>= 0.1.1)
|
83
62
|
marcel (1.0.2)
|
84
|
-
method_source (1.0.0)
|
85
63
|
mini_mime (1.1.2)
|
86
64
|
minitest (5.15.0)
|
87
65
|
mobility (1.2.5)
|
88
66
|
i18n (>= 0.6.10, < 2)
|
89
67
|
request_store (~> 1.0)
|
90
|
-
|
91
|
-
nokogiri (1.12.5-x86_64-darwin)
|
68
|
+
nokogiri (1.13.3-x86_64-darwin)
|
92
69
|
racc (~> 1.4)
|
93
|
-
nokogiri (1.
|
70
|
+
nokogiri (1.13.3-x86_64-linux)
|
94
71
|
racc (~> 1.4)
|
95
72
|
racc (1.6.0)
|
96
73
|
rack (2.2.3)
|
97
74
|
rack-test (1.1.0)
|
98
75
|
rack (>= 1.0, < 3)
|
99
|
-
rails (7.0.0)
|
100
|
-
actioncable (= 7.0.0)
|
101
|
-
actionmailbox (= 7.0.0)
|
102
|
-
actionmailer (= 7.0.0)
|
103
|
-
actionpack (= 7.0.0)
|
104
|
-
actiontext (= 7.0.0)
|
105
|
-
actionview (= 7.0.0)
|
106
|
-
activejob (= 7.0.0)
|
107
|
-
activemodel (= 7.0.0)
|
108
|
-
activerecord (= 7.0.0)
|
109
|
-
activestorage (= 7.0.0)
|
110
|
-
activesupport (= 7.0.0)
|
111
|
-
bundler (>= 1.15.0)
|
112
|
-
railties (= 7.0.0)
|
113
76
|
rails-dom-testing (2.0.3)
|
114
77
|
activesupport (>= 4.2.0)
|
115
78
|
nokogiri (>= 1.6)
|
116
79
|
rails-html-sanitizer (1.4.2)
|
117
80
|
loofah (~> 2.3)
|
118
|
-
railties (7.0.0)
|
119
|
-
actionpack (= 7.0.0)
|
120
|
-
activesupport (= 7.0.0)
|
121
|
-
method_source
|
122
|
-
rake (>= 12.2)
|
123
|
-
thor (~> 1.0)
|
124
|
-
zeitwerk (~> 2.5)
|
125
81
|
rake (13.0.6)
|
126
|
-
request_store (1.5.
|
82
|
+
request_store (1.5.1)
|
127
83
|
rack (>= 1.4)
|
128
84
|
sqlite3 (1.4.2)
|
129
|
-
thor (1.1.0)
|
130
85
|
tzinfo (2.0.4)
|
131
86
|
concurrent-ruby (~> 1.0)
|
132
|
-
websocket-driver (0.7.5)
|
133
|
-
websocket-extensions (>= 0.1.0)
|
134
|
-
websocket-extensions (0.1.5)
|
135
|
-
zeitwerk (2.5.1)
|
136
87
|
|
137
88
|
PLATFORMS
|
138
|
-
x86_64-darwin
|
89
|
+
x86_64-darwin
|
139
90
|
x86_64-linux
|
140
91
|
|
141
92
|
DEPENDENCIES
|
142
93
|
mobility-actiontext!
|
94
|
+
rake (~> 13.0)
|
143
95
|
sqlite3 (~> 1.4)
|
144
96
|
|
145
97
|
BUNDLED WITH
|
146
|
-
2.
|
98
|
+
2.3.7
|
data/README.md
CHANGED
@@ -79,7 +79,7 @@ This is done through the `Mobility::Backends::ActionText::Translation` model ext
|
|
79
79
|
|
80
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.
|
81
81
|
|
82
|
-
To release a new version, update `lib/mobility/action_text/version.rb` and `CHANGELOG.md`, run `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).
|
82
|
+
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
83
|
|
84
84
|
## Contributing
|
85
85
|
|
@@ -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
|
|
@@ -70,7 +76,9 @@ module Mobility
|
|
70
76
|
end
|
71
77
|
end
|
72
78
|
|
73
|
-
setup do |attributes,
|
79
|
+
setup do |attributes, options|
|
80
|
+
next if options[:plain]
|
81
|
+
|
74
82
|
attributes.each do |name|
|
75
83
|
has_one :"rich_text_#{name}", -> { where(name: name, locale: Mobility.locale) },
|
76
84
|
class_name: 'Mobility::Backends::ActionText::RichTextTranslation',
|
@@ -78,7 +86,15 @@ module Mobility
|
|
78
86
|
scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") }
|
79
87
|
scope :"with_rich_text_#{name}_and_embeds",
|
80
88
|
-> { includes("rich_text_#{name}": { embeds_attachments: :blob }) }
|
81
|
-
end
|
89
|
+
end
|
90
|
+
|
91
|
+
singleton_class.prepend(WithAllRichText) unless singleton_class < WithAllRichText
|
92
|
+
end
|
93
|
+
|
94
|
+
module WithAllRichText
|
95
|
+
def with_all_rich_text
|
96
|
+
super.eager_load(:rich_text_translations)
|
97
|
+
end
|
82
98
|
end
|
83
99
|
|
84
100
|
module ActionTextValidations
|
data/mobility-actiontext.gemspec
CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
+
spec.add_dependency 'actiontext', '>= 6.0'
|
29
30
|
spec.add_dependency 'mobility', '~> 1.2'
|
30
|
-
spec.add_dependency 'rails', '>= 6.0'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'sqlite3', '~> 1.4'
|
33
33
|
end
|
data/test_app/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
|
-
ruby '3.
|
4
|
+
ruby '3.1.1'
|
5
5
|
|
6
6
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
-
gem 'rails', '~>
|
7
|
+
gem 'rails', '~> 7.0.0'
|
8
8
|
# Use sqlite3 as the database for Active Record
|
9
9
|
gem 'sqlite3', '~> 1.4'
|
10
10
|
# Use Puma as the app server
|
data/test_app/Gemfile.lock
CHANGED
@@ -1,89 +1,98 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
mobility-actiontext (0.
|
4
|
+
mobility-actiontext (1.0.0)
|
5
|
+
actiontext (>= 6.0)
|
5
6
|
mobility (~> 1.2)
|
6
|
-
rails (>= 6.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (
|
12
|
-
actionpack (=
|
13
|
-
activesupport (=
|
11
|
+
actioncable (7.0.2.2)
|
12
|
+
actionpack (= 7.0.2.2)
|
13
|
+
activesupport (= 7.0.2.2)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (
|
17
|
-
actionpack (=
|
18
|
-
activejob (=
|
19
|
-
activerecord (=
|
20
|
-
activestorage (=
|
21
|
-
activesupport (=
|
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)
|
22
22
|
mail (>= 2.7.1)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
net-imap
|
24
|
+
net-pop
|
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)
|
28
31
|
mail (~> 2.5, >= 2.5.4)
|
32
|
+
net-imap
|
33
|
+
net-pop
|
34
|
+
net-smtp
|
29
35
|
rails-dom-testing (~> 2.0)
|
30
|
-
actionpack (
|
31
|
-
actionview (=
|
32
|
-
activesupport (=
|
33
|
-
rack (~> 2.0, >= 2.0
|
36
|
+
actionpack (7.0.2.2)
|
37
|
+
actionview (= 7.0.2.2)
|
38
|
+
activesupport (= 7.0.2.2)
|
39
|
+
rack (~> 2.0, >= 2.2.0)
|
34
40
|
rack-test (>= 0.6.3)
|
35
41
|
rails-dom-testing (~> 2.0)
|
36
42
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
-
actiontext (
|
38
|
-
actionpack (=
|
39
|
-
activerecord (=
|
40
|
-
activestorage (=
|
41
|
-
activesupport (=
|
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)
|
48
|
+
globalid (>= 0.6.0)
|
42
49
|
nokogiri (>= 1.8.5)
|
43
|
-
actionview (
|
44
|
-
activesupport (=
|
50
|
+
actionview (7.0.2.2)
|
51
|
+
activesupport (= 7.0.2.2)
|
45
52
|
builder (~> 3.1)
|
46
53
|
erubi (~> 1.4)
|
47
54
|
rails-dom-testing (~> 2.0)
|
48
55
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
-
activejob (
|
50
|
-
activesupport (=
|
56
|
+
activejob (7.0.2.2)
|
57
|
+
activesupport (= 7.0.2.2)
|
51
58
|
globalid (>= 0.3.6)
|
52
|
-
activemodel (
|
53
|
-
activesupport (=
|
54
|
-
activerecord (
|
55
|
-
activemodel (=
|
56
|
-
activesupport (=
|
57
|
-
activestorage (
|
58
|
-
actionpack (=
|
59
|
-
activejob (=
|
60
|
-
activerecord (=
|
61
|
-
activesupport (=
|
62
|
-
marcel (~> 1.0
|
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)
|
69
|
+
marcel (~> 1.0)
|
63
70
|
mini_mime (>= 1.1.0)
|
64
|
-
activesupport (
|
71
|
+
activesupport (7.0.2.2)
|
65
72
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
73
|
i18n (>= 1.6, < 2)
|
67
74
|
minitest (>= 5.1)
|
68
75
|
tzinfo (~> 2.0)
|
69
|
-
zeitwerk (~> 2.3)
|
70
76
|
bindex (0.8.1)
|
71
77
|
builder (3.2.4)
|
72
78
|
byebug (11.1.3)
|
73
79
|
concurrent-ruby (1.1.9)
|
74
80
|
crass (1.0.6)
|
81
|
+
digest (3.1.0)
|
75
82
|
erubi (1.10.0)
|
76
|
-
ffi (1.15.
|
83
|
+
ffi (1.15.5)
|
77
84
|
globalid (1.0.0)
|
78
85
|
activesupport (>= 5.0)
|
79
|
-
i18n (1.
|
86
|
+
i18n (1.10.0)
|
80
87
|
concurrent-ruby (~> 1.0)
|
81
|
-
|
88
|
+
io-wait (0.2.1)
|
89
|
+
jbuilder (2.11.5)
|
90
|
+
actionview (>= 5.0.0)
|
82
91
|
activesupport (>= 5.0.0)
|
83
|
-
listen (3.7.
|
92
|
+
listen (3.7.1)
|
84
93
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
85
94
|
rb-inotify (~> 0.9, >= 0.9.10)
|
86
|
-
loofah (2.
|
95
|
+
loofah (2.14.0)
|
87
96
|
crass (~> 1.0.2)
|
88
97
|
nokogiri (>= 1.5.9)
|
89
98
|
mail (2.7.1)
|
@@ -91,54 +100,69 @@ GEM
|
|
91
100
|
marcel (1.0.2)
|
92
101
|
method_source (1.0.0)
|
93
102
|
mini_mime (1.1.2)
|
94
|
-
minitest (5.
|
103
|
+
minitest (5.15.0)
|
95
104
|
mobility (1.2.5)
|
96
105
|
i18n (>= 0.6.10, < 2)
|
97
106
|
request_store (~> 1.0)
|
107
|
+
net-imap (0.2.3)
|
108
|
+
digest
|
109
|
+
net-protocol
|
110
|
+
strscan
|
111
|
+
net-pop (0.1.1)
|
112
|
+
digest
|
113
|
+
net-protocol
|
114
|
+
timeout
|
115
|
+
net-protocol (0.1.2)
|
116
|
+
io-wait
|
117
|
+
timeout
|
118
|
+
net-smtp (0.3.1)
|
119
|
+
digest
|
120
|
+
net-protocol
|
121
|
+
timeout
|
98
122
|
nio4r (2.5.8)
|
99
|
-
nokogiri (1.
|
123
|
+
nokogiri (1.13.3-x86_64-darwin)
|
100
124
|
racc (~> 1.4)
|
101
|
-
nokogiri (1.
|
125
|
+
nokogiri (1.13.3-x86_64-linux)
|
102
126
|
racc (~> 1.4)
|
103
|
-
puma (5.
|
127
|
+
puma (5.6.2)
|
104
128
|
nio4r (~> 2.0)
|
105
129
|
racc (1.6.0)
|
106
130
|
rack (2.2.3)
|
107
|
-
rack-mini-profiler (2.3.
|
131
|
+
rack-mini-profiler (2.3.4)
|
108
132
|
rack (>= 1.2.0)
|
109
133
|
rack-test (1.1.0)
|
110
134
|
rack (>= 1.0, < 3)
|
111
|
-
rails (
|
112
|
-
actioncable (=
|
113
|
-
actionmailbox (=
|
114
|
-
actionmailer (=
|
115
|
-
actionpack (=
|
116
|
-
actiontext (=
|
117
|
-
actionview (=
|
118
|
-
activejob (=
|
119
|
-
activemodel (=
|
120
|
-
activerecord (=
|
121
|
-
activestorage (=
|
122
|
-
activesupport (=
|
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)
|
123
147
|
bundler (>= 1.15.0)
|
124
|
-
railties (=
|
125
|
-
sprockets-rails (>= 2.0.0)
|
148
|
+
railties (= 7.0.2.2)
|
126
149
|
rails-dom-testing (2.0.3)
|
127
150
|
activesupport (>= 4.2.0)
|
128
151
|
nokogiri (>= 1.6)
|
129
152
|
rails-html-sanitizer (1.4.2)
|
130
153
|
loofah (~> 2.3)
|
131
|
-
railties (
|
132
|
-
actionpack (=
|
133
|
-
activesupport (=
|
154
|
+
railties (7.0.2.2)
|
155
|
+
actionpack (= 7.0.2.2)
|
156
|
+
activesupport (= 7.0.2.2)
|
134
157
|
method_source
|
135
|
-
rake (>=
|
158
|
+
rake (>= 12.2)
|
136
159
|
thor (~> 1.0)
|
160
|
+
zeitwerk (~> 2.5)
|
137
161
|
rake (13.0.6)
|
138
|
-
rb-fsevent (0.11.
|
162
|
+
rb-fsevent (0.11.1)
|
139
163
|
rb-inotify (0.10.1)
|
140
164
|
ffi (~> 1.0)
|
141
|
-
request_store (1.5.
|
165
|
+
request_store (1.5.1)
|
142
166
|
rack (>= 1.4)
|
143
167
|
sass-rails (6.0.0)
|
144
168
|
sassc-rails (~> 2.1, >= 2.1.1)
|
@@ -158,8 +182,10 @@ GEM
|
|
158
182
|
activesupport (>= 5.2)
|
159
183
|
sprockets (>= 3.0.0)
|
160
184
|
sqlite3 (1.4.2)
|
161
|
-
|
185
|
+
strscan (3.0.1)
|
186
|
+
thor (1.2.1)
|
162
187
|
tilt (2.0.10)
|
188
|
+
timeout (0.2.0)
|
163
189
|
turbolinks (5.2.1)
|
164
190
|
turbolinks-source (~> 5.2)
|
165
191
|
turbolinks-source (5.2.0)
|
@@ -173,10 +199,10 @@ GEM
|
|
173
199
|
websocket-driver (0.7.5)
|
174
200
|
websocket-extensions (>= 0.1.0)
|
175
201
|
websocket-extensions (0.1.5)
|
176
|
-
zeitwerk (2.5.
|
202
|
+
zeitwerk (2.5.4)
|
177
203
|
|
178
204
|
PLATFORMS
|
179
|
-
x86_64-darwin
|
205
|
+
x86_64-darwin
|
180
206
|
x86_64-linux
|
181
207
|
|
182
208
|
DEPENDENCIES
|
@@ -187,7 +213,7 @@ DEPENDENCIES
|
|
187
213
|
mobility-actiontext!
|
188
214
|
puma (~> 5.0)
|
189
215
|
rack-mini-profiler (~> 2.0)
|
190
|
-
rails (~>
|
216
|
+
rails (~> 7.0.0)
|
191
217
|
sass-rails (>= 6)
|
192
218
|
sqlite3 (~> 1.4)
|
193
219
|
turbolinks (~> 5)
|
@@ -195,7 +221,7 @@ DEPENDENCIES
|
|
195
221
|
web-console (>= 4.1.0)
|
196
222
|
|
197
223
|
RUBY VERSION
|
198
|
-
ruby 3.
|
224
|
+
ruby 3.1.1p18
|
199
225
|
|
200
226
|
BUNDLED WITH
|
201
|
-
2.
|
227
|
+
2.3.7
|
data/test_app/app/models/post.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
class TranslateRichTexts < ActiveRecord::Migration[6.1]
|
4
4
|
def change
|
5
5
|
# or null: true to allow untranslated rich text
|
6
|
-
add_column :action_text_rich_texts, :locale, :string, null:
|
6
|
+
add_column :action_text_rich_texts, :locale, :string, null: true
|
7
7
|
|
8
8
|
remove_index :action_text_rich_texts,
|
9
9
|
column: %i[record_type record_id name],
|
data/test_app/db/schema.rb
CHANGED
@@ -20,7 +20,7 @@ ActiveRecord::Schema.define(version: 20_210_114_125_134) do
|
|
20
20
|
t.integer 'record_id', null: false
|
21
21
|
t.datetime 'created_at', precision: 6, null: false
|
22
22
|
t.datetime 'updated_at', precision: 6, null: false
|
23
|
-
t.string 'locale'
|
23
|
+
t.string 'locale'
|
24
24
|
t.index %w[record_type record_id name locale], name: 'index_action_text_rich_texts_uniqueness',
|
25
25
|
unique: true
|
26
26
|
end
|
@@ -22,6 +22,11 @@ post_one_content_fr:
|
|
22
22
|
locale: fr
|
23
23
|
body: <h1>Bonjour le monde !</h1>
|
24
24
|
|
25
|
+
post_one_non_i18n_content:
|
26
|
+
record: one (Post)
|
27
|
+
name: non_i18n_content
|
28
|
+
body: <h1>Hello non i18n world!</h1>
|
29
|
+
|
25
30
|
untranslated_title_en:
|
26
31
|
record: untranslated (Post)
|
27
32
|
name: title
|
@@ -95,18 +95,44 @@ module Mobility
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
test 'post content is eager loaded' do
|
98
|
+
test 'post content is eager loaded explicitly' do
|
99
99
|
post = assert_queries(2) { Post.with_rich_text_content.last }
|
100
100
|
|
101
101
|
assert_no_queries do
|
102
102
|
assert_equal 'Hello world!', post.content.to_plain_text
|
103
|
+
end
|
104
|
+
end
|
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
|
+
|
112
|
+
test 'post content is eager loaded with all rich text' do
|
113
|
+
post = assert_queries(2) { Post.with_all_rich_text.last }
|
114
|
+
|
115
|
+
assert_no_queries do
|
116
|
+
assert_equal 'Hello world!', post.content.to_plain_text
|
117
|
+
end
|
118
|
+
end
|
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 } }
|
103
122
|
|
104
|
-
|
123
|
+
assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
|
124
|
+
end
|
125
|
+
|
126
|
+
test 'post non_i18n_content is eager loaded with all rich text' do
|
127
|
+
post = assert_queries(2) { Post.with_all_rich_text.last }
|
128
|
+
|
129
|
+
assert_no_queries do
|
130
|
+
assert_equal 'Hello non i18n world!', post.non_i18n_content.to_plain_text
|
105
131
|
end
|
106
132
|
end
|
107
133
|
|
108
134
|
test 'post is being destroyed' do
|
109
|
-
assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -
|
135
|
+
assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -5 do
|
110
136
|
assert posts(:one).destroy
|
111
137
|
end
|
112
138
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility-actiontext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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:
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: actiontext
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mobility
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
157
|
+
rubygems_version: 3.3.7
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Translate Rails Action Text rich text with Mobility.
|