feat(application_controller): add method to check if request is on app_host_legacy?

This commit is contained in:
Martin 2024-02-23 10:42:23 +01:00
parent 85eef97392
commit 8ca853c79c
2 changed files with 32 additions and 0 deletions

View file

@ -1,4 +1,27 @@
describe ApplicationHelper do
describe 'app_host_legacy?' do
let(:request) { instance_double(ActionDispatch::Request, base_url: request_base_url) }
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
subject { app_host_legacy?(request) }
context '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
let(:request_base_url) { app_host }
it { is_expected.to be_falsey }
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' }