Sha256: 5017cedbe1fd2177a696620ba813fb8d092b66f4ad4c9cce82bb7eaf89f84dca

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

require "spec_helper"

module Refinery
  module Admin
    describe PagesHelper do
      describe "#template_options" do
        context "when page layout/view templte is set" do
          it "returns empty hash" do
            page = FactoryGirl.create(:page)

            page.view_template = "rspec_template"
            helper.template_options(:view_template, page).should eq({})

            page.layout_template = "rspec_layout"
            helper.template_options(:layout_template, page).should eq({})
          end
        end

        context "when page layout/view template isn't set" do
          context "when page has parent" do
            it "returns option hash based on parent page" do
              parent = FactoryGirl.create(:page, :view_template => "rspec_view",
                                                 :layout_template => "rspec_layout")
              page = FactoryGirl.create(:page, :parent_id => parent.id)

              expected_view = { :selected => parent.view_template }
              helper.template_options(:view_template, page).should eq(expected_view)

              expected_layout = { :selected => parent.layout_template }
              helper.template_options(:layout_template, page).should eq(expected_layout)
            end
          end

          context "when page doesn't have parent page" do
            before do
              Refinery::Pages.stub(:view_template_whitelist).and_return(%w(one two))
              Refinery::Pages.stub(:layout_template_whitelist).and_return(%w(two one))
            end

            it "returns option hash with first item from configured whitelist" do
              page = FactoryGirl.create(:page)

              expected_view = { :selected => "one" }
              helper.template_options(:view_template, page).should eq(expected_view)

              expected_layout = { :selected => "two" }
              helper.template_options(:layout_template, page).should eq(expected_layout)
            end
          end
        end
      end
    end
  end
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-pages-2.0.5 spec/helpers/refinery/pages/admin/pages_helper_spec.rb