Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created February 17, 2012 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/1854172 to your computer and use it in GitHub Desktop.
Save mrchrisadams/1854172 to your computer and use it in GitHub Desktop.
module ApplicationHelper
# Generates a title, with a padlock if the category being shown is
# a proprietary dataset
def commercially_aware_title(result)
#padlock_string = content_tag(:span, "x", :class => "padlock") # this DON'T work
padlock_string = content_tag :span, "x".html_safe, :class => "padlock" # this DOES work
result.public?(session[:project]) ? result.title : "#{result.title} #{padlock_string}".html_safe
end
end
context 'displaying commercial links to pages' do
it "adds a padlock to titles for proprietary datasets" do
result = flexmock("result",
:public? => false,
:title => "A category title"
)
helper.commercially_aware_title(result).should match 'A category title <span class="padlock">&#120;</span>'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment