mobility-actiontext 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +152 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +1 -0
- data/lib/mobility/action_text.rb +4 -0
- data/lib/mobility/action_text/version.rb +7 -0
- data/lib/mobility/backends/action_text.rb +98 -0
- data/mobility-actiontext.gemspec +33 -0
- data/test_app/.gitignore +40 -0
- data/test_app/Gemfile +50 -0
- data/test_app/Gemfile.lock +221 -0
- data/test_app/Rakefile +6 -0
- data/test_app/app/assets/config/manifest.js +2 -0
- data/test_app/app/assets/stylesheets/application.css +15 -0
- data/test_app/app/controllers/application_controller.rb +2 -0
- data/test_app/app/helpers/application_helper.rb +2 -0
- data/test_app/app/models/application_record.rb +3 -0
- data/test_app/app/models/post.rb +7 -0
- data/test_app/app/views/layouts/application.html.erb +15 -0
- data/test_app/bin/bundle +114 -0
- data/test_app/bin/rails +4 -0
- data/test_app/bin/rake +4 -0
- data/test_app/bin/setup +33 -0
- data/test_app/config.ru +6 -0
- data/test_app/config/application.rb +35 -0
- data/test_app/config/boot.rb +3 -0
- data/test_app/config/credentials.yml.enc +1 -0
- data/test_app/config/database.yml +25 -0
- data/test_app/config/environment.rb +5 -0
- data/test_app/config/environments/development.rb +71 -0
- data/test_app/config/environments/production.rb +106 -0
- data/test_app/config/environments/test.rb +52 -0
- data/test_app/config/initializers/application_controller_renderer.rb +8 -0
- data/test_app/config/initializers/assets.rb +14 -0
- data/test_app/config/initializers/backtrace_silencers.rb +8 -0
- data/test_app/config/initializers/content_security_policy.rb +30 -0
- data/test_app/config/initializers/cookies_serializer.rb +5 -0
- data/test_app/config/initializers/filter_parameter_logging.rb +6 -0
- data/test_app/config/initializers/i18n.rb +3 -0
- data/test_app/config/initializers/inflections.rb +16 -0
- data/test_app/config/initializers/mime_types.rb +4 -0
- data/test_app/config/initializers/mobility.rb +15 -0
- data/test_app/config/initializers/permissions_policy.rb +11 -0
- data/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/test_app/config/locales/en.yml +33 -0
- data/test_app/config/puma.rb +43 -0
- data/test_app/config/routes.rb +3 -0
- data/test_app/config/storage.yml +34 -0
- data/test_app/db/migrate/20210114124021_create_active_storage_tables.active_storage.rb +39 -0
- data/test_app/db/migrate/20210114124022_create_action_text_tables.action_text.rb +16 -0
- data/test_app/db/migrate/20210114124951_translate_rich_texts.rb +17 -0
- data/test_app/db/migrate/20210114125134_create_posts.rb +7 -0
- data/test_app/db/schema.rb +64 -0
- data/test_app/db/seeds.rb +7 -0
- data/test_app/public/404.html +67 -0
- data/test_app/public/422.html +67 -0
- data/test_app/public/500.html +66 -0
- data/test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/test_app/public/apple-touch-icon.png +0 -0
- data/test_app/public/favicon.ico +0 -0
- data/test_app/public/robots.txt +1 -0
- data/test_app/test/application_system_test_case.rb +5 -0
- data/test_app/test/fixtures/action_text/rich_texts.yml +35 -0
- data/test_app/test/fixtures/posts.yml +3 -0
- data/test_app/test/mobility_action_text_test.rb +108 -0
- data/test_app/test/test_helper.rb +28 -0
- metadata +158 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
post_one_title_en:
|
2
|
+
record: one (Post)
|
3
|
+
name: title
|
4
|
+
locale: en
|
5
|
+
body: Post Title
|
6
|
+
|
7
|
+
post_one_title_fr:
|
8
|
+
record: one (Post)
|
9
|
+
name: title
|
10
|
+
locale: fr
|
11
|
+
body: Le titre du billet
|
12
|
+
|
13
|
+
post_one_content_en:
|
14
|
+
record: one (Post)
|
15
|
+
name: content
|
16
|
+
locale: en
|
17
|
+
body: <h1>Hello world!</h1>
|
18
|
+
|
19
|
+
post_one_content_fr:
|
20
|
+
record: one (Post)
|
21
|
+
name: content
|
22
|
+
locale: fr
|
23
|
+
body: <h1>Bonjour le monde !</h1>
|
24
|
+
|
25
|
+
untranslated_title_en:
|
26
|
+
record: untranslated (Post)
|
27
|
+
name: title
|
28
|
+
locale: en
|
29
|
+
body: untranslated title
|
30
|
+
|
31
|
+
untranslated_content_en:
|
32
|
+
record: untranslated (Post)
|
33
|
+
name: content
|
34
|
+
locale: en
|
35
|
+
body: untranslated content
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module Mobility
|
6
|
+
class ActionTextTest < ActiveSupport::TestCase
|
7
|
+
test 'post title backend is Mobility::Backends::ActionText' do
|
8
|
+
post = posts(:one)
|
9
|
+
|
10
|
+
assert_kind_of Mobility::Backends::ActionText, post.title_backend
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'post content backend is Mobility::Backends::ActionText' do
|
14
|
+
post = posts(:one)
|
15
|
+
|
16
|
+
assert_kind_of Mobility::Backends::ActionText, post.content_backend
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'post has plain_text_translations association' do
|
20
|
+
post = posts(:one)
|
21
|
+
|
22
|
+
assert post.plain_text_translations
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'post has rich_text_translations association' do
|
26
|
+
post = posts(:one)
|
27
|
+
|
28
|
+
assert post.rich_text_translations
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'post has two plain text translations' do
|
32
|
+
post = posts(:one)
|
33
|
+
|
34
|
+
assert_equal 2, post.plain_text_translations.count
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'post has two rich text translations' do
|
38
|
+
post = posts(:one)
|
39
|
+
|
40
|
+
assert_equal 2, post.rich_text_translations.count
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'post has plain text title' do
|
44
|
+
post = posts(:one)
|
45
|
+
|
46
|
+
assert_equal 'Post Title', post.title
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'post has rich text content' do
|
50
|
+
post = posts(:one)
|
51
|
+
|
52
|
+
assert_instance_of Mobility::Backends::ActionText::RichTextTranslation, post.rich_text_content
|
53
|
+
assert_equal <<~HTML, post.content.to_s
|
54
|
+
<div class="trix-content">
|
55
|
+
<h1>Hello world!</h1>
|
56
|
+
</div>
|
57
|
+
HTML
|
58
|
+
end
|
59
|
+
|
60
|
+
test 'post has different content in different languages' do
|
61
|
+
post = posts(:one)
|
62
|
+
|
63
|
+
I18n.with_locale(:en) do
|
64
|
+
assert_equal 'Post Title', post.title
|
65
|
+
assert_equal <<~HTML, post.content.to_s
|
66
|
+
<div class="trix-content">
|
67
|
+
<h1>Hello world!</h1>
|
68
|
+
</div>
|
69
|
+
HTML
|
70
|
+
end
|
71
|
+
I18n.with_locale(:fr) do
|
72
|
+
assert_equal 'Le titre du billet', post.title
|
73
|
+
assert_equal <<~HTML, post.content.to_s
|
74
|
+
<div class="trix-content">
|
75
|
+
<h1>Bonjour le monde !</h1>
|
76
|
+
</div>
|
77
|
+
HTML
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'post has no content when switching to untranslated language' do
|
82
|
+
post = posts(:untranslated)
|
83
|
+
|
84
|
+
I18n.with_locale(:en) do
|
85
|
+
assert_equal 'untranslated title', post.title
|
86
|
+
assert_equal <<~HTML, post.content.to_s
|
87
|
+
<div class="trix-content">
|
88
|
+
untranslated content
|
89
|
+
</div>
|
90
|
+
HTML
|
91
|
+
end
|
92
|
+
I18n.with_locale(:fr) do
|
93
|
+
assert_not post.title?
|
94
|
+
assert_not post.content?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'post content is eager loaded' do
|
99
|
+
post = assert_queries(2) { Post.with_rich_text_content.last }
|
100
|
+
|
101
|
+
assert_no_queries do
|
102
|
+
assert_equal 'Hello world!', post.content.to_plain_text
|
103
|
+
|
104
|
+
skip('FIXME: this should execute no queries')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require_relative "../config/environment"
|
3
|
+
require "rails/test_help"
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Run tests in parallel with specified workers
|
7
|
+
parallelize(workers: :number_of_processors)
|
8
|
+
|
9
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
def assert_queries(expected_count)
|
13
|
+
ActiveRecord::Base.connection.materialize_transactions
|
14
|
+
|
15
|
+
queries = []
|
16
|
+
ActiveSupport::Notifications.subscribe("sql.active_record") do |*, payload|
|
17
|
+
queries << payload[:sql] unless %w[ SCHEMA TRANSACTION ].include?(payload[:name])
|
18
|
+
end
|
19
|
+
|
20
|
+
yield.tap do
|
21
|
+
assert_equal expected_count, queries.size, "#{queries.size} instead of #{expected_count} queries were executed. #{queries.inspect}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def assert_no_queries(&block)
|
26
|
+
assert_queries(0, &block)
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobility-actiontext
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sébastien Dubois
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mobility
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- sedubois@users.noreply.github.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".github/workflows/main.yml"
|
63
|
+
- ".ruby-version"
|
64
|
+
- CHANGELOG.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/mobility/action_text.rb
|
71
|
+
- lib/mobility/action_text/version.rb
|
72
|
+
- lib/mobility/backends/action_text.rb
|
73
|
+
- mobility-actiontext.gemspec
|
74
|
+
- test_app/.gitignore
|
75
|
+
- test_app/Gemfile
|
76
|
+
- test_app/Gemfile.lock
|
77
|
+
- test_app/Rakefile
|
78
|
+
- test_app/app/assets/config/manifest.js
|
79
|
+
- test_app/app/assets/stylesheets/application.css
|
80
|
+
- test_app/app/controllers/application_controller.rb
|
81
|
+
- test_app/app/helpers/application_helper.rb
|
82
|
+
- test_app/app/models/application_record.rb
|
83
|
+
- test_app/app/models/post.rb
|
84
|
+
- test_app/app/views/layouts/application.html.erb
|
85
|
+
- test_app/bin/bundle
|
86
|
+
- test_app/bin/rails
|
87
|
+
- test_app/bin/rake
|
88
|
+
- test_app/bin/setup
|
89
|
+
- test_app/config.ru
|
90
|
+
- test_app/config/application.rb
|
91
|
+
- test_app/config/boot.rb
|
92
|
+
- test_app/config/credentials.yml.enc
|
93
|
+
- test_app/config/database.yml
|
94
|
+
- test_app/config/environment.rb
|
95
|
+
- test_app/config/environments/development.rb
|
96
|
+
- test_app/config/environments/production.rb
|
97
|
+
- test_app/config/environments/test.rb
|
98
|
+
- test_app/config/initializers/application_controller_renderer.rb
|
99
|
+
- test_app/config/initializers/assets.rb
|
100
|
+
- test_app/config/initializers/backtrace_silencers.rb
|
101
|
+
- test_app/config/initializers/content_security_policy.rb
|
102
|
+
- test_app/config/initializers/cookies_serializer.rb
|
103
|
+
- test_app/config/initializers/filter_parameter_logging.rb
|
104
|
+
- test_app/config/initializers/i18n.rb
|
105
|
+
- test_app/config/initializers/inflections.rb
|
106
|
+
- test_app/config/initializers/mime_types.rb
|
107
|
+
- test_app/config/initializers/mobility.rb
|
108
|
+
- test_app/config/initializers/permissions_policy.rb
|
109
|
+
- test_app/config/initializers/wrap_parameters.rb
|
110
|
+
- test_app/config/locales/en.yml
|
111
|
+
- test_app/config/puma.rb
|
112
|
+
- test_app/config/routes.rb
|
113
|
+
- test_app/config/storage.yml
|
114
|
+
- test_app/db/migrate/20210114124021_create_active_storage_tables.active_storage.rb
|
115
|
+
- test_app/db/migrate/20210114124022_create_action_text_tables.action_text.rb
|
116
|
+
- test_app/db/migrate/20210114124951_translate_rich_texts.rb
|
117
|
+
- test_app/db/migrate/20210114125134_create_posts.rb
|
118
|
+
- test_app/db/schema.rb
|
119
|
+
- test_app/db/seeds.rb
|
120
|
+
- test_app/public/404.html
|
121
|
+
- test_app/public/422.html
|
122
|
+
- test_app/public/500.html
|
123
|
+
- test_app/public/apple-touch-icon-precomposed.png
|
124
|
+
- test_app/public/apple-touch-icon.png
|
125
|
+
- test_app/public/favicon.ico
|
126
|
+
- test_app/public/robots.txt
|
127
|
+
- test_app/test/application_system_test_case.rb
|
128
|
+
- test_app/test/fixtures/action_text/rich_texts.yml
|
129
|
+
- test_app/test/fixtures/posts.yml
|
130
|
+
- test_app/test/mobility_action_text_test.rb
|
131
|
+
- test_app/test/test_helper.rb
|
132
|
+
homepage: https://github.com/sedubois/mobility-actiontext
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata:
|
136
|
+
homepage_uri: https://github.com/sedubois/mobility-actiontext
|
137
|
+
source_code_uri: https://github.com/sedubois/mobility-actiontext
|
138
|
+
changelog_uri: https://github.com/sedubois/mobility-actiontext/blob/main/CHANGELOG.md
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 2.7.2
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubygems_version: 3.2.5
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Translate Rails Action Text rich text with Mobility.
|
158
|
+
test_files: []
|