Skip to content

Instantly share code, notes, and snippets.

@jrbruce
Created November 29, 2010 22:25
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 jrbruce/720757 to your computer and use it in GitHub Desktop.
Save jrbruce/720757 to your computer and use it in GitHub Desktop.
# 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