Sha256: 528c94b1abc1611c936cd237a19f1dda6ef86324bfe1a09dd620ff1e822d13a8

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 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(: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

3 entries across 3 versions & 1 rubygems

Version Path
archangel-0.0.8 spec/models/archangel/site_spec.rb
archangel-0.0.7 spec/models/archangel/site_spec.rb
archangel-0.0.6 spec/models/archangel/site_spec.rb