spec/models/refinery/page_spec.rb in refinerycms-pages-2.0.4 vs spec/models/refinery/page_spec.rb in refinerycms-pages-2.0.5
- old
+ new
@@ -1,5 +1,6 @@
+# encoding: utf-8
require 'spec_helper'
module Refinery
describe Page do
@@ -98,9 +99,44 @@
page.save
page.reload
page.url[:id].should be_nil
page.url[:path].should == ['rspec-is-great']
+ end
+ end
+
+ describe '#canonical' do
+ before do
+ ::Refinery::I18n.stub(:default_frontend_locale).and_return(:en)
+ ::Refinery::I18n.stub(:frontend_locales).and_return([Refinery::I18n.default_frontend_locale, :ru])
+ ::Refinery::I18n.stub(:current_frontend_locale).and_return(Refinery::I18n.default_frontend_locale)
+
+ page.save
+ end
+ let(:page_title) { 'team' }
+ let(:child_title) { 'about' }
+ let(:ru_page_title) { 'Новости' }
+ let!(:default_canonical) {
+ Globalize.with_locale(::Refinery::I18n.default_frontend_locale) {
+ page.canonical
+ }
+ }
+
+ specify 'page returns itself' do
+ page.canonical.should == page.url
+ end
+
+ specify 'default canonical matches page#canonical' do
+ default_canonical.should == page.canonical
+ end
+
+ specify 'translated page returns master page' do
+ Globalize.with_locale(:ru) do
+ page.title = ru_page_title
+ page.save
+
+ page.canonical.should == default_canonical
+ end
end
end
context 'custom slugs' do
let(:custom_page_slug) { 'custom-page-slug' }