Created
February 17, 2012 16:17
-
-
Save mrchrisadams/1854172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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">x</span>' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment