initial version
This commit is contained in:
parent
7aadd9d129
commit
f407bc7a8f
11
lib/locomotive/liquid/drops/current_user.rb
Normal file
11
lib/locomotive/liquid/drops/current_user.rb
Normal file
@ -0,0 +1,11 @@
|
||||
module Locomotive
|
||||
module Liquid
|
||||
module Drops
|
||||
class CurrentUser < Base
|
||||
def logged_in?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -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)
|
||||
|
31
spec/lib/locomotive/liquid/drops/current_user_spec.rb
Normal file
31
spec/lib/locomotive/liquid/drops/current_user_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user