Sha256: b33778d162fc01296950bf29e5e02c3ba7040d596d6faf18f59081ef597c8fc4

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

include Alchemy::BaseHelper

describe Alchemy::Admin::ElementsHelper do

  context "partial rendering" do

    before do
      @page = FactoryGirl.create(:public_page)
      @element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
    end

    it "should render an element editor partial" do
      helper.render_editor(@element).should match(/class="content_editor".+id="essence_text_\d{1,}"/)
    end

    it "should render a picture gallery editor partial" do
      helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
    end

  end

  describe "#grouped_elements_for_select" do

    before do
      @page = FactoryGirl.create(:public_page)
    end

    before(:each) do
      @page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
      cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
      @elements = [{'name' => '1'}, {'name' => '2'}]
      Alchemy::Cell.stub!(:definitions).and_return(cell_descriptions)
    end

    it "should return string of elements grouped by cell for select_tag helper" do
      helper.grouped_elements_for_select(@elements).should == helper.grouped_options_for_select({"Foo cell" => [["1", "1#foo_cell"], ["2", "2#foo_cell"]]})
    end

    context "with empty elements array" do
      it "should return an empty string" do
        helper.grouped_elements_for_select([]).should == ""
      end
    end

    context "with empty cell definitions" do
      it "should return an empty string" do
        @page.stub!(:layout_description).and_return({'name' => "foo"})
        helper.grouped_elements_for_select(@elements).should == ""
      end
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-2.3.2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.4.0 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.4.rc4 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.4.rc2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.4.rc1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.3.1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.4.beta2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.3.0 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.3.rc5 spec/helpers/admin/elements_helper_spec.rb