mobility-actiontext 0.5.0 → 1.1.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 +12 -0
- data/Gemfile.lock +31 -31
- data/README.md +10 -3
- data/lib/mobility/action_text/version.rb +1 -1
- data/lib/mobility/backends/action_text.rb +23 -2
- data/mobility-actiontext.gemspec +2 -0
- data/test_app/Gemfile +2 -2
- data/test_app/Gemfile.lock +65 -65
- 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 +48 -4
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d469e061908f44d2b12d45a5cfe0108a9b78264e14eecf677abd881d8fb29c
|
4
|
+
data.tar.gz: 22c8db7113a9b6cbfcdf2e060a6f4b639b59e8011ab5a1ae5bf1b525040f2235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1372589dbf8592c9dd66e0d28c628e16a71ef6397e878c2c9c6e38a43ff86266963cc38db8cb8a605242fbba6fd9503bfcb348c073a302edf237749490d141
|
7
|
+
data.tar.gz: c2e72b4be327237ca0aac4557fcca381cfbbe0558832f681850fa74deba72e79dfd08d4ab94f9a82136d6b05c7fcf92fe207e1bd3ec9ce38f648ad95d28fa969
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.1.
|
1
|
+
ruby-3.1.1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Mobility Action Text Changelog
|
2
2
|
|
3
|
+
### 1.1.0 (2022-03-24)
|
4
|
+
|
5
|
+
- Add rich text associations for each locale ([#25](https://github.com/sedubois/mobility-actiontext/pull/25)).
|
6
|
+
|
7
|
+
### 1.0.0 (2022-02-28)
|
8
|
+
- Fix eager loading of single translation using `with_rich_text_#{name}` ([#24](https://github.com/sedubois/mobility-actiontext/pull/24)).
|
9
|
+
|
10
|
+
The version update to 1.0.0 indicates the plugin has no more known issues.
|
11
|
+
|
12
|
+
### 0.6.0 (2022-02-27)
|
13
|
+
- Include all translations on eager load using `with_all_rich_text` ([#23](https://github.com/sedubois/mobility-actiontext/pull/23)).
|
14
|
+
|
3
15
|
### 0.5.0 (2022-02-13)
|
4
16
|
- Require only actiontext in gemspec dependencies ([#20](https://github.com/sedubois/mobility-actiontext/pull/20)).
|
5
17
|
|
data/Gemfile.lock
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mobility-actiontext (
|
4
|
+
mobility-actiontext (1.1.0)
|
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.
|
12
|
-
actionview (= 7.0.2.
|
13
|
-
activesupport (= 7.0.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.
|
19
|
-
actionpack (= 7.0.2.
|
20
|
-
activerecord (= 7.0.2.
|
21
|
-
activestorage (= 7.0.2.
|
22
|
-
activesupport (= 7.0.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.
|
26
|
-
activesupport (= 7.0.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.
|
32
|
-
activesupport (= 7.0.2.
|
31
|
+
activejob (7.0.2.3)
|
32
|
+
activesupport (= 7.0.2.3)
|
33
33
|
globalid (>= 0.3.6)
|
34
|
-
activemodel (7.0.2.
|
35
|
-
activesupport (= 7.0.2.
|
36
|
-
activerecord (7.0.2.
|
37
|
-
activemodel (= 7.0.2.
|
38
|
-
activesupport (= 7.0.2.
|
39
|
-
activestorage (7.0.2.
|
40
|
-
actionpack (= 7.0.2.
|
41
|
-
activejob (= 7.0.2.
|
42
|
-
activerecord (= 7.0.2.
|
43
|
-
activesupport (= 7.0.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.
|
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.
|
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
|
-
i18n (1.
|
57
|
+
i18n (1.10.0)
|
58
58
|
concurrent-ruby (~> 1.0)
|
59
|
-
loofah (2.
|
59
|
+
loofah (2.15.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.
|
65
|
+
mobility (1.2.6)
|
66
66
|
i18n (>= 0.6.10, < 2)
|
67
67
|
request_store (~> 1.0)
|
68
|
-
nokogiri (1.13.
|
68
|
+
nokogiri (1.13.3-x86_64-darwin)
|
69
69
|
racc (~> 1.4)
|
70
|
-
nokogiri (1.13.
|
70
|
+
nokogiri (1.13.3-x86_64-linux)
|
71
71
|
racc (~> 1.4)
|
72
72
|
racc (1.6.0)
|
73
73
|
rack (2.2.3)
|
@@ -95,4 +95,4 @@ DEPENDENCIES
|
|
95
95
|
sqlite3 (~> 1.4)
|
96
96
|
|
97
97
|
BUNDLED WITH
|
98
|
-
2.3.
|
98
|
+
2.3.10
|
data/README.md
CHANGED
@@ -77,9 +77,17 @@ 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.
|
80
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
81
81
|
|
82
|
-
|
82
|
+
Execute tests by running:
|
83
|
+
|
84
|
+
```sh
|
85
|
+
cd test_app
|
86
|
+
bundle install
|
87
|
+
bundle exec rails test
|
88
|
+
```
|
89
|
+
|
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
|
|
84
92
|
## Contributing
|
85
93
|
|
@@ -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
|
-
|
@@ -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,15 +76,30 @@ 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',
|
77
85
|
as: :record, inverse_of: :record, autosave: true, dependent: :destroy
|
86
|
+
Mobility.available_locales.each do |locale|
|
87
|
+
has_one :"rich_text_#{name}_#{locale}", -> { where(name: name, locale: locale) },
|
88
|
+
class_name: 'Mobility::Backends::ActionText::RichTextTranslation',
|
89
|
+
as: :record, inverse_of: :record, autosave: true, dependent: :destroy
|
90
|
+
end
|
78
91
|
scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") }
|
79
92
|
scope :"with_rich_text_#{name}_and_embeds",
|
80
93
|
-> { includes("rich_text_#{name}": { embeds_attachments: :blob }) }
|
81
|
-
end
|
94
|
+
end
|
95
|
+
|
96
|
+
singleton_class.prepend(WithAllRichText) unless singleton_class < WithAllRichText
|
97
|
+
end
|
98
|
+
|
99
|
+
module WithAllRichText
|
100
|
+
def with_all_rich_text
|
101
|
+
super.eager_load(:rich_text_translations)
|
102
|
+
end
|
82
103
|
end
|
83
104
|
|
84
105
|
module ActionTextValidations
|
data/mobility-actiontext.gemspec
CHANGED
@@ -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
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
|
-
ruby '3.1.
|
4
|
+
ruby '3.1.1'
|
5
5
|
|
6
6
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
7
|
gem 'rails', '~> 7.0.0'
|
@@ -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'
|
34
|
+
gem 'rack-mini-profiler'
|
35
35
|
gem 'listen', '~> 3.3'
|
36
36
|
end
|
37
37
|
|
data/test_app/Gemfile.lock
CHANGED
@@ -1,74 +1,74 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
mobility-actiontext (
|
4
|
+
mobility-actiontext (1.1.0)
|
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.
|
12
|
-
actionpack (= 7.0.2.
|
13
|
-
activesupport (= 7.0.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.
|
17
|
-
actionpack (= 7.0.2.
|
18
|
-
activejob (= 7.0.2.
|
19
|
-
activerecord (= 7.0.2.
|
20
|
-
activestorage (= 7.0.2.
|
21
|
-
activesupport (= 7.0.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.
|
27
|
-
actionpack (= 7.0.2.
|
28
|
-
actionview (= 7.0.2.
|
29
|
-
activejob (= 7.0.2.
|
30
|
-
activesupport (= 7.0.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.
|
37
|
-
actionview (= 7.0.2.
|
38
|
-
activesupport (= 7.0.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.
|
44
|
-
actionpack (= 7.0.2.
|
45
|
-
activerecord (= 7.0.2.
|
46
|
-
activestorage (= 7.0.2.
|
47
|
-
activesupport (= 7.0.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.
|
51
|
-
activesupport (= 7.0.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.
|
57
|
-
activesupport (= 7.0.2.
|
56
|
+
activejob (7.0.2.3)
|
57
|
+
activesupport (= 7.0.2.3)
|
58
58
|
globalid (>= 0.3.6)
|
59
|
-
activemodel (7.0.2.
|
60
|
-
activesupport (= 7.0.2.
|
61
|
-
activerecord (7.0.2.
|
62
|
-
activemodel (= 7.0.2.
|
63
|
-
activesupport (= 7.0.2.
|
64
|
-
activestorage (7.0.2.
|
65
|
-
actionpack (= 7.0.2.
|
66
|
-
activejob (= 7.0.2.
|
67
|
-
activerecord (= 7.0.2.
|
68
|
-
activesupport (= 7.0.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.
|
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,14 +76,14 @@ GEM
|
|
76
76
|
bindex (0.8.1)
|
77
77
|
builder (3.2.4)
|
78
78
|
byebug (11.1.3)
|
79
|
-
concurrent-ruby (1.1.
|
79
|
+
concurrent-ruby (1.1.10)
|
80
80
|
crass (1.0.6)
|
81
81
|
digest (3.1.0)
|
82
82
|
erubi (1.10.0)
|
83
83
|
ffi (1.15.5)
|
84
84
|
globalid (1.0.0)
|
85
85
|
activesupport (>= 5.0)
|
86
|
-
i18n (1.
|
86
|
+
i18n (1.10.0)
|
87
87
|
concurrent-ruby (~> 1.0)
|
88
88
|
io-wait (0.2.1)
|
89
89
|
jbuilder (2.11.5)
|
@@ -92,7 +92,7 @@ GEM
|
|
92
92
|
listen (3.7.1)
|
93
93
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
94
94
|
rb-inotify (~> 0.9, >= 0.9.10)
|
95
|
-
loofah (2.
|
95
|
+
loofah (2.15.0)
|
96
96
|
crass (~> 1.0.2)
|
97
97
|
nokogiri (>= 1.5.9)
|
98
98
|
mail (2.7.1)
|
@@ -101,7 +101,7 @@ GEM
|
|
101
101
|
method_source (1.0.0)
|
102
102
|
mini_mime (1.1.2)
|
103
103
|
minitest (5.15.0)
|
104
|
-
mobility (1.2.
|
104
|
+
mobility (1.2.6)
|
105
105
|
i18n (>= 0.6.10, < 2)
|
106
106
|
request_store (~> 1.0)
|
107
107
|
net-imap (0.2.3)
|
@@ -120,40 +120,40 @@ GEM
|
|
120
120
|
net-protocol
|
121
121
|
timeout
|
122
122
|
nio4r (2.5.8)
|
123
|
-
nokogiri (1.13.
|
123
|
+
nokogiri (1.13.3-x86_64-darwin)
|
124
124
|
racc (~> 1.4)
|
125
|
-
nokogiri (1.13.
|
125
|
+
nokogiri (1.13.3-x86_64-linux)
|
126
126
|
racc (~> 1.4)
|
127
127
|
puma (5.6.2)
|
128
128
|
nio4r (~> 2.0)
|
129
129
|
racc (1.6.0)
|
130
130
|
rack (2.2.3)
|
131
|
-
rack-mini-profiler (
|
131
|
+
rack-mini-profiler (3.0.0)
|
132
132
|
rack (>= 1.2.0)
|
133
133
|
rack-test (1.1.0)
|
134
134
|
rack (>= 1.0, < 3)
|
135
|
-
rails (7.0.2.
|
136
|
-
actioncable (= 7.0.2.
|
137
|
-
actionmailbox (= 7.0.2.
|
138
|
-
actionmailer (= 7.0.2.
|
139
|
-
actionpack (= 7.0.2.
|
140
|
-
actiontext (= 7.0.2.
|
141
|
-
actionview (= 7.0.2.
|
142
|
-
activejob (= 7.0.2.
|
143
|
-
activemodel (= 7.0.2.
|
144
|
-
activerecord (= 7.0.2.
|
145
|
-
activestorage (= 7.0.2.
|
146
|
-
activesupport (= 7.0.2.
|
135
|
+
rails (7.0.2.3)
|
136
|
+
actioncable (= 7.0.2.3)
|
137
|
+
actionmailbox (= 7.0.2.3)
|
138
|
+
actionmailer (= 7.0.2.3)
|
139
|
+
actionpack (= 7.0.2.3)
|
140
|
+
actiontext (= 7.0.2.3)
|
141
|
+
actionview (= 7.0.2.3)
|
142
|
+
activejob (= 7.0.2.3)
|
143
|
+
activemodel (= 7.0.2.3)
|
144
|
+
activerecord (= 7.0.2.3)
|
145
|
+
activestorage (= 7.0.2.3)
|
146
|
+
activesupport (= 7.0.2.3)
|
147
147
|
bundler (>= 1.15.0)
|
148
|
-
railties (= 7.0.2.
|
148
|
+
railties (= 7.0.2.3)
|
149
149
|
rails-dom-testing (2.0.3)
|
150
150
|
activesupport (>= 4.2.0)
|
151
151
|
nokogiri (>= 1.6)
|
152
152
|
rails-html-sanitizer (1.4.2)
|
153
153
|
loofah (~> 2.3)
|
154
|
-
railties (7.0.2.
|
155
|
-
actionpack (= 7.0.2.
|
156
|
-
activesupport (= 7.0.2.
|
154
|
+
railties (7.0.2.3)
|
155
|
+
actionpack (= 7.0.2.3)
|
156
|
+
activesupport (= 7.0.2.3)
|
157
157
|
method_source
|
158
158
|
rake (>= 12.2)
|
159
159
|
thor (~> 1.0)
|
@@ -174,7 +174,7 @@ GEM
|
|
174
174
|
sprockets (> 3.0)
|
175
175
|
sprockets-rails
|
176
176
|
tilt
|
177
|
-
sprockets (4.0.
|
177
|
+
sprockets (4.0.3)
|
178
178
|
concurrent-ruby (~> 1.0)
|
179
179
|
rack (> 1, < 3)
|
180
180
|
sprockets-rails (3.4.2)
|
@@ -212,7 +212,7 @@ DEPENDENCIES
|
|
212
212
|
mobility (~> 1.2)
|
213
213
|
mobility-actiontext!
|
214
214
|
puma (~> 5.0)
|
215
|
-
rack-mini-profiler
|
215
|
+
rack-mini-profiler
|
216
216
|
rails (~> 7.0.0)
|
217
217
|
sass-rails (>= 6)
|
218
218
|
sqlite3 (~> 1.4)
|
@@ -221,7 +221,7 @@ DEPENDENCIES
|
|
221
221
|
web-console (>= 4.1.0)
|
222
222
|
|
223
223
|
RUBY VERSION
|
224
|
-
ruby 3.1.
|
224
|
+
ruby 3.1.1p18
|
225
225
|
|
226
226
|
BUNDLED WITH
|
227
|
-
2.3.
|
227
|
+
2.3.10
|
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
|
@@ -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,24 @@ 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, post.rich_text_content_en
|
64
|
+
assert_equal <<~HTML, post.rich_text_content_en.to_s
|
65
|
+
<div class="trix-content">
|
66
|
+
<h1>Hello world!</h1>
|
67
|
+
</div>
|
68
|
+
HTML
|
69
|
+
|
70
|
+
assert_instance_of Mobility::Backends::ActionText::RichTextTranslation, post.rich_text_content_fr
|
71
|
+
assert_equal <<~HTML, post.rich_text_content_fr.to_s
|
72
|
+
<div class="trix-content">
|
73
|
+
<h1>Bonjour le monde !</h1>
|
74
|
+
</div>
|
75
|
+
HTML
|
76
|
+
end
|
77
|
+
|
60
78
|
test 'post has different content in different languages' do
|
61
79
|
post = posts(:one)
|
62
80
|
|
@@ -95,18 +113,44 @@ module Mobility
|
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
98
|
-
test 'post content is eager loaded' do
|
116
|
+
test 'post content is eager loaded explicitly' do
|
99
117
|
post = assert_queries(2) { Post.with_rich_text_content.last }
|
100
118
|
|
101
119
|
assert_no_queries do
|
102
120
|
assert_equal 'Hello world!', post.content.to_plain_text
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
test 'correct translation is returned if single translation for different locale was eager loaded' do
|
125
|
+
post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_rich_text_content.last } }
|
103
126
|
|
104
|
-
|
127
|
+
assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
|
128
|
+
end
|
129
|
+
|
130
|
+
test 'post content is eager loaded with all rich text' do
|
131
|
+
post = assert_queries(2) { Post.with_all_rich_text.last }
|
132
|
+
|
133
|
+
assert_no_queries do
|
134
|
+
assert_equal 'Hello world!', post.content.to_plain_text
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
test 'correct translation is returned if all translations for different locale were eager loaded' do
|
139
|
+
post = assert_queries(2) { Mobility.with_locale(:en) { Post.with_all_rich_text.last } }
|
140
|
+
|
141
|
+
assert_equal 'Bonjour le monde !', Mobility.with_locale(:fr) { post.content }.to_plain_text
|
142
|
+
end
|
143
|
+
|
144
|
+
test 'post non_i18n_content is eager loaded with all rich text' do
|
145
|
+
post = assert_queries(2) { Post.with_all_rich_text.last }
|
146
|
+
|
147
|
+
assert_no_queries do
|
148
|
+
assert_equal 'Hello non i18n world!', post.non_i18n_content.to_plain_text
|
105
149
|
end
|
106
150
|
end
|
107
151
|
|
108
152
|
test 'post is being destroyed' do
|
109
|
-
assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -
|
153
|
+
assert_difference ->{Mobility::Backends::ActionText::RichTextTranslation.count}, -5 do
|
110
154
|
assert posts(:one).destroy
|
111
155
|
end
|
112
156
|
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:
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2022-03-24 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:
|
@@ -154,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
156
|
- !ruby/object:Gem::Version
|
155
157
|
version: '0'
|
156
158
|
requirements: []
|
157
|
-
rubygems_version: 3.3.
|
159
|
+
rubygems_version: 3.3.7
|
158
160
|
signing_key:
|
159
161
|
specification_version: 4
|
160
162
|
summary: Translate Rails Action Text rich text with Mobility.
|