Sha256: 6bdcd1b057ac6cf9037d808e25ea6c07035f8dfe23f49246f034fb130eaad252

Contents?: true

Size: 1.68 KB

Versions: 11

Compression:

Stored size: 1.68 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 '/'
			expect(last_request.params['date']).to eq(nil)
			expect(last_request.query_string).to eq('')
		end

		it 'should remove the file name from PATH_INFO' do
			get '/20120501.html'
			expect(last_request.env['PATH_INFO']).to eq('/')
			get '/diary/20120501.html'
			expect(last_request.env['PATH_INFO']).to eq('/diary/')
		end

		it 'should add date query' do
			get '/diary/0501.html'
			expect(last_request.params['date']).to eq("0501")
			get '/0501.html'
			expect(last_request.params['date']).to eq("0501")
			get '/201205.html'
			expect(last_request.params['date']).to eq("201205")
			get '/20120501.html'
			expect(last_request.params['date']).to eq("20120501")
		end

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/tdiary-4.2.0/spec/core/rack/html_anchor_spec.rb
tdiary-4.2.0 spec/core/rack/html_anchor_spec.rb
tdiary-4.1.3 spec/core/rack/html_anchor_spec.rb
tdiary-4.1.2 spec/core/rack/html_anchor_spec.rb
tdiary-4.1.1 spec/core/rack/html_anchor_spec.rb
tdiary-4.1.0 spec/core/rack/html_anchor_spec.rb
tdiary-4.1.0.20141126 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.5.1 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.5 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.4 spec/core/rack/html_anchor_spec.rb
tdiary-4.0.3 spec/core/rack/html_anchor_spec.rb