Sha256: 0cae4d49a3fdc5e6522d2f6b5d2e2031415d3225b191c592f7110c9ac2ddcd10

Contents?: true

Size: 1.05 KB

Versions: 23

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Models::I18nField do

  let(:name)          { 'title' }
  let(:translations)  { nil }
  let(:field)         { described_class.new(name, translations) }

  describe '#blank?' do

    subject { field.blank? }

    it { is_expected.to eq true }

    context 'with translations' do

      let(:translations) { { en: 'Hello world', fr: nil } }

      it { is_expected.to eq false }

    end

    context 'with a single value' do

      let(:translations) { 'Hello world' }

      it { is_expected.to eq false }

    end

  end

  describe '#dup' do

    let(:translations) { { en: 'Hello world', fr: nil } }

    subject { field.dup }

    it 'gets a fresh copy of the translations' do
      expect(subject[:en]).to eq 'Hello world'
      expect(subject.translations.object_id).not_to eq field.translations.object_id
    end

  end

  describe '#to_json' do

    let(:translations) { { en: 'Hello world', fr: nil } }

    subject { field.to_json }

    it { is_expected.to eq("{\"en\":\"Hello world\",\"fr\":null}") }

  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.7.1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.7.0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.6.1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.6.0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.3 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.2 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0.rc0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0.beta3 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.4.1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.4.0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/models/i18n_field_spec.rb