0
specify "should generate monthly link" do
0
- assert_equal "<a href=\"/archives/2006/1\"
\">January 2006</a>", link_to_month(sections(:home).to_liquid, '2006-1')
0
+ assert_equal "<a href=\"/archives/2006/1\"
title=\"January 2006\">January 2006</a>", link_to_month(sections(:home).to_liquid, '2006-1')
0
specify "should generate paged url" do
0
other_section = link_to_section(sections(:home).to_liquid)
0
home_section = link_to_section(sections(:about).to_liquid)
0
- assert_match %r(href="/"), other_section
0
- assert_match %r(href="/about"), home_section
0
- assert_match %r(class="selected"), home_section
0
- assert_no_match %r(class="selected"), other_section
0
+ assert_match %r(href="/"), other_section
0
+ assert_match %r(href="/about"), home_section
0
+ assert_match %r(class="selected"), home_section
0
+ assert_no_match %r(class="selected"), other_section
0
+ assert_match %r(title="#{sections(:home).name}"), other_section
0
+ assert_match %r(title="#{sections(:about).name}"), home_section
0
specify "should generate paged url for home section" do
0
specify "should generate tag links" do
0
- assert_equal "<a href=\"/tags/foo\" rel=\"tag\"
\">foo</a>", link_to_tag('foo')
0
+ assert_equal "<a href=\"/tags/foo\" rel=\"tag\"
title=\"foo\">foo</a>", link_to_tag('foo')
0
specify "should generate search urls" do
0
assert_match /href="\/feed\/about\/atom.xml"/, content
0
assert_match /title="About Articles"/, content
0
specify "should html encode anchor text" do
0
unencoded = 'Tom & Jerry'
0
contents(:welcome).title = unencoded
0
@article2.context = @context
0
assert_match /href="\/about"/, link_to_search_result(@article)
0
assert_match /href="\/about\/another-welcome-to-mephisto"/, link_to_search_result(@article2)
0
+context "Link_to Url Filters" do
0
+ fixtures :sites, :sections, :contents
0
+ include CoreFilters, UrlFilters
0
+ @context = mock_context 'site' => sites(:first).to_liquid
0
+ @section = sections(:about).to_liquid
0
+ @article = contents(:welcome).to_liquid
0
+ @paged_article = contents(:about).to_liquid
0
+ @article.context = @paged_article.context = @context
0
+ specify "should generate links with custom text" do
0
+ pattern = %r(^<a href="[^"]+" (?:rel="tag" )?title="Custom text">Custom text</a>$)
0
+ assert_match pattern, link_to_article(@article, args)
0
+ assert_match pattern, link_to_page(@article, @section, args)
0
+ assert_match pattern, link_to_section(@section, args)
0
+ assert_match pattern, link_to_comments(@article, args)
0
+ assert_match pattern, link_to_tag('foo', args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', args)
0
+ assert_match pattern, link_to_search_result(@article, args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, args)
0
+ specify "should generate links with custom title attribute" do
0
+ pattern = %r(^<a href="[^"]+" (?:rel="tag" )?title="Custom title">)
0
+ args = [nil, 'Custom title']
0
+ assert_match pattern, link_to_article(@article, *args)
0
+ assert_match pattern, link_to_page(@article, @section, *args)
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_match pattern, link_to_comments(@article, *args)
0
+ assert_match pattern, link_to_tag('foo', *args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', *args)
0
+ assert_match pattern, link_to_search_result(@article, *args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, *args)
0
+ specify "should generate links with custom id attribute" do
0
+ pattern = %r(^<a href="[^"]+" id="custom-id" (?:rel="tag" )?title="[^"]+">)
0
+ args = [nil, nil, 'custom-id']
0
+ assert_match pattern, link_to_article(@article, *args)
0
+ assert_match pattern, link_to_page(@article, @section, *args)
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_match pattern, link_to_comments(@article, *args)
0
+ assert_match pattern, link_to_tag('foo', *args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', *args)
0
+ assert_match pattern, link_to_search_result(@article, *args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, *args)
0
+ specify "should generate links with custom class attribute" do
0
+ pattern = %r(^<a class="custom-class" href="[^"]+" (?:rel="tag" )?title="[^"]+">)
0
+ args = [nil, nil, nil, 'custom-class']
0
+ assert_match pattern, link_to_article(@article, *args)
0
+ assert_match pattern, link_to_page(@article, @section, *args)
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_match pattern, link_to_comments(@article, *args)
0
+ assert_match pattern, link_to_tag('foo', *args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', *args)
0
+ assert_match pattern, link_to_search_result(@article, *args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, *args)
0
+ specify "should generate links with custom rel attribute" do
0
+ pattern = %r(^<a href="[^"]+" rel="custom-rel" title="[^"]+">)
0
+ args = [nil, nil, nil, nil, 'custom-rel']
0
+ assert_match pattern, link_to_article(@article, *args)
0
+ assert_match pattern, link_to_page(@article, @section, *args)
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_match pattern, link_to_comments(@article, *args)
0
+ assert_match pattern, link_to_tag('foo', *args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', *args)
0
+ assert_match pattern, link_to_search_result(@article, *args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, *args)
0
+ specify "should html encode custom attributes" do
0
+ pattern = %r(^<a class="custom&class" href="[^"]+" id="custom&id" rel="custom&rel" title="Custom & title">Custom & text</a>$)
0
+ args = ['Custom & text', 'Custom & title', 'custom&id', 'custom&class', 'custom&rel']
0
+ assert_match pattern, link_to_article(@article, *args)
0
+ assert_match pattern, link_to_page(@article, @section, *args)
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_match pattern, link_to_comments(@article, *args)
0
+ assert_match pattern, link_to_tag('foo', *args)
0
+ assert_match pattern, link_to_month(@section, '2006-1', 'my', *args)
0
+ assert_match pattern, link_to_search_result(@article, *args)
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_search_result(@paged_article, *args)
0
+ specify "should generate page links with selected class appended to custom class attribute" do
0
+ pattern = %r(class="custom-class selected")
0
+ args = [nil, nil, nil, 'custom-class']
0
+ @context['section'] = @section
0
+ @context['article'] = @paged_article
0
+ assert_match pattern, link_to_page(@paged_article, @section, *args)
0
+ assert_no_match pattern, link_to_page(@article, @section, *args)
0
+ specify "should generate section links with selected class appended to custom class attribute" do
0
+ pattern = %r(class="custom-class selected")
0
+ args = [nil, nil, nil, 'custom-class']
0
+ @context['section'] = @section
0
+ assert_match pattern, link_to_section(@section, *args)
0
+ assert_no_match pattern, link_to_section(sections(:home).to_liquid, *args)
Comments
No one has commented yet.