locomotivecms_steam 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +13 -14
- data/lib/locomotive/steam/middlewares/locale.rb +5 -1
- data/lib/locomotive/steam/middlewares/renderer.rb +1 -1
- data/lib/locomotive/steam/middlewares/thread_safe.rb +4 -0
- data/lib/locomotive/steam/version.rb +1 -1
- data/spec/unit/middlewares/locale_spec.rb +52 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0638993657ef4d9c1daeacceaf92343dced8b62
|
4
|
+
data.tar.gz: 88c03d05c185a8e33de76a7c83f0414d9c463ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81a06d2a759297e8177148cba1d9a00bf1baf925d4335465f82e03541362259855056a68b6656a6be41d140713fd4cd1755fc9890985b4ba2d698a30e9904ac5
|
7
|
+
data.tar.gz: 008df971169a7c5c267bf2eb521276ca35814006e038b90b4ac57723971d00ab270824f7a9517e78743b91d80e5639ef0d7c192486494916103a509245791c8e
|
data/Gemfile
CHANGED
@@ -30,8 +30,8 @@ group :test do
|
|
30
30
|
|
31
31
|
gem 'rack-test', '~> 0.6.3'
|
32
32
|
|
33
|
-
gem 'codeclimate-test-reporter', '~> 0.4.7',
|
34
|
-
gem 'coveralls', '~> 0.8.1',
|
33
|
+
gem 'codeclimate-test-reporter', '~> 0.4.7', require: false
|
34
|
+
gem 'coveralls', '~> 0.8.1', require: false
|
35
35
|
end
|
36
36
|
|
37
37
|
platform :ruby do
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.2.
|
4
|
+
locomotivecms_steam (1.2.1)
|
5
5
|
RedCloth (~> 4.3.2)
|
6
6
|
autoprefixer-rails (~> 6.3.3.1)
|
7
7
|
chronic (~> 0.10.2)
|
@@ -30,9 +30,8 @@ GEM
|
|
30
30
|
remote: https://rubygems.org/
|
31
31
|
specs:
|
32
32
|
RedCloth (4.3.2)
|
33
|
-
activesupport (4.2.
|
33
|
+
activesupport (4.2.8)
|
34
34
|
i18n (~> 0.7)
|
35
|
-
json (~> 1.7, >= 1.7.7)
|
36
35
|
minitest (~> 5.1)
|
37
36
|
thread_safe (~> 0.3, >= 0.3.4)
|
38
37
|
tzinfo (~> 1.1)
|
@@ -44,14 +43,14 @@ GEM
|
|
44
43
|
bson (4.1.1)
|
45
44
|
byebug (8.2.5)
|
46
45
|
chronic (0.10.2)
|
47
|
-
chunky_png (1.3.
|
46
|
+
chunky_png (1.3.8)
|
48
47
|
codeclimate-test-reporter (0.4.8)
|
49
48
|
simplecov (>= 0.7.1, < 1.0.0)
|
50
49
|
coderay (1.1.1)
|
51
50
|
coffee-script (2.4.1)
|
52
51
|
coffee-script-source
|
53
52
|
execjs
|
54
|
-
coffee-script-source (1.
|
53
|
+
coffee-script-source (1.12.2)
|
55
54
|
colorize (0.8.1)
|
56
55
|
compass (1.0.3)
|
57
56
|
chunky_png (~> 1.2)
|
@@ -65,7 +64,7 @@ GEM
|
|
65
64
|
sass (>= 3.3.0, < 3.5)
|
66
65
|
compass-import-once (1.0.5)
|
67
66
|
sass (>= 3.2, < 3.5)
|
68
|
-
concurrent-ruby (1.0.
|
67
|
+
concurrent-ruby (1.0.5)
|
69
68
|
coveralls (0.8.15)
|
70
69
|
json (>= 1.8, < 3)
|
71
70
|
simplecov (~> 0.12.0)
|
@@ -81,7 +80,7 @@ GEM
|
|
81
80
|
rack (>= 1.3.0)
|
82
81
|
duktape (1.3.0.6)
|
83
82
|
execjs (2.7.0)
|
84
|
-
ffi (1.9.
|
83
|
+
ffi (1.9.18)
|
85
84
|
flamegraph (0.9.5)
|
86
85
|
haml (4.0.7)
|
87
86
|
tilt
|
@@ -113,13 +112,13 @@ GEM
|
|
113
112
|
mime-types (2.6.2)
|
114
113
|
mimetype-fu (0.1.2)
|
115
114
|
mini_portile2 (2.1.0)
|
116
|
-
minitest (5.
|
117
|
-
moneta (0.8.
|
115
|
+
minitest (5.10.1)
|
116
|
+
moneta (0.8.1)
|
118
117
|
mongo (2.2.7)
|
119
118
|
bson (~> 4.0)
|
120
119
|
morphine (0.1.1)
|
121
120
|
multi_json (1.12.1)
|
122
|
-
multi_xml (0.
|
121
|
+
multi_xml (0.6.0)
|
123
122
|
nokogiri (1.6.8.1)
|
124
123
|
mini_portile2 (~> 2.1.0)
|
125
124
|
nokogumbo (1.4.10)
|
@@ -134,7 +133,7 @@ GEM
|
|
134
133
|
pry-byebug (3.3.0)
|
135
134
|
byebug (~> 8.0)
|
136
135
|
pry (~> 0.10)
|
137
|
-
public_suffix (2.0.
|
136
|
+
public_suffix (2.0.5)
|
138
137
|
puma (3.6.0)
|
139
138
|
rack (2.0.1)
|
140
139
|
rack-cache (1.6.1)
|
@@ -148,7 +147,7 @@ GEM
|
|
148
147
|
rack (>= 1.1.0)
|
149
148
|
rake (10.4.2)
|
150
149
|
rb-fsevent (0.9.8)
|
151
|
-
rb-inotify (0.9.
|
150
|
+
rb-inotify (0.9.8)
|
152
151
|
ffi (>= 0.5.0)
|
153
152
|
rspec (3.4.0)
|
154
153
|
rspec-core (~> 3.4.0)
|
@@ -167,7 +166,7 @@ GEM
|
|
167
166
|
crass (~> 1.0.2)
|
168
167
|
nokogiri (>= 1.4.4)
|
169
168
|
nokogumbo (~> 1.4.1)
|
170
|
-
sass (3.4.
|
169
|
+
sass (3.4.23)
|
171
170
|
simplecov (0.12.0)
|
172
171
|
docile (~> 1.1.0)
|
173
172
|
json (>= 1.8, < 3)
|
@@ -182,7 +181,7 @@ GEM
|
|
182
181
|
term-ansicolor (1.3.2)
|
183
182
|
tins (~> 1.0)
|
184
183
|
thor (0.19.1)
|
185
|
-
thread_safe (0.3.
|
184
|
+
thread_safe (0.3.6)
|
186
185
|
tilt (2.0.5)
|
187
186
|
timecop (0.8.1)
|
188
187
|
tins (1.12.0)
|
@@ -28,7 +28,7 @@ module Locomotive::Steam
|
|
28
28
|
protected
|
29
29
|
|
30
30
|
def extract_locale
|
31
|
-
_locale =
|
31
|
+
_locale = locale_from_params || default_locale
|
32
32
|
_path = request.path_info
|
33
33
|
|
34
34
|
if _path =~ /^\/(#{site.locales.join('|')})+(\/|$)/
|
@@ -44,6 +44,10 @@ module Locomotive::Steam
|
|
44
44
|
env['steam.locale'] = services.locale = _locale
|
45
45
|
end
|
46
46
|
|
47
|
+
def locale_from_params
|
48
|
+
locales.include?(params[:locale]) ? params[:locale] : nil
|
49
|
+
end
|
50
|
+
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -20,7 +20,7 @@ module Locomotive::Steam
|
|
20
20
|
redirect_to(page.redirect_url, page.redirect_type)
|
21
21
|
else
|
22
22
|
content = parse_and_render_liquid
|
23
|
-
render_response(content, page.not_found? ? 404: 200, page.response_type)
|
23
|
+
render_response(content, page.not_found? ? 404 : 200, page.response_type)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../../../lib/locomotive/steam/middlewares/thread_safe'
|
4
|
+
require_relative '../../../lib/locomotive/steam/middlewares/helpers'
|
5
|
+
require_relative '../../../lib/locomotive/steam/middlewares/locale'
|
6
|
+
|
7
|
+
describe Locomotive::Steam::Middlewares::Locale do
|
8
|
+
|
9
|
+
let(:site) { instance_double('Site', default_locale: :de, locales: %w(de fr)) }
|
10
|
+
let(:url) { 'http://models.example.com' }
|
11
|
+
let(:app) { ->(env) { [200, env, 'app'] } }
|
12
|
+
let(:services) { instance_double('Services', :locale= => 'en') }
|
13
|
+
let(:middleware) { Locomotive::Steam::Middlewares::Locale.new(app) }
|
14
|
+
|
15
|
+
subject do
|
16
|
+
env = env_for(url, 'steam.site' => site)
|
17
|
+
env['steam.request'] = Rack::Request.new(env)
|
18
|
+
env['steam.services'] = services
|
19
|
+
code, env = middleware.call(env)
|
20
|
+
env['steam.locale']
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'locale asked in the request params' do
|
24
|
+
|
25
|
+
context 'the locale is blank' do
|
26
|
+
|
27
|
+
let(:url) { 'http://models.example.com?locale=' }
|
28
|
+
|
29
|
+
it { is_expected.to eq :de }
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'the locale exists' do
|
34
|
+
|
35
|
+
let(:url) { 'http://models.example.com?locale=fr' }
|
36
|
+
|
37
|
+
it { is_expected.to eq 'fr' }
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'the locale is unknown' do
|
42
|
+
|
43
|
+
let(:url) { 'http://models.example.com?locale=onload' }
|
44
|
+
|
45
|
+
it { is_expected.to eq :de }
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_steam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -797,6 +797,7 @@ files:
|
|
797
797
|
- spec/unit/middlewares/entry_submission_spec.rb
|
798
798
|
- spec/unit/middlewares/helpers_spec.rb
|
799
799
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
800
|
+
- spec/unit/middlewares/locale_spec.rb
|
800
801
|
- spec/unit/middlewares/page_spec.rb
|
801
802
|
- spec/unit/middlewares/private_access_spec.rb
|
802
803
|
- spec/unit/middlewares/renderer_spec.rb
|
@@ -1059,6 +1060,7 @@ test_files:
|
|
1059
1060
|
- spec/unit/middlewares/entry_submission_spec.rb
|
1060
1061
|
- spec/unit/middlewares/helpers_spec.rb
|
1061
1062
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
1063
|
+
- spec/unit/middlewares/locale_spec.rb
|
1062
1064
|
- spec/unit/middlewares/page_spec.rb
|
1063
1065
|
- spec/unit/middlewares/private_access_spec.rb
|
1064
1066
|
- spec/unit/middlewares/renderer_spec.rb
|