Sha256: d5b81fd1fc00fea323a1fbbad9d9861441a34b4c3046444db9d4bac4d820c485

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe Site, type: :model do
    context "validations" do
      it { is_expected.to validate_presence_of(:locale) }
      it { is_expected.to validate_presence_of(:name) }

      it { is_expected.to allow_value("").for(:theme) }

      it "allows certain languages" do
        expect(subject)
          .to validate_inclusion_of(:locale).in_array(Archangel::LANGUAGES)
      end

      it "allows certain languages" do
        expect(subject)
          .to validate_inclusion_of(:theme).in_array(Archangel.themes)
      end
    end

    it { is_expected.to have_many(:assets) }
    it { is_expected.to have_many(:collections) }
    it { is_expected.to have_many(:metatags) }
    it { is_expected.to have_many(:pages) }
    it { is_expected.to have_many(:templates) }
    it { is_expected.to have_many(:users) }
    it { is_expected.to have_many(:widgets) }

    it { is_expected.to have_many(:entries).through(:collections) }
    it { is_expected.to have_many(:fields).through(:collections) }

    context ".current" do
      it "returns an existing object" do
        resource = create(:site, name: "My Awesome New Site")

        expect(described_class.current).to eq(resource)
        expect(described_class.current.name).to eq("My Awesome New Site")
      end

      it "returns a new object" do
        expect(described_class.current.name).to eq("Archangel")
      end
    end

    context "#to_liquid" do
      it "returns a Liquid object" do
        resource = build(:site)

        expect(resource.to_liquid).to be_a(Archangel::Liquid::Drops::SiteDrop)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.3.0 spec/models/archangel/site_spec.rb