weeler 1.5.2 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -0
- data/.travis.yml +3 -14
- data/CHANGELOG.md +43 -0
- data/Gemfile +3 -0
- data/README.md +30 -37
- data/Rakefile +4 -4
- data/app/assets/javascripts/weeler/init.js +32 -0
- data/app/assets/stylesheets/weeler/style.css.scss +7 -1
- data/app/controllers/concerns/weeler/section_seo.rb +1 -1
- data/app/controllers/weeler/base_controller.rb +2 -2
- data/app/controllers/weeler/seo_items_controller.rb +3 -2
- data/app/controllers/weeler/settings_controller.rb +27 -9
- data/app/controllers/weeler/static_sections_controller.rb +2 -2
- data/app/controllers/weeler/translations_controller.rb +5 -19
- data/app/models/setting.rb +7 -0
- data/app/views/kaminari/weeler/_first_page.html.haml +3 -0
- data/app/views/kaminari/weeler/_gap.html.haml +2 -0
- data/app/views/kaminari/weeler/_last_page.html.haml +3 -0
- data/app/views/kaminari/weeler/_next_page.html.haml +3 -0
- data/app/views/kaminari/weeler/_page.html.haml +2 -0
- data/app/views/kaminari/weeler/_paginator.html.haml +11 -0
- data/app/views/kaminari/weeler/_prev_page.html.haml +3 -0
- data/app/views/weeler/base/_footer.html.haml +1 -1
- data/app/views/weeler/settings/_form.html.haml +16 -0
- data/app/views/weeler/settings/index.html.haml +5 -8
- data/app/views/weeler/static_sections/show.html.haml +5 -1
- data/app/views/weeler/translations/_form.html.haml +5 -2
- data/app/views/weeler/translations/index.html.haml +0 -10
- data/lib/generators/weeler/templates/assets/javascripts/weeler/app/index.js +3 -1
- data/lib/generators/weeler/templates/assets/stylesheets/weeler/app/index.css +1 -1
- data/lib/generators/weeler/templates/controllers/weeler/application_controller.rb +1 -1
- data/lib/i18n/backend/weeler/exporter.rb +32 -14
- data/lib/i18n/backend/weeler/importer.rb +57 -54
- data/lib/i18n/backend/weeler.rb +15 -26
- data/lib/weeler/action_controller/acts/restful.rb +4 -4
- data/lib/weeler/action_dispatch/routing/mapper.rb +1 -2
- data/lib/weeler/action_view/helpers/translation_helper.rb +2 -2
- data/lib/weeler/engine.rb +0 -3
- data/lib/weeler/version.rb +3 -3
- data/lib/weeler.rb +8 -3
- data/spec/.DS_Store +0 -0
- data/spec/controllers/translations_controller_spec.rb +16 -16
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +2 -2
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/stylesheets/application.css +6 -4
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/{assets/javascripts → javascript/packs}/application.js +5 -3
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/post.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +9 -9
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +19 -13
- data/spec/dummy/config/boot.rb +3 -3
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/environment.rb +2 -2
- data/spec/dummy/config/environments/development.rb +38 -5
- data/spec/dummy/config/environments/production.rb +64 -32
- data/spec/dummy/config/environments/test.rb +21 -9
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +2 -1
- data/spec/dummy/db/migrate/20140123083704_create_weeler_seos.rb +1 -1
- data/spec/dummy/db/migrate/20140123083705_create_weeler_settings.rb +1 -1
- data/spec/dummy/db/migrate/20140123083706_create_weeler_translations.rb +1 -1
- data/spec/dummy/db/migrate/20140123083707_translate_weeler_seos.rb +1 -1
- data/spec/dummy/db/migrate/20140718103237_create_posts.rb +1 -1
- data/spec/dummy/db/migrate/20140726151210_create_translations.rb +1 -1
- data/spec/dummy/db/migrate/20160330161101_create_weeler_locks.rb +1 -1
- data/spec/dummy/db/migrate/20160330192005_create_weeler_translation_stats.rb +1 -1
- data/spec/dummy/db/schema.rb +56 -64
- data/spec/dummy/{app/mailers/.keep → db/test.sqlite3} +0 -0
- data/spec/dummy/log/development.log +0 -1020
- data/spec/dummy/public/404.html +24 -15
- data/spec/dummy/public/422.html +24 -15
- data/spec/dummy/public/500.html +23 -14
- data/spec/dummy/{app/models/.keep → public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/factories/dummy_posts.rb +3 -3
- data/spec/factories/translations.rb +4 -4
- data/spec/fixtures/test_2020_format.xlsx +0 -0
- data/spec/spec_helper.rb +7 -5
- data/spec/weeler/action_controller/acts/restful_spec.rb +15 -16
- data/spec/weeler/i18n/backend/weeler/exporter_spec.rb +6 -0
- data/spec/weeler/i18n/backend/weeler/importer_spec.rb +17 -6
- data/spec/weeler/i18n/backend/weeler_spec.rb +55 -70
- data/spec/weeler/i18n/humanize_missing_translations_spec.rb +14 -11
- data/weeler.gemspec +18 -13
- metadata +103 -65
- data/app/assets/javascripts/weeler/init.js.coffee +0 -26
- data/app/models/settings.rb +0 -2
- data/app/views/kaminari/weeler/_first_page.html.erb +0 -13
- data/app/views/kaminari/weeler/_gap.html.erb +0 -8
- data/app/views/kaminari/weeler/_last_page.html.erb +0 -13
- data/app/views/kaminari/weeler/_next_page.html.erb +0 -14
- data/app/views/kaminari/weeler/_page.html.erb +0 -12
- data/app/views/kaminari/weeler/_paginator.html.erb +0 -23
- data/app/views/kaminari/weeler/_prev_page.html.erb +0 -13
- data/app/views/weeler/translations/usage_stats.html.haml +0 -34
- data/lib/generators/weeler/templates/migrations/create_weeler_translation_stats.rb +0 -11
- data/lib/i18n/backend/weeler/usage_logger.rb +0 -35
- data/lib/weeler/action_view/helpers/form_helper.rb +0 -13
- data/lib/weeler/action_view/helpers/image_form_helper.rb +0 -83
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/log/production.log +0 -4
- data/spec/weeler/action_view/helpers/form_helper_spec.rb +0 -35
- data/spec/weeler/i18n/backend/weeler/usage_logger_spec.rb +0 -34
data/spec/dummy/public/404.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
|
-
|
7
|
+
.rails-default-error-page {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
|
-
div.dialog {
|
14
|
-
width:
|
15
|
-
|
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 {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,38 +27,41 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
28
35
|
font-size: 100%;
|
29
36
|
color: #730E15;
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
49
56
|
|
50
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
51
58
|
<!-- This file lives in public/404.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
data/spec/dummy/public/422.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
|
-
|
7
|
+
.rails-default-error-page {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
|
-
div.dialog {
|
14
|
-
width:
|
15
|
-
|
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 {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,38 +27,41 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
28
35
|
font-size: 100%;
|
29
36
|
color: #730E15;
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
49
56
|
|
50
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
51
58
|
<!-- This file lives in public/422.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
data/spec/dummy/public/500.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
|
-
|
7
|
+
.rails-default-error-page {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
|
-
div.dialog {
|
14
|
-
width:
|
15
|
-
|
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 {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,37 +27,40 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
28
35
|
font-size: 100%;
|
29
36
|
color: #730E15;
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
49
56
|
|
50
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
51
58
|
<!-- This file lives in public/500.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
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>
|
54
64
|
</div>
|
55
|
-
<p>If you are the application owner check the logs for more information.</p>
|
56
65
|
</body>
|
57
66
|
</html>
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
@@ -10,9 +10,11 @@ end
|
|
10
10
|
|
11
11
|
ENV['RAILS_ENV'] ||= 'test'
|
12
12
|
|
13
|
-
require File.expand_path(
|
13
|
+
# require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
14
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
15
|
+
|
14
16
|
require 'rspec/rails'
|
15
|
-
require '
|
17
|
+
require 'factory_bot'
|
16
18
|
require 'capybara/rspec'
|
17
19
|
require 'database_cleaner'
|
18
20
|
require 'shoulda-matchers'
|
@@ -34,9 +36,9 @@ RSpec.configure do |config|
|
|
34
36
|
|
35
37
|
config.include Rails.application.routes.url_helpers
|
36
38
|
|
37
|
-
#
|
38
|
-
config.include
|
39
|
-
|
39
|
+
# FactoryBot
|
40
|
+
config.include FactoryBot::Syntax::Methods
|
41
|
+
|
40
42
|
Capybara.javascript_driver = :webkit
|
41
43
|
|
42
44
|
# disable empty translation creation
|
@@ -5,7 +5,7 @@ class Weeler::FoosController < Weeler::ContentController; end
|
|
5
5
|
describe Weeler::ActionController::Acts::Restful, type: :controller do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
|
8
|
+
FactoryBot.create_list(:dummy_post, 2)
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
@@ -35,7 +35,7 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
35
35
|
routes.draw { get "index" => "weeler/foos#index" }
|
36
36
|
|
37
37
|
get "index"
|
38
|
-
expect(response).to
|
38
|
+
expect(response).to have_http_status(200)
|
39
39
|
end
|
40
40
|
|
41
41
|
specify "assigns posts" do
|
@@ -54,13 +54,13 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
54
54
|
# end
|
55
55
|
# end
|
56
56
|
|
57
|
-
post "create", post: attributes_for(:dummy_post)
|
57
|
+
post "create", params: { post: attributes_for(:dummy_post) }
|
58
58
|
post = Post.last
|
59
59
|
expect(response).to redirect_to("http://test.host/weeler-admin/foos/#{post.id}/edit")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "sets only permited params" do
|
63
|
-
post "create", post: attributes_for(:dummy_post, body: "Heila")
|
63
|
+
post "create", params: { post: attributes_for(:dummy_post, body: "Heila") }
|
64
64
|
post = Post.last
|
65
65
|
expect(post.title).to eq("Foo bar")
|
66
66
|
expect(post.body).to eq(nil)
|
@@ -69,22 +69,23 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
69
69
|
|
70
70
|
describe "GET #edit" do
|
71
71
|
it "returns success status" do
|
72
|
-
get "edit", id: Post.last.id
|
73
|
-
expect(response).to
|
72
|
+
get "edit", params: { id: Post.last.id }
|
73
|
+
expect(response).to have_http_status(200)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "GET #new" do
|
78
78
|
it "returns success status" do
|
79
79
|
get "new"
|
80
|
-
|
80
|
+
|
81
|
+
expect(response).to have_http_status(200)
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
85
|
describe "PUT #update" do
|
85
86
|
it "sets only permited params" do
|
86
87
|
post = Post.last
|
87
|
-
put "update", id: post.id, post: {title: "Shivauva", body: "Another world!"}
|
88
|
+
put "update", params: { id: post.id, post: {title: "Shivauva", body: "Another world!"} }
|
88
89
|
post.reload
|
89
90
|
expect(post.title).to eq("Shivauva")
|
90
91
|
expect(post.body).to eq("Foo baar bazaar")
|
@@ -94,7 +95,7 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
94
95
|
describe "DELETE #destroy" do
|
95
96
|
it "destroys item" do
|
96
97
|
post = Post.last
|
97
|
-
delete "destroy", id: post.id
|
98
|
+
delete "destroy", params: { id: post.id }
|
98
99
|
expect { post.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
99
100
|
end
|
100
101
|
end
|
@@ -102,7 +103,7 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
102
103
|
specify "POST #order" do
|
103
104
|
routes.draw { post "order" => "weeler/foos#order" }
|
104
105
|
|
105
|
-
post "order", orders: "order[]=2&order[]=1"
|
106
|
+
post "order", params: { orders: "order[]=2&order[]=1" }
|
106
107
|
post1 = Post.order(sequence: :asc).first
|
107
108
|
post2 = Post.order(sequence: :asc).last
|
108
109
|
expect(post1.sequence).to eq(0)
|
@@ -120,15 +121,15 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
120
121
|
describe "actions" do
|
121
122
|
describe "POST #create" do
|
122
123
|
it "sets only permited params" do
|
123
|
-
post "create", post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila")
|
124
|
+
post "create", params: { post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila") }
|
124
125
|
post = Post.last
|
125
126
|
expect(post.title).to eq(nil)
|
126
127
|
expect(post.body).to eq(nil)
|
127
128
|
end
|
128
129
|
|
129
130
|
it "warns developer" do
|
130
|
-
warning_message = "[UNPERMITED PARAMS] To permit {\"
|
131
|
-
expect { post("create", post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila")) }.to output(warning_message).to_stderr
|
131
|
+
warning_message = "[UNPERMITED PARAMS] To permit {\"body\"=>\"Heila\", \"title\"=>\"Foo lala\"} params, add 'permit_params: permit_params:' option to 'acts_as_restful'\n"
|
132
|
+
expect { post("create", params: { post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila") }) }.to output(warning_message).to_stderr
|
132
133
|
end
|
133
134
|
end
|
134
135
|
end
|
@@ -142,7 +143,7 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
142
143
|
describe "actions" do
|
143
144
|
describe "POST #create" do
|
144
145
|
it "sets only permited params" do
|
145
|
-
post "create", post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila")
|
146
|
+
post "create", params: { post: attributes_for(:dummy_post, title: "Foo lala", body: "Heila") }
|
146
147
|
post = Post.last
|
147
148
|
expect(post.title).to eq("Foo lala")
|
148
149
|
expect(post.body).to eq("Heila")
|
@@ -165,7 +166,5 @@ describe Weeler::ActionController::Acts::Restful, type: :controller do
|
|
165
166
|
end
|
166
167
|
end
|
167
168
|
end
|
168
|
-
|
169
|
-
|
170
169
|
end
|
171
170
|
end
|
@@ -22,12 +22,18 @@ describe I18n::Backend::Weeler::Exporter do
|
|
22
22
|
expect(@rows.first.cells[0].value).to eq("Key")
|
23
23
|
expect(@rows.first.cells[1].value).to eq("En")
|
24
24
|
expect(@rows.first.cells[2].value).to eq("Lv")
|
25
|
+
|
26
|
+
expect(@rows.first.cells[3].value).to eq("Created at")
|
27
|
+
expect(@rows.first.cells[4].value).to eq("Updated at")
|
25
28
|
end
|
26
29
|
|
27
30
|
it "other row with one translation" do
|
28
31
|
expect(@rows[1].cells[0].value).to eq("foo.one")
|
29
32
|
expect(@rows[1].cells[1].value).to eq("test")
|
30
33
|
expect(@rows[1].cells[2].value).to eq("")
|
34
|
+
|
35
|
+
expect(@rows[1].cells[3].value&.is_a?(Time)).to eq(true)
|
36
|
+
expect(@rows[1].cells[4].value&.is_a?(Time)).to eq(true)
|
31
37
|
end
|
32
38
|
|
33
39
|
it "other row with two translation" do
|
@@ -6,7 +6,6 @@ describe I18n::Backend::Weeler::Importer do
|
|
6
6
|
let(:file_path) { Rack::Test::UploadedFile.new(File.dirname(__FILE__) + '/../../../../fixtures/test.xlsx') }
|
7
7
|
|
8
8
|
describe :import do
|
9
|
-
|
10
9
|
context "empty db" do
|
11
10
|
before(:each) do
|
12
11
|
I18n::Backend::Weeler::Translation.delete_all
|
@@ -24,9 +23,24 @@ describe I18n::Backend::Weeler::Importer do
|
|
24
23
|
it "returns nil if value is not file" do
|
25
24
|
expect(I18n.t(:"product.list.open", :locale => :en)).to eq("")
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
27
|
|
28
|
+
context 'when file includes created_at and updated_at dates' do
|
29
|
+
let(:file_path) { Rack::Test::UploadedFile.new(File.dirname(__FILE__) + '/../../../../fixtures/test_2020_format.xlsx') }
|
30
|
+
|
31
|
+
before(:each) do
|
32
|
+
I18n::Backend::Weeler::Translation.delete_all
|
33
|
+
I18n::Backend::Weeler::Translation.import file_path
|
34
|
+
end
|
35
|
+
|
36
|
+
it "translation stores all translation in each locale" do
|
37
|
+
expect(I18n::Backend::Weeler::Translation.count).to eq(30)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "stores only values from locals" do
|
41
|
+
expect(I18n::Backend::Weeler::Translation.distinct.pluck(:locale).sort).to eq(['en', 'lt', 'lv'])
|
42
|
+
end
|
43
|
+
end
|
30
44
|
|
31
45
|
context "full db" do
|
32
46
|
before(:each) do
|
@@ -38,13 +52,10 @@ describe I18n::Backend::Weeler::Importer do
|
|
38
52
|
it "file import overrides value" do
|
39
53
|
expect(I18n.t(:"welcome.title", :locale => :en)).to eq("fooo")
|
40
54
|
I18n::Backend::Weeler::Translation.import file_path
|
41
|
-
|
55
|
+
Setting.i18n_updated_at = Time.current
|
42
56
|
|
43
57
|
expect(I18n.t(:"welcome.title", :locale => :en)).to eq("EN welcome")
|
44
58
|
end
|
45
|
-
|
46
59
|
end
|
47
|
-
|
48
60
|
end
|
49
|
-
|
50
61
|
end
|