Sha256: e0294fc822aa7c5670bcc63d5095d5e41514b681098d5bcfe80958e63f239874

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'
require 'rack/test'
require 'tdiary/rack/html_anchor'

describe TDiary::Rack::HtmlAnchor do
	include Rack::Test::Methods

	describe "html anchor" do
		let(:app) { TDiary::Rack::HtmlAnchor.new(
			lambda{|env| [200, {}, ['Awesome']]} )}

		it 'should not do anything for root access' do
			get '/'
			last_request.params['date'].should == nil
			last_request.query_string.should == ''
		end

		it 'should remove the file name from PATH_INFO' do
			get '/20120501.html'
			last_request.env['PATH_INFO'].should == '/'
			get '/diary/20120501.html'
			last_request.env['PATH_INFO'].should == '/diary/'
		end

		it 'should add date query' do
			get '/diary/0501.html'
			last_request.params['date'].should == "0501"
			get '/0501.html'
			last_request.params['date'].should == "0501"
			get '/201205.html'
			last_request.params['date'].should == "201205"
			get '/20120501.html'
			last_request.params['date'].should == "20120501"
		end

		it 'should add date query when using section_permalink_anchor plugin' do
			get '/20120501p01.html'
			last_request.params['date'].should == "20120501"
			last_request.params['p'].should == "01"
		end

		it 'should replace date query' do
			get '/20120501.html?date=20120101'
			last_request.params['date'].should == "20120501"
		end

		it 'should not break original query' do
			get '/?date=20120501'
			last_request.params['date'].should == "20120501"
			get '/index.rb?date=20120501'
			last_request.params['date'].should == "20120501"
			get '/index.rb?date=20120501&p=01'
			last_request.params['date'].should == "20120501"
			last_request.params['p'].should == "01"
		end
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tdiary-4.0.2.20140201 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.2 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.1.20131102 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.1.20130929 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.1.20130903 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.1 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.0.20130826 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.0 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130727 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130722 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130720 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130617 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130614 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130604 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130527 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130518 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130508 spec/core/rack/html_anchor_spec.rb
tdiary-3.2.2.20130507 spec/core/rack/html_anchor_spec.rb