initial version

This commit is contained in:
Enrique García Cota 2012-02-28 19:29:54 +01:00
parent 7aadd9d129
commit f407bc7a8f
4 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,11 @@
module Locomotive
module Liquid
module Drops
class CurrentUser < Base
def logged_in?
false
end
end
end
end
end

View File

@ -68,7 +68,8 @@ module Locomotive
'path' => request.path,
'url' => request.url,
'now' => Time.now.utc,
'today' => Date.today
'today' => Date.today,
'current_user' => Locomotive::Liquid::Drops::CurrentUser.new
}
assigns.merge!(Locomotive.config.context_assign_extensions)

View File

@ -0,0 +1,31 @@
require 'spec_helper'
describe Locomotive::Liquid::Drops::CurrentUser do
before(:each) do
@page = FactoryGirl.build(:sub_page)
@site = @page.site
@site.pages.expects(:any_in).returns([@page])
@controller = Locomotive::TestController.new
@controller.stubs(:flash).returns(ActionDispatch::Flash::FlashHash.new())
@controller.stubs(:params).returns(:url => '/subpage')
@controller.stubs(:request).returns(OpenStruct.new(:url => '/subpage', :fullpath => '/subpage'))
@controller.current_site = @site
end
context '#logged_in?' do
it 'returns false when no user is logged in' do
@page.raw_template = '{{ current_user.logged_in? }}'
@page.send(:serialize_template)
@controller.expects(:render).with(:text => "false", :layout => false, :status => :ok).returns(true)
@controller.send(:render_locomotive_page)
end
end
after(:all) do
ENV['APP_TLD'] = nil
Locomotive.configure_for_test(true)
end
end