test/helpers/test_xml_sitemap.rb in nanoc-4.5.1 vs test/helpers/test_xml_sitemap.rb in nanoc-4.5.2
- old
+ new
@@ -184,9 +184,36 @@
assert_equal 'http://example.com/walton/eve/', urls[4].css('> loc').inner_text
assert_equal 'http://example.com/walton/bob/', urls[5].css('> loc').inner_text
end
end
+ def test_url_escape
+ if_have 'builder', 'nokogiri' do
+ # Create items
+ @items = Nanoc::Int::IdentifiableCollection.new({})
+ item = Nanoc::ItemWithRepsView.new(Nanoc::Int::Item.new('some content 1', {}, '/george/'), @view_context)
+ @items << item
+ create_item_rep(item.unwrap, :default, '/cool projects/проверка')
+
+ # Create sitemap item
+ @item = Nanoc::ItemWithRepsView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'), @view_context)
+
+ # Create site
+ @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
+
+ # Build sitemap
+ res = xml_sitemap(items: @items)
+
+ # Check
+ doc = Nokogiri::XML(res)
+ urlsets = doc.css('> urlset')
+ assert_equal 1, urlsets.size
+ urls = urlsets.css('> url')
+ assert_equal 1, urls.size
+ assert_equal 'http://example.com/cool%20projects/%D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0', urls[0].css('> loc').inner_text
+ end
+ end
+
protected
def create_item_rep(item, name, path)
rep = Nanoc::Int::ItemRep.new(item, name)
rep.paths = { last: path }