Sha256: a54a48df17be4a9ffcdbb1ab1f50e7b8e6708a72bc9a1ae289097e8d5a43acae

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Frontend - Homepage (HTML)", type: :request do
  describe "with available homepage" do
    it "returns successfully" do
      create(:page, :homepage)

      get "/"

      expect(response).to have_http_status(:ok)
    end
  end

  describe "with unavailable homepage" do
    it "returns 404 when homepage is unpublished" do
      create(:page, :homepage, :unpublished)

      get "/"

      expect(response).to have_http_status(:not_found)
    end

    it "returns 404 when homepage is future published" do
      create(:page, :homepage, :future)

      get "/"

      expect(response).to have_http_status(:not_found)
    end

    it "returns 404 when homepage is deleted" do
      create(:page, :homepage, :deleted)

      get "/"

      expect(response).to have_http_status(:not_found)
    end
  end

  describe "with multiple homepages" do
    before do
      create(:page, :homepage, content: "Amazing")

      second_homepage = create(:page, content: "Grace")
      second_homepage.update_column(:homepage, true)
    end

    it "returns the first available" do
      get "/"

      expect(response.body).to include("Amazing")
    end

    it "does not return the second available" do
      get "/"

      expect(response.body).not_to include("Grace")
    end
  end

  describe "without a homepage" do
    it "returns 404 status" do
      get "/"

      expect(response).to have_http_status(:not_found)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/requests/frontend/html/homepage_spec.rb