From 6619d4e5dc40fe90e53728322399be156ca91b3c Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Thu, 16 Feb 2012 02:45:14 +0100 Subject: [PATCH] all the non-models specs have been fixed --- lib/locomotive/liquid/drops/content_entry.rb | 2 +- lib/locomotive/liquid/drops/page.rb | 2 +- lib/locomotive/liquid/tags/nav.rb | 3 ++- .../middlewares/seo_trailing_slash.rb | 2 +- spec/lib/locomotive/httparty/patches_spec.rb | 19 ------------------- spec/lib/locomotive/liquid/drops/page_spec.rb | 7 ++++--- spec/lib/locomotive/liquid/tags/nav_spec.rb | 12 +++++++++++- spec/lib/locomotive/liquid/tags/seo_spec.rb | 4 ++-- spec/lib/locomotive/render_spec.rb | 7 +++---- .../routing/site_dispatcher_spec.rb | 18 +++++++++--------- spec/requests/seo_trailing_slash_spec.rb | 12 ++++-------- 11 files changed, 38 insertions(+), 50 deletions(-) delete mode 100644 spec/lib/locomotive/httparty/patches_spec.rb diff --git a/lib/locomotive/liquid/drops/content_entry.rb b/lib/locomotive/liquid/drops/content_entry.rb index 5c5308d2..096d1dbd 100644 --- a/lib/locomotive/liquid/drops/content_entry.rb +++ b/lib/locomotive/liquid/drops/content_entry.rb @@ -44,7 +44,7 @@ module Locomotive end def _label - self._label + @_label ||= self._source._label end end diff --git a/lib/locomotive/liquid/drops/page.rb b/lib/locomotive/liquid/drops/page.rb index e8973b35..5282fb31 100644 --- a/lib/locomotive/liquid/drops/page.rb +++ b/lib/locomotive/liquid/drops/page.rb @@ -6,7 +6,7 @@ module Locomotive delegate :seo_title, :meta_keywords, :meta_description, :to => '_source' def title - self._source.templatized? ? @context['content_entry'].highlighted_field_value : self._source.title + self._source.templatized? ? @context['content_entry']._label : self._source.title end def slug diff --git a/lib/locomotive/liquid/tags/nav.rb b/lib/locomotive/liquid/tags/nav.rb index 6a74055b..406fa7cd 100644 --- a/lib/locomotive/liquid/tags/nav.rb +++ b/lib/locomotive/liquid/tags/nav.rb @@ -46,7 +46,8 @@ module Locomotive output = children_output.join("\n") if @options[:no_wrapper] != 'true' - output = %{} + list_class = !@options[:class].blank? ? %( class="#{@options[:class]}") : '' + output = %{} end output diff --git a/lib/locomotive/middlewares/seo_trailing_slash.rb b/lib/locomotive/middlewares/seo_trailing_slash.rb index b0cfcd0a..ead6c199 100644 --- a/lib/locomotive/middlewares/seo_trailing_slash.rb +++ b/lib/locomotive/middlewares/seo_trailing_slash.rb @@ -9,7 +9,7 @@ module Locomotive def call(env) path = env['PATH_INFO'] - if !path.starts_with?("/#{Locomotive.mounted_on}/") && (match = path.match(%r{(.+)/$})) + if !path.starts_with?("#{Locomotive.mounted_on}/") && (match = path.match(%r{(.+)/$})) response = Rack::Response.new response.redirect(match[1], 301) # moved permanently response.finish diff --git a/spec/lib/locomotive/httparty/patches_spec.rb b/spec/lib/locomotive/httparty/patches_spec.rb deleted file mode 100644 index 4ad30d6c..00000000 --- a/spec/lib/locomotive/httparty/patches_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'Httparty patches' do - - describe 'Crack patch' do - - context '#parsing json' do - - it 'fixes an issue about json input beginning by a variable declaration' do - lambda { - Crack::JSON.parse('var json = { "foo": 42 };') - }.should_not raise_error - end - - end - - end - -end diff --git a/spec/lib/locomotive/liquid/drops/page_spec.rb b/spec/lib/locomotive/liquid/drops/page_spec.rb index 405b73d8..6f3b66c7 100644 --- a/spec/lib/locomotive/liquid/drops/page_spec.rb +++ b/spec/lib/locomotive/liquid/drops/page_spec.rb @@ -47,7 +47,7 @@ describe Locomotive::Liquid::Drops::Page do end it 'renders title of parent page' do - content = render_template '{{ sub_page.parent.title }}', {'sub_page' => @sub_page} + content = render_template '{{ sub_page.parent.title }}', { 'sub_page' => @sub_page } content.should == "Home page" end @@ -56,10 +56,11 @@ describe Locomotive::Liquid::Drops::Page do context '#breadcrumbs' do before(:each) do @sub_page = FactoryGirl.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.") + @sub_page.stubs(:ancestors_and_self).returns([FactoryGirl.build(:page), @sub_page]) end it 'renders breadcrumbs of current page' do - content = render_template '{% for crumb in sub_page.breadcrumbs %}{{ crumb.title}},{% endfor %}', {'sub_page' => @sub_page} + content = render_template '{% for crumb in sub_page.breadcrumbs %}{{ crumb.title }},{% endfor %}', { 'sub_page' => @sub_page } content.should == 'Home page,Subpage,' end end @@ -73,7 +74,7 @@ describe Locomotive::Liquid::Drops::Page do it 'renders the content instance highlighted field instead for a templatized page' do templatized = FactoryGirl.build(:page, :title => 'Lorem ipsum template', :templatized => true) - content_entry = Locomotive::Liquid::Drops::Content.new(mock('content_entry', :highlighted_field_value => 'Locomotive rocks !')) + content_entry = Locomotive::Liquid::Drops::ContentEntry.new(mock('content_entry', :_label => 'Locomotive rocks !')) render_template('{{ page.title }}', 'page' => templatized, 'content_entry' => content_entry).should == 'Locomotive rocks !' end diff --git a/spec/lib/locomotive/liquid/tags/nav_spec.rb b/spec/lib/locomotive/liquid/tags/nav_spec.rb index ad4d38aa..a7ab5e64 100644 --- a/spec/lib/locomotive/liquid/tags/nav_spec.rb +++ b/spec/lib/locomotive/liquid/tags/nav_spec.rb @@ -96,10 +96,20 @@ describe Locomotive::Liquid::Tags::Nav do render_nav('site', {}, 'icon: after').should match /