locomotivecms_steam 1.1.1 → 1.1.2
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 +21 -20
- 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: 5f9df68e43afc27c2b1791937e36cc3755b31516
|
4
|
+
data.tar.gz: bfea5634abf89f91ebd523b01dd58f51ce6a7d65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7fd99e9a39fd88391391d55345cff0e13537cb8b504dd6af0b4c7c8b043ffc6a47c30d9491b18f4e5aee4b78ea8d8ccfabd1cf596356ee727d053d381b361da
|
7
|
+
data.tar.gz: e62db05b922358598d8841a86a76910e32a2dc7fc3879e034246e2c0aaf1bdbe4bd3a4984e5165c5e0a43a0bc8317d8e373da2da0a495cca1ddca8003c33a7e9
|
data/Gemfile
CHANGED
@@ -29,8 +29,8 @@ group :test do
|
|
29
29
|
|
30
30
|
gem 'rack-test', '~> 0.6.3'
|
31
31
|
|
32
|
-
gem 'codeclimate-test-reporter', '~> 0.4.7',
|
33
|
-
gem 'coveralls', '~> 0.8.1',
|
32
|
+
gem 'codeclimate-test-reporter', '~> 0.4.7', require: false
|
33
|
+
gem 'coveralls', '~> 0.8.1', require: false
|
34
34
|
end
|
35
35
|
|
36
36
|
platform :ruby do
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.1.
|
4
|
+
locomotivecms_steam (1.1.2)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
6
|
autoprefixer-rails (~> 6.3.3.1)
|
7
7
|
chronic (~> 0.10.2)
|
@@ -29,28 +29,28 @@ GEM
|
|
29
29
|
remote: https://rubygems.org/
|
30
30
|
specs:
|
31
31
|
RedCloth (4.2.9)
|
32
|
-
activesupport (4.2.
|
32
|
+
activesupport (4.2.8)
|
33
33
|
i18n (~> 0.7)
|
34
|
-
json (~> 1.7, >= 1.7.7)
|
35
34
|
minitest (~> 5.1)
|
36
35
|
thread_safe (~> 0.3, >= 0.3.4)
|
37
36
|
tzinfo (~> 1.1)
|
38
|
-
addressable (2.
|
37
|
+
addressable (2.5.0)
|
38
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
39
39
|
attr_extras (4.4.0)
|
40
40
|
autoprefixer-rails (6.3.3.1)
|
41
41
|
execjs
|
42
42
|
bson (4.0.2)
|
43
43
|
byebug (8.2.1)
|
44
44
|
chronic (0.10.2)
|
45
|
-
chunky_png (1.3.
|
45
|
+
chunky_png (1.3.8)
|
46
46
|
codeclimate-test-reporter (0.4.8)
|
47
47
|
simplecov (>= 0.7.1, < 1.0.0)
|
48
48
|
coderay (1.1.0)
|
49
49
|
coffee-script (2.4.1)
|
50
50
|
coffee-script-source
|
51
51
|
execjs
|
52
|
-
coffee-script-source (1.
|
53
|
-
colorize (0.
|
52
|
+
coffee-script-source (1.12.2)
|
53
|
+
colorize (0.8.1)
|
54
54
|
compass (1.0.3)
|
55
55
|
chunky_png (~> 1.2)
|
56
56
|
compass-core (~> 1.0.2)
|
@@ -63,7 +63,7 @@ GEM
|
|
63
63
|
sass (>= 3.3.0, < 3.5)
|
64
64
|
compass-import-once (1.0.5)
|
65
65
|
sass (>= 3.2, < 3.5)
|
66
|
-
concurrent-ruby (1.0.
|
66
|
+
concurrent-ruby (1.0.5)
|
67
67
|
coveralls (0.8.10)
|
68
68
|
json (~> 1.8)
|
69
69
|
rest-client (>= 1.6.8, < 2)
|
@@ -80,11 +80,11 @@ GEM
|
|
80
80
|
addressable (~> 2.3)
|
81
81
|
multi_json (~> 1.0)
|
82
82
|
rack (>= 1.3.0)
|
83
|
-
execjs (2.
|
83
|
+
execjs (2.7.0)
|
84
84
|
fast_stack (0.1.0)
|
85
85
|
rake
|
86
86
|
rake-compiler
|
87
|
-
ffi (1.9.
|
87
|
+
ffi (1.9.18)
|
88
88
|
flamegraph (0.1.0)
|
89
89
|
fast_stack
|
90
90
|
haml (4.0.7)
|
@@ -117,17 +117,17 @@ GEM
|
|
117
117
|
mime-types (2.6.2)
|
118
118
|
mimetype-fu (0.1.2)
|
119
119
|
mini_portile2 (2.0.0)
|
120
|
-
minitest (5.
|
121
|
-
moneta (0.8.
|
120
|
+
minitest (5.10.1)
|
121
|
+
moneta (0.8.1)
|
122
122
|
mongo (2.2.3)
|
123
123
|
bson (~> 4.0)
|
124
124
|
morphine (0.1.1)
|
125
125
|
multi_json (1.11.2)
|
126
|
-
multi_xml (0.
|
126
|
+
multi_xml (0.6.0)
|
127
127
|
netrc (0.11.0)
|
128
128
|
nokogiri (1.6.7.2)
|
129
129
|
mini_portile2 (~> 2.0.0.rc2)
|
130
|
-
nokogumbo (1.4.
|
130
|
+
nokogumbo (1.4.10)
|
131
131
|
nokogiri
|
132
132
|
origin (2.1.1)
|
133
133
|
pry (0.10.3)
|
@@ -137,6 +137,7 @@ GEM
|
|
137
137
|
pry-byebug (3.3.0)
|
138
138
|
byebug (~> 8.0)
|
139
139
|
pry (~> 0.10)
|
140
|
+
public_suffix (2.0.5)
|
140
141
|
puma (2.15.3)
|
141
142
|
rack (1.6.4)
|
142
143
|
rack-cache (1.6.1)
|
@@ -151,8 +152,8 @@ GEM
|
|
151
152
|
rake (10.4.2)
|
152
153
|
rake-compiler (0.9.5)
|
153
154
|
rake
|
154
|
-
rb-fsevent (0.9.
|
155
|
-
rb-inotify (0.9.
|
155
|
+
rb-fsevent (0.9.8)
|
156
|
+
rb-inotify (0.9.8)
|
156
157
|
ffi (>= 0.5.0)
|
157
158
|
rest-client (1.8.0)
|
158
159
|
http-cookie (>= 1.0.2, < 2.0)
|
@@ -175,7 +176,7 @@ GEM
|
|
175
176
|
crass (~> 1.0.2)
|
176
177
|
nokogiri (>= 1.4.4)
|
177
178
|
nokogumbo (~> 1.4.1)
|
178
|
-
sass (3.4.
|
179
|
+
sass (3.4.23)
|
179
180
|
simplecov (0.11.1)
|
180
181
|
docile (~> 1.1.0)
|
181
182
|
json (~> 1.8)
|
@@ -186,12 +187,12 @@ GEM
|
|
186
187
|
concurrent-ruby (~> 1.0)
|
187
188
|
rack (> 1, < 3)
|
188
189
|
stackprof (0.2.7)
|
189
|
-
stringex (2.6.
|
190
|
+
stringex (2.6.1)
|
190
191
|
term-ansicolor (1.3.2)
|
191
192
|
tins (~> 1.0)
|
192
193
|
thor (0.19.1)
|
193
|
-
thread_safe (0.3.
|
194
|
-
tilt (2.0.
|
194
|
+
thread_safe (0.3.6)
|
195
|
+
tilt (2.0.6)
|
195
196
|
timecop (0.8.0)
|
196
197
|
tins (1.6.0)
|
197
198
|
tzinfo (1.2.2)
|
@@ -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.1.
|
4
|
+
version: 1.1.2
|
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
|
@@ -773,6 +773,7 @@ files:
|
|
773
773
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
774
774
|
- spec/unit/middlewares/helpers_spec.rb
|
775
775
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
776
|
+
- spec/unit/middlewares/locale_spec.rb
|
776
777
|
- spec/unit/middlewares/private_access_spec.rb
|
777
778
|
- spec/unit/middlewares/renderer_spec.rb
|
778
779
|
- spec/unit/middlewares/site_spec.rb
|
@@ -1025,6 +1026,7 @@ test_files:
|
|
1025
1026
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
1026
1027
|
- spec/unit/middlewares/helpers_spec.rb
|
1027
1028
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
1029
|
+
- spec/unit/middlewares/locale_spec.rb
|
1028
1030
|
- spec/unit/middlewares/private_access_spec.rb
|
1029
1031
|
- spec/unit/middlewares/renderer_spec.rb
|
1030
1032
|
- spec/unit/middlewares/site_spec.rb
|