Sha256: 04473c44d900748e5a35693edaaf444777303a12b8aea6fa79eb9b242359bb5e

Contents?: true

Size: 1.26 KB

Versions: 36

Compression:

Stored size: 1.26 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

36 entries across 36 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 spec/models/spotlight/language_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.13.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.12.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.12.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.11.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.10.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.9.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.8.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.7.2 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.7.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.7.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.6.1.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.6.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.6.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.5.2 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.5.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.5.0 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.4.1 spec/models/spotlight/language_spec.rb
blacklight-spotlight-2.4.0 spec/models/spotlight/language_spec.rb