feat(cross-domain-redirect): redirect to APP_HOST when user is on APP_HOST_LEGACY
This commit is contained in:
parent
8ca853c79c
commit
a13594792a
4 changed files with 64 additions and 2 deletions
|
@ -11,17 +11,63 @@ describe ApplicationHelper do
|
|||
|
||||
subject { app_host_legacy?(request) }
|
||||
|
||||
context 'request on ENV[APP_HOST_LEGACY]' do
|
||||
context 'when request on ENV[APP_HOST_LEGACY]' do
|
||||
let(:request_base_url) { app_host_legacy }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'request on ENV[APP_HOST]' do
|
||||
context 'when request on ENV[APP_HOST]' do
|
||||
let(:request_base_url) { app_host }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'auto_switch_domain?' do
|
||||
subject { auto_switch_domain?(request, user_signed_in) }
|
||||
|
||||
context 'when user_signed_in? is true' do
|
||||
let(:user_signed_in) { true }
|
||||
let(:request) { instance_double(ActionDispatch::Request, base_url: 'osf', params: {}) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'when user_signed_in? is false' do
|
||||
let(:user_signed_in) { false }
|
||||
let(:params) { {} }
|
||||
let(:request) { instance_double(ActionDispatch::Request, base_url: request_base_url, params:) }
|
||||
let(:app_host_legacy) { 'legacy' }
|
||||
let(:app_host) { 'host' }
|
||||
|
||||
before do
|
||||
stub_const("ApplicationHelper::APP_HOST_LEGACY", app_host_legacy)
|
||||
stub_const("ApplicationHelper::APP_HOST", app_host)
|
||||
end
|
||||
|
||||
context 'request on ENV[APP_HOST_LEGACY] without feature or url' do
|
||||
let(:request_base_url) { app_host_legacy }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'request on ENV[APP_HOST_LEGACY] with switch_domain params' do
|
||||
let(:params) { { switch_domain: '1' } }
|
||||
let(:request_base_url) { app_host_legacy }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'request on ENV[APP_HOST_LEGACY] with switch_domain params' do
|
||||
before { Flipper.enable :switch_domain }
|
||||
after { Flipper.disable :switch_domain }
|
||||
let(:request_base_url) { app_host_legacy }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'request on ENV[APP_HOST]' do
|
||||
let(:request_base_url) { app_host }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#flash_class" do
|
||||
it { expect(flash_class('notice')).to eq 'alert-success' }
|
||||
it { expect(flash_class('alert', sticky: true, fixed: true)).to eq 'alert-danger sticky alert-fixed' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue