Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/bitclust/screen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ def initialize(h, request_full_uri, opt)
attr_reader :search_full_url

def body
run_template('opensearchdescription')
# XML なので HTML の layout は通さない
run_template('opensearchdescription', false)
end

def content_type
Expand Down
39 changes: 39 additions & 0 deletions test/test_opensearchdescription_screen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'test/unit'
require 'uri'
require 'bitclust'
require 'bitclust/screen'

class TestOpenSearchDescriptionScreen < Test::Unit::TestCase
SRC = <<'HERE'
= class Foo
description
HERE

def screen
_lib, db = BitClust::RRDParser.parse(SRC, 'testlib', {'version' => '3.4'})
datadir = File.expand_path('../data/bitclust', __dir__)
manager = BitClust::ScreenManager.new(
:templatedir => "#{datadir}/template",
:catalogdir => "#{datadir}/catalog",
:encoding => 'utf-8',
:default_encoding => 'utf-8',
:base_url => '',
:cgi_url => '/view',
:target_version => '3.4'
)
manager.opensearchdescription_screen(URI.parse('http://example.com/view/opensearchdescription'),
:database => db)
end

def test_body_is_bare_xml_without_html_layout
body = screen.body
assert_match(/\A<\?xml/, body)
assert_not_include(body, '<html')
assert_match(%r{\A<\?xml[^>]*\?>\s*<OpenSearchDescription\b.*</OpenSearchDescription>\s*\z}m, body)
assert_include(body, 'http://example.com/view/search')
end

def test_content_type_is_opensearch_xml
assert_equal 'application/opensearchdescription+xml; charset=utf-8', screen.content_type
end
end
Loading