add the middleware to manage sessions
did
committed Feb 16, 2015
commit 53ec74bde54b550a19b4e1e70b8dd351d8e068f1
Showing 5
changed files with
66 additions
and 46 deletions
locomotive/steam/liquid/drops/site.rb b/lib/locomotive/steam/liquid/drops/site.rb
+3
-1
| @@ | @@ -21,7 +21,9 @@ module Locomotive |
| end | |
| def scoped_pages | |
| - | repository.all(@context['with_scope']) |
| + | conditions = @context['with_scope'] || {} |
| + | conditions['slug.ne'] = '404' |
| + | repository.all(conditions) |
| end | |
locomotive/steam/server.rb b/lib/locomotive/steam/server.rb
+3
-3
| @@ | @@ -25,12 +25,12 @@ module Locomotive::Steam |
| server = self | |
| Rack::Builder.new do | |
| - | use Rack::Lint |
| - | |
| server.serve_assets(self) if server.options[:serve_assets] | |
| - | |
| use Middlewares::Favicon | |
| + | use Rack::Lint |
| + | use Rack::Session::Moneta, server.options[:moneta] |
| + | |
| use Middlewares::DefaultEnv, server.options | |
| use Middlewares::Logging | |
| use Middlewares::Site | |
spec/integration/server/basic_spec.rb
+12
-32
| @@ | @@ -87,44 +87,24 @@ describe Locomotive::Steam::Server do |
| end | |
| - | # it 'returns all the pages', pending: true do |
| - | # get '/all' |
| - | # last_response.body.should =~ /Home page/ |
| - | # last_response.body.should =~ /<li>Home page<\/li>/ |
| - | # last_response.body.should =~ /<li>John-doe<\/li>/ |
| - | # last_response.body.should =~ /<li>Songs<\/li>/ |
| - | # last_response.body.should =~ /<li>A song template<\/li>/ |
| - | # end |
| + | describe 'contents with_scope' do |
| - | # describe 'contents with_scope', pending: true do |
| - | # subject { get '/grunge_bands'; last_response.body } |
| + | subject { get '/grunge-bands'; last_response.body } |
| - | # it { should match(/Layne/)} |
| - | # it { should_not match(/Peter/) } |
| - | # end |
| - | |
| - | # describe 'pages with_scope', pending: true do |
| - | # subject { get '/unlisted_pages'; last_response.body } |
| - | # it { subject.should match(/Page to test the nav tag/)} |
| - | # it { should_not match(/About Us/)} |
| - | # end |
| - | |
| - | # describe 'session', pending: true do |
| - | |
| - | # subject { get '/contest'; last_response.body } |
| - | |
| - | # it { should match(/Your code is: HELLO WORLD/) } |
| - | # it { should_not match(/You've already participated to that contest ! Come back later./) } |
| + | it 'filters content entries' do |
| + | is_expected.to include 'Layne' |
| + | is_expected.not_to include 'Peter' |
| + | end |
| - | # describe 'assign tag' do |
| + | end |
| - | # subject { 2.times { get '/contest' }; last_response.body } |
| + | describe 'pages with_scope' do |
| - | # it { should_not match(/Your code is: HELLO WORLD/) } |
| - | # it { should match(/You've already participated to that contest ! Come back later./) } |
| + | subject { get '/unlisted-pages'; last_response.body } |
| - | # end |
| + | it { is_expected.to include 'Page to test the nav tag' } |
| + | it { is_expected.not_to include 'About Us' } |
| - | # end |
| + | end |
| end | |
spec/integration/server/nav_spec.rb
+15
-10
| @@ | @@ -12,17 +12,22 @@ describe Locomotive::Steam::Server do |
| subject { get '/all'; last_response.body } | |
| - | it { is_expected.not_to include('<nav id="nav">') } |
| - | |
| - | it { is_expected.to include('<li id="about-us-link" class="link first"><a href="/about-us">About Us</a></li>') } |
| - | |
| - | it { is_expected.to include('<li id="music-link" class="link"><a href="/music">Music</a></li>') } |
| - | |
| - | it { is_expected.to include('<li id="store-link" class="link"><a href="/store">Store</a></li>') } |
| - | |
| - | it { is_expected.to include('<li id="contact-link" class="link last"><a href="/contact">Contact Us</a></li>') } |
| + | it 'generates the right nav' do |
| + | is_expected.not_to include('<nav id="nav">') |
| + | is_expected.to include('<li id="about-us-link" class="link first"><a href="/about-us">About Us</a></li>') |
| + | is_expected.to include('<li id="music-link" class="link"><a href="/music">Music</a></li>') |
| + | is_expected.to include('<li id="store-link" class="link"><a href="/store">Store</a></li>') |
| + | is_expected.to include('<li id="contact-link" class="link last"><a href="/contact">Contact Us</a></li>') |
| + | is_expected.not_to include('<li id="events-link" class="link"><a href="/events">Events</a></li>') |
| + | end |
| - | it { is_expected.not_to include('<li id="events-link" class="link"><a href="/events">Events</a></li>') } |
| + | it 'lists all the pages' do |
| + | is_expected.to include('Home page') |
| + | is_expected.not_to include('<li>Page not found</li>') |
| + | is_expected.to include('<li>Home page</li>') |
| + | is_expected.to include('<li>John doe</li>') |
| + | is_expected.to include('<li>A song template</li>') |
| + | end |
| describe 'with wrapper' do | |
spec/integration/server/session_spec.rb
+33
-0
| @@ | @@ -0,0 +1,33 @@ |
| + | require File.dirname(__FILE__) + '/../integration_helper' |
| + | |
| + | describe Locomotive::Steam::Server do |
| + | |
| + | include Rack::Test::Methods |
| + | |
| + | def app |
| + | run_server |
| + | end |
| + | |
| + | describe 'session' do |
| + | |
| + | subject { get '/contest'; last_response.body } |
| + | |
| + | it 'displays code for the first time' do |
| + | is_expected.to include 'Your code is: HELLO WORLD' |
| + | is_expected.not_to include "You've already participated to that contest ! Come back later." |
| + | end |
| + | |
| + | describe 'assign tag' do |
| + | |
| + | subject { 2.times { get '/contest' }; last_response.body } |
| + | |
| + | it 'does not display code if second time' do |
| + | is_expected.not_to include 'Your code is: HELLO WORLD' |
| + | is_expected.to include "You've already participated to that contest ! Come back later." |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| + | end |