all the non-models specs have been fixed
This commit is contained in:
parent
64a050dff9
commit
6619d4e5dc
@ -44,7 +44,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def _label
|
def _label
|
||||||
self._label
|
@_label ||= self._source._label
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ module Locomotive
|
|||||||
delegate :seo_title, :meta_keywords, :meta_description, :to => '_source'
|
delegate :seo_title, :meta_keywords, :meta_description, :to => '_source'
|
||||||
|
|
||||||
def title
|
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
|
end
|
||||||
|
|
||||||
def slug
|
def slug
|
||||||
|
@ -46,7 +46,8 @@ module Locomotive
|
|||||||
output = children_output.join("\n")
|
output = children_output.join("\n")
|
||||||
|
|
||||||
if @options[:no_wrapper] != 'true'
|
if @options[:no_wrapper] != 'true'
|
||||||
output = %{<ul id="#{@options[:id]}" class="#{@options[:class]}">\n#{output}</ul>}
|
list_class = !@options[:class].blank? ? %( class="#{@options[:class]}") : ''
|
||||||
|
output = %{<ul id="#{@options[:id]}"#{list_class}>\n#{output}</ul>}
|
||||||
end
|
end
|
||||||
|
|
||||||
output
|
output
|
||||||
|
@ -9,7 +9,7 @@ module Locomotive
|
|||||||
def call(env)
|
def call(env)
|
||||||
path = env['PATH_INFO']
|
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 = Rack::Response.new
|
||||||
response.redirect(match[1], 301) # moved permanently
|
response.redirect(match[1], 301) # moved permanently
|
||||||
response.finish
|
response.finish
|
||||||
|
@ -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
|
|
@ -47,7 +47,7 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'renders title of parent page' do
|
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"
|
content.should == "Home page"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,10 +56,11 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
context '#breadcrumbs' do
|
context '#breadcrumbs' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@sub_page = FactoryGirl.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
@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
|
end
|
||||||
|
|
||||||
it 'renders breadcrumbs of current page' do
|
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,'
|
content.should == 'Home page,Subpage,'
|
||||||
end
|
end
|
||||||
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
|
it 'renders the content instance highlighted field instead for a templatized page' do
|
||||||
templatized = FactoryGirl.build(:page, :title => 'Lorem ipsum template', :templatized => true)
|
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 !'
|
render_template('{{ page.title }}', 'page' => templatized, 'content_entry' => content_entry).should == 'Locomotive rocks !'
|
||||||
end
|
end
|
||||||
|
@ -96,10 +96,20 @@ describe Locomotive::Liquid::Tags::Nav do
|
|||||||
render_nav('site', {}, 'icon: after').should match /<li id="child-1-link" class="link first"><a href="\/child_1">Child #1<span><\/span><\/a><\/li>/
|
render_nav('site', {}, 'icon: after').should match /<li id="child-1-link" class="link first"><a href="\/child_1">Child #1<span><\/span><\/a><\/li>/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assign a different dom id' do
|
it 'assigns a different dom id' do
|
||||||
render_nav('site', {}, 'id: "main-nav"').should match /<ul id="main-nav">/
|
render_nav('site', {}, 'id: "main-nav"').should match /<ul id="main-nav">/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'assigns a class' do
|
||||||
|
render_nav('site', {}, 'class: "nav"').should match /<ul id="nav" class="nav">/
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns a class other than "on" for a selected item' do
|
||||||
|
(page = @home.children.last.children.first).stubs(:parent).returns(@home.children.last)
|
||||||
|
output = render_nav 'parent', { :page => page }, 'active_class: "active"'
|
||||||
|
output.should match /<li id="sub-child-1-link" class="link active first">/
|
||||||
|
end
|
||||||
|
|
||||||
it 'excludes entries based on a regexp' do
|
it 'excludes entries based on a regexp' do
|
||||||
render_nav('page', {}, 'exclude: "child_1"').should == '<ul id="nav"><li id="child-2-link" class="link first last"><a href="/child_2">Child #2</a></li></ul>'
|
render_nav('page', {}, 'exclude: "child_1"').should == '<ul id="nav"><li id="child-2-link" class="link first last"><a href="/child_2">Child #2</a></li></ul>'
|
||||||
end
|
end
|
||||||
|
@ -81,8 +81,8 @@ describe Locomotive::Liquid::Tags::SEO do
|
|||||||
|
|
||||||
let(:content_type) do
|
let(:content_type) do
|
||||||
FactoryGirl.build(:content_type, :site => site).tap do |ct|
|
FactoryGirl.build(:content_type, :site => site).tap do |ct|
|
||||||
ct.entries_custom_fields.build :label => 'anything', :type => 'String'
|
ct.entries_custom_fields.build :label => 'anything', :type => 'string'
|
||||||
end
|
end.tap { |_ct| _ct.valid? }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "has seo title" do
|
context "has seo title" do
|
||||||
|
@ -128,19 +128,18 @@ describe 'Locomotive rendering system' do
|
|||||||
@content_type = FactoryGirl.build(:content_type, :site => nil)
|
@content_type = FactoryGirl.build(:content_type, :site => nil)
|
||||||
@content_entry = @content_type.entries.build(:_visible => true)
|
@content_entry = @content_type.entries.build(:_visible => true)
|
||||||
@page.templatized = true
|
@page.templatized = true
|
||||||
@page.content_type = @content_type
|
@page.stubs(:fetch_target_entry).returns(@content_entry)
|
||||||
@controller.request.fullpath = '/projects/edeneo.html'
|
@controller.request.fullpath = '/projects/edeneo.html'
|
||||||
@controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{projects/edeneo projects/content_type_template} }).returns([@page])
|
@controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{projects/edeneo projects/content_type_template} }).returns([@page])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the content_entry variable' do
|
it 'sets the content_entry variable' do
|
||||||
@content_type.entries.stubs(:where).returns([@content_entry])
|
|
||||||
@controller.send(:locomotive_page).should_not be_nil
|
@controller.send(:locomotive_page).should_not be_nil
|
||||||
@controller.instance_variable_get(:@content_entry).should == @content_entry
|
@controller.instance_variable_get(:@content_entry).should == @content_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the 404 page if the instance does not exist' do
|
it 'returns the 404 page if the instance does not exist' do
|
||||||
@content_type.entries.stubs(:where).returns([])
|
@page.stubs(:fetch_target_entry).returns(nil)
|
||||||
(klass = Locomotive::Page).expects(:published).returns([true])
|
(klass = Locomotive::Page).expects(:published).returns([true])
|
||||||
@controller.current_site.pages.expects(:not_found).returns(klass)
|
@controller.current_site.pages.expects(:not_found).returns(klass)
|
||||||
@controller.send(:locomotive_page).should be_true
|
@controller.send(:locomotive_page).should be_true
|
||||||
@ -149,7 +148,7 @@ describe 'Locomotive rendering system' do
|
|||||||
|
|
||||||
it 'returns the 404 page if the instance is not visible' do
|
it 'returns the 404 page if the instance is not visible' do
|
||||||
@content_entry._visible = false
|
@content_entry._visible = false
|
||||||
@content_type.entries.stubs(:where).returns([@content_entry])
|
@page.stubs(:fetch_target_entry).returns(@content_entry)
|
||||||
(klass = Locomotive::Page).expects(:published).returns([true])
|
(klass = Locomotive::Page).expects(:published).returns([true])
|
||||||
@controller.current_site.pages.expects(:not_found).returns(klass)
|
@controller.current_site.pages.expects(:not_found).returns(klass)
|
||||||
@controller.send(:locomotive_page).should be_true
|
@controller.send(:locomotive_page).should be_true
|
||||||
|
@ -86,8 +86,8 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
|
|
||||||
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
||||||
@controller.expects(:current_site).returns(false)
|
@controller.expects(:current_site).returns(false)
|
||||||
@controller.stubs(:installation_url).returns('/admin/install/url/')
|
@controller.stubs(:installation_url).returns('/locomotive/install/url/')
|
||||||
@controller.stubs(:redirect_to).with('/admin/install/url/')
|
@controller.stubs(:redirect_to).with('/locomotive/install/url/')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false' do
|
it 'returns false' do
|
||||||
@ -95,7 +95,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the admin installation url' do
|
it 'redirects to the admin installation url' do
|
||||||
@controller.expects(:redirect_to).with('/admin/install/url/')
|
@controller.expects(:redirect_to).with('/locomotive/install/url/')
|
||||||
@controller.send(:require_site)
|
@controller.send(:require_site)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -109,8 +109,8 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
|
|
||||||
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
||||||
@controller.expects(:current_site).returns(false)
|
@controller.expects(:current_site).returns(false)
|
||||||
@controller.stubs(:installation_url).returns('/admin/install/url/')
|
@controller.stubs(:installation_url).returns('/locomotive/install/url/')
|
||||||
@controller.stubs(:redirect_to).with('/admin/install/url/')
|
@controller.stubs(:redirect_to).with('/locomotive/install/url/')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false' do
|
it 'returns false' do
|
||||||
@ -118,7 +118,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the admin installation url' do
|
it 'redirects to the admin installation url' do
|
||||||
@controller.expects(:redirect_to).with('/admin/install/url/')
|
@controller.expects(:redirect_to).with('/locomotive/install/url/')
|
||||||
@controller.send(:require_site)
|
@controller.send(:require_site)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
@controller.stubs(:request).returns(@request)
|
@controller.stubs(:request).returns(@request)
|
||||||
@controller.stubs(:current_locomotive_account).returns(@account)
|
@controller.stubs(:current_locomotive_account).returns(@account)
|
||||||
@controller.stubs(:sign_out).with(@account)
|
@controller.stubs(:sign_out).with(@account)
|
||||||
@controller.stubs(:new_session_url).returns('/new/admin/session')
|
@controller.stubs(:new_locomotive_account_session_url).returns('/locomotive/session/new')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a site is present' do
|
context 'when a site is present' do
|
||||||
@ -213,7 +213,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the new session url' do
|
it 'redirects to the new session url' do
|
||||||
@controller.expects(:redirect_to).with('/new/admin/session')
|
@controller.expects(:redirect_to).with('/locomotive/session/new')
|
||||||
@controller.send(:validate_site_membership)
|
@controller.send(:validate_site_membership)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the new session url' do
|
it 'redirects to the new session url' do
|
||||||
@controller.expects(:redirect_to).with('/new/admin/session')
|
@controller.expects(:redirect_to).with('/locomotive/session/new')
|
||||||
@controller.send(:validate_site_membership)
|
@controller.send(:validate_site_membership)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,22 +2,18 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'Locomotive::Middlewares::SeoTrailingSlash' do
|
describe 'Locomotive::Middlewares::SeoTrailingSlash' do
|
||||||
|
|
||||||
before(:all) do
|
|
||||||
Dummy::Application.instance.instance_variable_set(:@app, nil) # re-initialize the stack
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not process the "/" url' do
|
it 'does not process the "/" url' do
|
||||||
get '/'
|
get '/'
|
||||||
response.status.should_not be(301)
|
response.status.should_not be(301)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not process the "/admin/" url' do
|
it 'does not process the "/locomotive/" url' do
|
||||||
get '/admin/'
|
get '/locomotive/'
|
||||||
response.status.should_not be(301)
|
response.status.should_not be(301)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not process the "/admin/*" urls' do
|
it 'does not process the "/locomotive/*" urls' do
|
||||||
get '/admin/login'
|
get '/locomotive/login'
|
||||||
response.status.should_not be(301)
|
response.status.should_not be(301)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user