Permalink
Browse files

Merge pull request #3 from lokimeyburg/fullpath_argument_for_annotati…

…on_tags

Fullpath argument for annotation tags
  • Loading branch information...
2 parents 1efb8b0 + ec5e3e3 commit 797e1a752f1143637dbb1f441a07263fb872bfbc @matthewrobertson committed Apr 18, 2013
Showing with 14 additions and 2 deletions.
  1. +4 −2 lib/ress/view_helpers.rb
  2. +10 −0 spec/ress/view_helpers_spec.rb
View
@@ -2,8 +2,10 @@ module Ress
module ViewHelpers
- def ress_annotation_tags
- path = "#{request.host_with_port}#{request.fullpath}"
+ def ress_annotation_tags(options={})
+ fullpath = options[:fullpath] || request.fullpath
+
+ path = "#{request.host_with_port}#{fullpath}"
html = if canonical_request?
path.gsub!("#{request.subdomain}.", '') if Ress.replace_canonical_subdomain?
Ress.alternate_versions.map do |category|
@@ -62,6 +62,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 797e1a7

Please sign in to comment.