Sha256: 1a090fa223fe80857b7518be9ae91f0b9363e6ec95d665dfd2b95e2ac730276c

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 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('')
    allow(view).to receive(:render_hint_for).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

11 entries across 11 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.3 spec/views/essences/essence_boolean_editor_spec.rb
lc_alchemy_cms-3.2.1 spec/views/essences/essence_boolean_editor_spec.rb
lc_alchemy_cms-3.2.0 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.2.0 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.2.0.rc1 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.2.0.beta spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.1 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.rc3 spec/views/essences/essence_boolean_editor_spec.rb
alchemy_cms-3.1.0.rc2 spec/views/essences/essence_boolean_editor_spec.rb