Sha256: ecb90fe722c7b0f526264b0c1508fe39550e6a779af8d83736428fffad65773f

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Kms::PageFetcher, type: :service do
  describe '#fetch' do
    subject { Kms::PageFetcher.new('about') }
    context 'when there"s a page with exact fullpath' do
      it "returns current page drop by given path" do
        page = FactoryGirl.create(:page)
        fetcher = Kms::PageFetcher.new(page.slug)
        result_page = fetcher.fetch!
        expect(result_page).to be_instance_of(Kms::PageDrop)
        expect(result_page.source).to be_eql(page)
      end
    end
    context 'when there"s a templatable page responding to path' do
      it "returns templatable page for this path" do
        snippet = FactoryGirl.create(:snippet, slug: 'about')
        templatable_page = FactoryGirl.create(:templatable_page)
        result_page = subject.fetch!
        expect(result_page.source.templatable).to be true
      end
    end
    context 'when no page for path but 404 page exists' do
      it "returns 404 page" do
        page_404 = FactoryGirl.create(:page_404)
        result_page = subject.fetch!
        expect(result_page.slug).to be_eql('404')
      end
    end
    context 'when no page and no special 404 page' do
      it 'raises RecordNotFound exception' do
        expect {subject.fetch!}.to raise_error(ActiveRecord::RecordNotFound)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kms-1.2.1 spec/services/kms/page_fetcher_spec.rb
kms-1.2.0 spec/services/kms/page_fetcher_spec.rb
kms-1.1.0 spec/services/kms/page_fetcher_spec.rb
kms-1.0.1 spec/services/kms/page_fetcher_spec.rb
kms-1.0.0 spec/services/kms/page_fetcher_spec.rb