Skip to content
Browse files

Added an optional fullpath argument for ress_annotations_tag. Useful …

…if the alternate versions do not share a similar url as the canonical version
  • Loading branch information...
1 parent 6ea5aca commit bd7d52837a5e85cbef75c50c695ceea1a90bcb54 @lokimeyburg lokimeyburg committed
Showing with 16 additions and 2 deletions.
  1. +6 −2 lib/ress/view_helpers.rb
  2. +10 −0 spec/ress/view_helpers_spec.rb
View
8 lib/ress/view_helpers.rb
@@ -2,8 +2,12 @@ module Ress
module ViewHelpers
- def ress_annotation_tags
- path = "#{request.host_with_port}#{request.fullpath}"
+ def ress_annotation_tags(options={})
+ options = { :fullpath => nil }.merge(options)
+ fullpath = options[:fullpath]
+ fullpath ||= request.fullpath
+
+ path = "#{request.host_with_port}#{fullpath}"
html = if canonical_request?
Ress.alternate_versions.map do |category|
category.link_tag(request.protocol, path, self)
View
10 spec/ress/view_helpers_spec.rb
@@ -53,6 +53,16 @@
end
+ context 'with fullpath argument' do
+ let(:request) { stub('request', :protocol => 'http://', :host_with_port => 'foo.com', :fullpath => '/bar', :subdomain => '') }
+ before { view.stub(:canonical_request? => true) }
+
+ it 'gerenates the link tags using the fullpath argument instead' do
+ view.ress_annotation_tags(:fullpath => '/notbar').should ==
+ "<link href=\"http://m.foo.com/notbar\" id=\"m\" media=\"stuff\" rel=\"alternate\" />"
+ end
+ end
+
end
end

0 comments on commit bd7d528

Please sign in to comment.
Something went wrong with that request. Please try again.