Sha256: ecc9954d6b28c9d5758976a8c08326309070974720a2b2721a2a9c6e642f8d5b

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe Qbrick::Cms::PagesHelper, type: :helper do
  describe '#content_tab_active' do
    it 'returns active when page has a title and no errors' do
      @page = create(:page, title: 'Page 1', slug: 'page1')
      expect(helper.content_tab_active(@page)).to be(:active)
    end

    it 'returns nil when page has no translation' do
      @page = create(:page, title: 'Page 1', slug: 'page1')
      I18n.with_locale :de do
        expect(helper.content_tab_active(@page)).to be_nil
      end
    end
  end

  describe '#metadata_tab_active' do
    it 'returns active when page is not translated' do
      @page = create(:page, title: 'Page 1', slug: 'page1')
      I18n.with_locale :de do
        expect(helper.metadata_tab_active(@page)).to be(:active)
      end
    end
  end

  describe '#hide_content_tab?' do
    it 'has a page without translations' do
      @page = create(:page, title: 'Page 1', slug: 'page1')
      I18n.with_locale :de do
        expect(helper.hide_content_tab?(@page)).to be_truthy
      end
    end

    it 'has a redirect page' do
      @page = create(:page, title: 'Page 1', slug: 'page1',
                            page_type: Qbrick::PageType::REDIRECT, redirect_url: 'en/references')
      expect(helper.hide_content_tab?(@page)).to be_truthy
    end

    it 'has a not saved page' do
      @page = Qbrick::Page.new
      expect(helper.hide_content_tab?(@page)).to be_truthy
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qbrick-2.6.0 spec/helpers/qbrick/cms/pages_helper_spec.rb
qbrick-2.5.2 spec/helpers/qbrick/cms/pages_helper_spec.rb
qbrick-2.5.1 spec/helpers/qbrick/cms/pages_helper_spec.rb
qbrick-2.5.0 spec/helpers/qbrick/cms/pages_helper_spec.rb