2019-12-11 22:07:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'Bootstrapping the Discourse App' do
|
|
|
|
let(:ie_agent) { "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" }
|
|
|
|
|
|
|
|
context "when disabled" do
|
|
|
|
before do
|
2020-04-30 02:40:21 +08:00
|
|
|
SiteSetting.discourse_unsupported_browser_enabled = false
|
2019-12-11 22:07:22 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not include the IE stylesheet or Javascript" do
|
|
|
|
get "/categories", headers: { "HTTP_USER_AGENT" => ie_agent }
|
2020-04-30 02:40:21 +08:00
|
|
|
expect(response.body).not_to match(/discourse-unsupported-browser-optional.js/)
|
|
|
|
expect(response.body).not_to match(/stylesheets\/discourse-unsupported-browser/)
|
2019-12-11 22:07:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when enabled" do
|
|
|
|
before do
|
2020-04-30 02:40:21 +08:00
|
|
|
SiteSetting.discourse_unsupported_browser_enabled = true
|
2019-12-11 22:07:22 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "includes the IE js and css" do
|
|
|
|
get "/categories", headers: { "HTTP_USER_AGENT" => ie_agent }
|
2020-04-30 02:40:21 +08:00
|
|
|
expect(response.body).to match(/discourse-unsupported-browser-optional.js/)
|
|
|
|
expect(response.body).to match(/stylesheets\/discourse-unsupported-browser/)
|
2019-12-11 22:07:22 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't include IE stuff for non-IE browsers" do
|
|
|
|
get "/categories", headers: { "HTTP_USER_AGENT" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36" }
|
2020-04-30 02:40:21 +08:00
|
|
|
expect(response.body).not_to match(/discourse-unsupported-browser-optional.js/)
|
|
|
|
expect(response.body).not_to match(/stylesheets\/discourse-unsupported-browser/)
|
2019-12-11 22:07:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|