Sha256: 156e59ce4b9999955d3d5684b1f09ed98d3833a429345cfb84e009a150c123a6

Contents?: true

Size: 1.21 KB

Versions: 27

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spotlight::CloneTranslatedPageFromLocale do
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let!(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
  let!(:language) { FactoryBot.create(:language, locale: 'es', exhibit: exhibit) }
  subject(:clone) { described_class.call(locale: language.locale, page: page) }

  it 'clones the exhibit home page for a particular exhibit' do
    expect(Spotlight::Page.where(locale: 'es')).not_to be_present
    expect { clone.save }.to change(Spotlight::Page, :count).by(1)
    expect(Spotlight::Page.unscope(:order).last.locale).to eq 'es'
  end

  context 'when a translated page already exists for that locale' do
    let(:translated_page) { page.clone_for_locale('es') }

    it 'destroys it first' do
      expect(Spotlight::Page.where(locale: 'es')).not_to be_present
      translated_page.save!
      expect(Spotlight::Page.where(locale: 'es').count).to eq 1
      expect { clone.save! }.to change(Spotlight::Page, :count).by(0) # because it deletes one and adds one
      expect(Spotlight::Page.where(locale: 'es').count).to eq 1
      expect(Spotlight::Page.unscope(:order).last.locale).to eq 'es'
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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