Sha256: 5ffbd2e3ca0c3b662a143a5bc8259f040a3257f8950744a787dcb974331b687f
Contents?: true
Size: 1.24 KB
Versions: 26
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' describe Locomotive::Extensions::Site::Locales do let(:site) { FactoryGirl.build(:site, locales: [:en, :fr]) } describe '#localized_page_fullpath' do context 'index page' do let(:page) { build_page } it 'returns an empty string if default locale' do site.localized_page_fullpath(page).should == '' end it 'returns only the locale if another locale ' do site.localized_page_fullpath(page, 'fr').should == 'fr' end end context 'another page' do let(:page) { build_page('about-us', { fr: 'a-notre-sujet' }) } it 'returns only the fullpath if default locale' do site.localized_page_fullpath(page).should == 'about-us' end it 'returns the fullpath if another locale' do site.localized_page_fullpath(page, 'fr').should == 'fr/a-notre-sujet' end end end def build_page(slug = nil, translations = {}) FactoryGirl.build(:page).tap do |page| page.slug = slug if slug page.send(:build_fullpath) translations.each do |locale, translation| ::Mongoid::Fields::I18n.with_locale(locale) do page.slug = translation page.send(:build_fullpath) end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems