rack-locale_chooser 0.0.13 → 0.0.14
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.
- data/Gemfile.lock +1 -1
- data/lib/rack-locale_chooser/version.rb +1 -1
- data/lib/rack-locale_chooser.rb +1 -1
- data/spec/rack-locale_chooser_spec.rb +13 -17
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/rack-locale_chooser.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'logger'
|
2
3
|
|
3
4
|
describe Rack::LocaleChooser do
|
4
5
|
def app
|
5
6
|
app = Rack::Builder.new {
|
6
|
-
use Rack::LocaleChooser::Chooser, :
|
7
|
-
|
7
|
+
use Rack::LocaleChooser::Chooser, :logger => Logger.new('log/locale.log'),
|
8
|
+
:host_mappings => { :es => 'es.example.com',
|
9
|
+
:pt_BR => 'br.example.com' },
|
8
10
|
:country_mappings => { 'VE' => :es }
|
9
11
|
run BasicRackApp.new
|
10
12
|
}
|
@@ -19,10 +21,7 @@ describe Rack::LocaleChooser do
|
|
19
21
|
get 'http://example.com/', {}, 'HTTP_COOKIE' => 'locale=es'
|
20
22
|
last_response.status.should == 301
|
21
23
|
last_response.headers['Location'].should == 'http://es.example.com/'
|
22
|
-
|
23
|
-
|
24
|
-
it "should be redirected folling geolocation" do
|
25
|
-
get 'http://example.com', {}
|
24
|
+
I18n.locale.should == :es
|
26
25
|
end
|
27
26
|
|
28
27
|
it "should be redirected following HTTP_ACCEPT_LANGUAGE headers" do
|
@@ -32,25 +31,22 @@ describe Rack::LocaleChooser do
|
|
32
31
|
I18n.locale.should == :es
|
33
32
|
end
|
34
33
|
|
35
|
-
it "should map locale to explicit domain mappings" do
|
36
|
-
get 'http://example.com/', {}, 'HTTP_ACCEPT_LANGUAGE' => 'en'
|
37
|
-
last_response.status.should == 301
|
38
|
-
last_response.headers['Location'].should == 'http://us.example.com/'
|
39
|
-
I18n.locale.should == :en
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
34
|
it "should map locale to explicit location mappings by country level" do
|
44
|
-
get 'http://example.com/', {}, 'REMOTE_ADDR' => '200.1.1.2' #
|
35
|
+
get 'http://example.com/', {}, 'REMOTE_ADDR' => '200.1.1.2' # VE
|
45
36
|
last_response.status.should == 301
|
46
37
|
last_response.headers['Location'].should == 'http://es.example.com/'
|
38
|
+
I18n.locale.should == :es
|
47
39
|
end
|
48
40
|
|
41
|
+
it "should map locale to default if location mappings by country level not found" do
|
42
|
+
get 'http://example.com/', {}, 'REMOTE_ADDR' => '174.141.155.106' # US
|
43
|
+
last_response.status.should == 200
|
44
|
+
I18n.locale.should == :en
|
45
|
+
end
|
49
46
|
|
50
47
|
it "fall back to default if accept language headers not on mappings" do
|
51
48
|
get 'http://example.com/', {}, 'HTTP_ACCEPT_LANGUAGE' => 'ru'
|
52
|
-
last_response.status.should ==
|
53
|
-
last_response.headers['Location'].should == 'http://us.example.com/'
|
49
|
+
last_response.status.should == 200
|
54
50
|
I18n.locale.should == :en
|
55
51
|
end
|
56
52
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-locale_chooser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 14
|
10
|
+
version: 0.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jefferson Jean Martins Gir\xC3\xA3o"
|