docbrown/spec/requests/service_worker_spec.rb
Ben Halpern 73125c0795
Reduce service worker functionality to minimal offline page (#12834)
* Reduce service worker functionality to minimal offline page

* Update docs for service workers

* Add comment to fix test

* Include incrementable static cache

* Add TODO comments about removal

* Fix trailing whitespace
2021-03-01 19:29:26 -05:00

37 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "ServiceWorker", type: :request do
describe "GET /serviceworker.js" do
it "renders file with proper text" do
get "/serviceworker.js"
expect(response.body).to include("Service worker file")
end
it "renders javascript file" do
get "/serviceworker.js"
expect(response.header["Content-Type"]).to include("text/javascript")
end
it "sends a surrogate key (for Fastly's user)" do
get "/serviceworker.js"
expect(response.header["Surrogate-Key"]).to include("serviceworker-js")
end
end
describe "GET /manifest.json" do
it "renders file with proper text" do
get "/manifest.json"
expect(response.body).to include("\"name\": \"#{SiteConfig.community_name}\"")
end
it "renders json file" do
get "/manifest.json"
expect(response.header["Content-Type"]).to include("application/json")
end
it "sends a surrogate key (for Fastly's user)" do
get "/manifest.json"
expect(response.header["Surrogate-Key"]).to include("manifest-json")
end
end
end