Sha256: d50ad4e5baf30b6d2b4f51669c61078fa641bd8bf79e0c7ac85e10b81c4eba14

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe 'alchemy/essences/_essence_boolean_editor' do
  let(:essence) { Alchemy::EssenceBoolean.new(ingredient: false) }
  let(:content) { Alchemy::Content.new(essence: essence, name: 'Boolean') }

  before do
    allow(view).to receive(:render_content_name).and_return(content.name)
    allow(view).to receive(:delete_content_link).and_return('')
  end

  it "renders a checkbox" do
    render partial: "alchemy/essences/essence_boolean_editor", locals: {content: content}
    expect(rendered).to have_selector('input[type="checkbox"]')
  end

  context 'with default value given in view local options' do
    it "checks the checkbox" do
      render partial: "alchemy/essences/essence_boolean_editor", locals: {content: content, options: {default_value: true}}
      expect(rendered).to have_selector('input[type="checkbox"][checked="checked"]')
    end
  end

  context 'with default value given in content settings' do
    before { allow(content).to receive(:settings).and_return({default_value: true}) }

    it "checks the checkbox" do
      render partial: "alchemy/essences/essence_boolean_editor", locals: {content: content}
      expect(rendered).to have_selector('input[type="checkbox"][checked="checked"]')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alchemy_cms-3.1.0.rc1 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta6 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta5 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta4 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta3 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta2 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.beta1 spec/views/essences/essence_boolean_editor_spec.rb