Sha256: 6cabf64ad90c4fa580c74ba90b22fab4685327b0b5edcc36910ab2d33a97f803

Contents?: true

Size: 1.44 KB

Versions: 13

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

include Alchemy::BaseHelper

describe Alchemy::Admin::ElementsHelper do

	before(:each) do
		@page = Factory(:public_page)
	  @element = Factory(: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({"FooCell"=>[["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

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-2.1.5 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.4 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.3 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.rc6 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.rc5 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.rc4 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.rc3 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.rc2 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.beta6 spec/helpers/admin/elements_helper_spec.rb
alchemy_cms-2.1.beta5 spec/helpers/admin/elements_helper_spec.rb