Sha256: ba31df2496f3ca51aef23bd771db0de9f24ee181c51174e9f9c87612d571b7df

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Page do

  let(:attributes) { {} }
  let(:page) { described_class.new(attributes) }

  describe '#index?' do

    let(:attributes) { { fullpath: { en: 'foo/index' } } }

    subject { page.index? }
    it { is_expected.to eq false }

    context 'true' do
      let(:attributes) { { fullpath: { en: 'index' } } }
      it { is_expected.to eq true }
    end

  end

  describe '#not_found?' do

    let(:attributes) { { fullpath: { en: 'index' } } }

    subject { page.not_found? }
    it { is_expected.to eq false }

    context 'true' do
      let(:attributes) { { fullpath: { en: '404' } } }
      it { is_expected.to eq true }
    end

  end

  describe '#valid?' do

    subject { page.valid? }
    it { is_expected.to eq true }

  end

  describe '#content_type_id' do

    let(:attributes) { { target_klass_name: '42' } }
    subject { page.content_type_id }

    it { is_expected.to eq '42' }

    context 'with a Locomotive Engine class name like' do
      let(:attributes) { { target_klass_name: 'Locomotive::ContentEntryBigNumber' } }
      it { is_expected.to eq 'BigNumber' }
    end
  end

  describe '#redirect?' do

    subject { page.redirect? }

    it { is_expected.to eq false }

    context 'redirect_url has been set' do

      let(:attributes) { { redirect: nil, redirect_url: 'http://www.google.fr' } }

      it { is_expected.to eq true }

      context 'but redirect is set to false' do

        let(:attributes) { { redirect: false, redirect_url: 'http://www.google.fr' } }

        it { is_expected.to eq false }

      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.1.1 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.1.0 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.1.0.rc3 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.1.0.rc2 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.1.0.rc1 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.1 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc10 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc9 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc8 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc6 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc4 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc3 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc2 spec/unit/entities/page_spec.rb
locomotivecms_steam-1.0.0.rc1 spec/unit/entities/page_spec.rb