Created
November 29, 2010 22:25
-
-
Save jrbruce/720757 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# spec/helpers/application_helper_spec.rb | |
require 'spec_helper' | |
describe ApplicationHelper do | |
describe "#logo" do | |
it "image tag should point to logo.png" do | |
helper.logo.should =~ /logo.png/i | |
end | |
end | |
end | |
# app/helpers/application_helper.rb | |
module ApplicationHelper | |
def logo | |
if current_account && current_account.logo? | |
image_tag(current_account.logo.url(:large), :alt => "Custom_Name") | |
else | |
image_tag("logo.png", :alt => "Name", :class => "round") | |
end | |
end | |
end | |
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
helper_method :current_account | |
def current_account | |
# logic in here | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment