diff options
author | Jenkins <jenkins@jenkins.ninjawedding.org> | 2018-03-09 00:17:17 +0000 |
---|---|---|
committer | Jenkins <jenkins@jenkins.ninjawedding.org> | 2018-03-09 00:17:17 +0000 |
commit | 447d7e612753d69f043e08ebb228b21e411c8b4a (patch) | |
tree | 80caebcff2b131898f620f89ad0858d44530d30f /spec/controllers | |
parent | 43a9a781a443a6b9296431fbcc4285b3ca6a1a57 (diff) | |
parent | ff44b2e92d496c6027b20157fea6ebd885906bea (diff) |
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/concerns/localized_spec.rb | 53 | ||||
-rw-r--r-- | spec/controllers/home_controller_spec.rb | 15 |
2 files changed, 23 insertions, 45 deletions
diff --git a/spec/controllers/concerns/localized_spec.rb b/spec/controllers/concerns/localized_spec.rb index c917ce85e..f71c96aff 100644 --- a/spec/controllers/concerns/localized_spec.rb +++ b/spec/controllers/concerns/localized_spec.rb @@ -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 available and preferred language' do + request.headers['Accept-Language'] = 'ca-ES, fa' + 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 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 - 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 default locale if none of available languages are compatible' do + request.headers['Accept-Language'] = '' + get 'success' + expect(I18n.locale).to eq :en end end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 1077a7288..f43cf0c27 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -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 |