Sha256: bdb2a85cf6caaf73b1db05b50f6b3f0c68eb17c8932fe827f1177e04ff5aa2cf

Contents?: true

Size: 1.27 KB

Versions: 22

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

RSpec.describe Spotlight::Language do
  describe '#to_native' do
    it 'is the native translation of the locale' do
      expect(described_class.new(locale: 'de').to_native).to eq 'Deutsch'
    end

    it 'is a blank string when the locale does not exist (for string comparison)' do
      expect(described_class.new(locale: 'xx').to_native).to eq ''
    end
  end

  describe 'when being destroyed' do
    let(:exhibit) { FactoryBot.create(:exhibit) }
    let(:language) { described_class.create(locale: 'es', exhibit: exhibit) }

    before { Translation.current_exhibit = exhibit }

    it 'also destroys its locale related pages' do
      page_es = exhibit.home_page.clone_for_locale('es').tap(&:save)

      expect(Spotlight::Page.exists?(page_es.id)).to be true

      expect do
        language.destroy
      end.to change(Spotlight::Page, :count).by(-1)

      expect(Spotlight::Page.exists?(page_es.id)).to be false
    end

    it 'also destroys its locale related translations' do
      translation = FactoryBot.create(:translation, key: 'some.key', exhibit: exhibit, locale: 'es')

      expect do
        language.destroy
      end.to change(Translation, :count).by(-1)

      expect(Translation.exists?(translation.id)).to be false
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.3.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.2.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.1.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.3 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.2 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc4 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc3 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc2 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.rc1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.10 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.9 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.8 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.7 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.6 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.5 spec/models/spotlight/language_spec.rb