Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
@@ -16,49 +16,24 @@ describe ApplicationController, type: :controller do
|
||||
end
|
||||
|
||||
shared_examples 'default locale' do
|
||||
context 'when DEFAULT_LOCALE environment variable is set' do
|
||||
around do |example|
|
||||
ClimateControl.modify 'DEFAULT_LOCALE' => 'ca', &example.method(:run)
|
||||
I18n.locale = I18n.default_locale
|
||||
end
|
||||
after { I18n.locale = I18n.default_locale }
|
||||
|
||||
it 'sets language specified by ENV if preferred' do
|
||||
request.headers['Accept-Language'] = 'ca, fa'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :ca
|
||||
end
|
||||
|
||||
it 'sets available and preferred language if language specified by ENV is not preferred' do
|
||||
request.headers['Accept-Language'] = 'ca-ES, fa'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :fa
|
||||
end
|
||||
|
||||
it 'sets language specified by ENV if it is compatible and none of available languages are preferred' do
|
||||
request.headers['Accept-Language'] = 'ca-ES, fa-IR'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :ca
|
||||
end
|
||||
|
||||
it 'sets available and compatible langauge if language specified by ENV is not compatible none of available languages are preferred' do
|
||||
request.headers['Accept-Language'] = 'fa-IR'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :fa
|
||||
end
|
||||
|
||||
it 'sets language specified by ENV if none of available languages are compatible' do
|
||||
request.headers['Accept-Language'] = ''
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :ca
|
||||
end
|
||||
it 'sets available and preferred language' do
|
||||
request.headers['Accept-Language'] = 'ca-ES, fa'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :fa
|
||||
end
|
||||
|
||||
context 'when DEFAULT_LOCALE environment variable is not set' do
|
||||
it 'sets default locale if none of available languages are compatible' do
|
||||
request.headers['Accept-Language'] = ''
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :en
|
||||
end
|
||||
it 'sets available and compatible langauge if none of available languages are preferred' do
|
||||
request.headers['Accept-Language'] = 'fa-IR'
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :fa
|
||||
end
|
||||
|
||||
it 'sets default locale if none of available languages are compatible' do
|
||||
request.headers['Accept-Language'] = ''
|
||||
get 'success'
|
||||
expect(I18n.locale).to eq :en
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -4,21 +4,24 @@ RSpec.describe HomeController, type: :controller do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
subject { get :index }
|
||||
|
||||
context 'when not signed in' do
|
||||
context 'when requested path is tag timeline' do
|
||||
before { @request.path = '/web/timelines/tag/name' }
|
||||
it { is_expected.to redirect_to '/tags/name' }
|
||||
end
|
||||
|
||||
it 'redirects to about page' do
|
||||
@request.path = '/'
|
||||
get :index
|
||||
expect(response).to redirect_to(about_path)
|
||||
is_expected.to redirect_to(about_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when signed in' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
subject do
|
||||
sign_in(user)
|
||||
get :index
|
||||
end
|
||||
before { sign_in(user) }
|
||||
|
||||
it 'assigns @body_classes' do
|
||||
subject
|
||||
|
Reference in New Issue
Block a user