Sha256: f355060951f965ffedf510866daeb6ddf87740c41126bf34be6c05944e0a5f57

Contents?: true

Size: 1.7 KB

Versions: 9

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe Alchemy::Admin::ContentsHelper do
  let(:element) { build_stubbed(:element, name: 'article') }
  let(:content) { mock_model('Content', essence_partial_name: 'essence_text') }

  describe 'render_content_name' do
    let(:content) do
      mock_model 'Content',
        name: 'intro',
        description: {name: 'intro', type: 'EssenceText'},
        name_for_label: 'Intro',
        has_validations?: false
    end
    subject { helper.render_content_name(content) }

    it "returns the content name" do
      should == "Intro"
    end

    context 'if content is nil' do
      let(:content) { nil }

      it "returns nil" do
        should be_nil
      end
    end

    context 'with missing description' do
      before { content.stub(description: {}) }

      it "renders a warning" do
        should have_selector('span.warning')
        should have_content('Intro')
      end
    end

    context 'with validations' do
      before { content.stub(has_validations?: true) }

      it "show a validation indicator" do
        should have_selector('.validation_indicator')
      end
    end
  end

  describe 'render_new_content_link' do
    subject { helper.render_new_content_link(element) }

    it "renders a link to add new content to element" do
      helper.stub(:render_icon).and_return('')
      should match(/a.+href.*admin\/elements\/#{element.id}\/contents\/new/m)
    end
  end

  describe 'render_create_content_link' do
    subject { helper.render_create_content_link(element, 'headline') }

    it "should render a link to create a content in element" do
      helper.stub(:render_icon).and_return('')
      should have_selector('a.new_content_link[data-method="post"]')
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.3 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.2 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.1 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.0 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.0.rc8 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.0.rc7 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.0.rc6 spec/helpers/admin/contents_helper_spec.rb
alchemy_cms-3.0.0.rc5 spec/helpers/admin/contents_helper_spec.rb