Skip to content

Commit

Permalink
Merge pull request #3 from lokimeyburg/fullpath_argument_for_annotati…
Browse files Browse the repository at this point in the history
…on_tags

Fullpath argument for annotation tags
  • Loading branch information
matthewrobertson committed Apr 18, 2013
2 parents 1efb8b0 + ec5e3e3 commit 797e1a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ress/view_helpers.rb
Expand Up @@ -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|
Expand Down
10 changes: 10 additions & 0 deletions spec/ress/view_helpers_spec.rb
Expand Up @@ -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.