-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually set I18n.locale based on http header
- Loading branch information
Showing
7 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe LocaleDetector do | ||
|
||
subject { LocaleDetector.fallback_locale } | ||
|
||
it { should_not be_empty } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe LocaleDetector::Filter do | ||
|
||
def set_locale(opts = {}) | ||
filter = Object.new.extend(LocaleDetector::Filter) | ||
request = double('request', :env => { 'HTTP_ACCEPT_LANGUAGE' => opts[:language] }) | ||
filter.stub(:request).and_return(request) | ||
filter.send(:set_locale) | ||
end | ||
|
||
specify { set_locale(:language => nil).should eql(LocaleDetector.fallback_locale) } | ||
|
||
specify { set_locale(:language => 'pl').should eql('pl') } | ||
|
||
specify { set_locale(:language => 'pl-PL').should eql('pl') } | ||
|
||
specify { set_locale(:language => 'pl,en-us;q=0.7,en;q=0.3').should eql('pl') } | ||
|
||
specify { set_locale(:language => 'lt,en-us;q=0.8,en;q=0.6,ru;q=0.4,pl;q=0.2').should eql('lt') } | ||
|
||
specify { set_locale(:language => 'pl-PL;q=0.1,en-us;q=0.7,en;q=0.3').should eql('en') } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$:.unshift(File.dirname(__FILE__)) | ||
|
||
require 'rails' | ||
require 'locale_detector' | ||
|
||
RSpec.configure do |config| | ||
config.mock_with :rspec | ||
end |