Updated

spec/requests / cache_control_header_spec.rb

C
80 lines of codes
0 methods
N/A complexity/method
3 churn
154.57 complexity
38 duplications
require 'rails_helper' RSpec.describe 'Cache-Control headers', type: :request do let(:cache_control) { response.headers['Cache-Control'] } let(:status) { response.status } context "when visiting the petition index page" do before do
  1. Similar code found in 2 nodes Locations: 0 1
get "/petitions" end it "doesn't change the cache control headers" do expect(cache_control).to eq("max-age=0, private, must-revalidate") expect(status).to eq(200) end end context "when visiting the petition show page" do let!(:petition) { FactoryBot.create(:open_petition) } before do get "/petitions/#{petition.id}" end it "doesn't change the cache control headers" do expect(cache_control).to eq("max-age=0, private, must-revalidate") expect(status).to eq(200) end end context "when visiting the new petition page" do let!(:petition) { FactoryBot.create(:open_petition) } before do get "/petitions/new" end it "changes the cache control headers to 'no-store, no-cache'" do expect(cache_control).to eq("no-store, no-cache") expect(status).to eq(200) end end context "when visiting the new sponsor page" do let!(:petition) { FactoryBot.create(:pending_petition) } before do get "/petitions/#{petition.id}/sponsors/new?token=#{petition.sponsor_token}" end it "changes the cache control headers to 'no-store, no-cache'" do expect(cache_control).to eq("no-store, no-cache") expect(status).to eq(200) end end context "when visiting the new signature page" do let!(:petition) { FactoryBot.create(:open_petition) } before do get "/petitions/#{petition.id}/signatures/new" end it "changes the cache control headers to 'no-store, no-cache'" do expect(cache_control).to eq("no-store, no-cache") expect(status).to eq(200) end end context "when visiting an admin page", admin: true do before do
  1. Similar code found in 2 nodes Locations: 0 1
get "/admin/login" end it "changes the cache control headers to 'no-store, no-cache'" do expect(cache_control).to eq("no-store, no-cache") expect(status).to eq(200) end end end