Sha256: 0c92d0e2f982ce66293b40b83ac00cd2a57807c989e2612203f86c489c2019cc

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

include Alchemy::BaseHelper

describe Alchemy::Admin::ElementsHelper do

  before(:each) do
    @page = FactoryGirl.create(:public_page)
    @element = FactoryGirl.create(:element, :page => @page)
  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 editor partial" do
    helper.render_picture_editor(@element).should match(/class="essence_picture_editor"/)
  end

  describe "#grouped_elements_for_select" do

    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

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-2.2.4 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.3.2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.3.1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.0 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc15 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc14 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc13 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc11 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc8 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.2.rc7 spec/helpers/admin/elements_helper_spec.rb