Sha256: 577bc17ca2b0db0852a0e16237ec1ce800aa1cd671fc422bcc17f43b42b418b8

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper"

class MarkdownPlusFilter
  # dummy filter class
end

describe Admin::PagesHelper do
  dataset :users_and_pages

  before :each do
    @page = mock_model(Page)
    @errors = mock("errors")
    @page.stub!(:errors).and_return(@errors)
    helper.stub!(:image).and_return('')
    helper.stub!(:admin?).and_return(true)
    helper.instance_variable_set(:@page, @page)
  end

  it "should have meta errors if the page has errors on the slug" do
    @errors.should_receive(:[]).with(:slug).and_return("Error")
    helper.meta_errors?.should be_true
  end

  it "should have meta errors if the page has errors on the breadcrumb" do
    @errors.should_receive(:[]).with(:slug).and_return(nil)
    @errors.should_receive(:[]).with(:breadcrumb).and_return("Error")
    helper.meta_errors?.should be_true
  end

  it "should render the tag reference" do
    helper.should_receive(:render).at_least(:once).and_return("Tag Reference")
    helper.tag_reference.should =~ /Tag Reference/
  end

  describe "filter_reference" do
    it "should determine the filter reference from the first part on the current page" do
      helper.instance_variable_set :@page, pages(:home)
      helper.filter.should be_kind_of(TextFilter)
    end
    
    it "should render the filter reference for complex filter names" do
      MarkdownPlusFilter.stub!(:description).and_return("Markdown rocks!")
      helper.stub!(:filter).and_return(MarkdownPlusFilter)
      helper.filter_reference.should == "Markdown rocks!"
    end
  end

  it "should have a default filter name" do
    @page.should_receive(:parts).and_return([])
    helper.default_filter_name.should == ""
  end

  it "should find the homepage" do
    helper.homepage.should == pages(:home)
  end
  
  it "should render javascript for the page editing form" do
    helper.should respond_to(:page_edit_javascripts)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
radiant-1.1.4 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.3 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.2 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.1 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.0 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.0.rc1 spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.0.beta spec/helpers/admin/pages_helper_spec.rb
radiant-1.1.0.alpha spec/helpers/admin/pages_helper_spec.rb