Skip to content

Commit

Permalink
close issue hacketyhack#119, fix for programs without username
Browse files Browse the repository at this point in the history
  • Loading branch information
coreypurcell committed Jan 29, 2012
1 parent 6cec366 commit c7d261b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/helpers/programs_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
module ProgramsHelper
def program_link program
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
if program.author_username.present?
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
else
"#{link_to(program.title.titleize, url_for(:controller => '/programs', :action => 'show', :id => program.slug))}".html_safe
end
end

def author_link username, program = nil
return nil unless username
output = ""
output += link_to(username, user_path(username))

Expand Down
12 changes: 12 additions & 0 deletions spec/views/programs_index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'

describe 'programs/index.html.haml' do
context 'programs without a username' do
it "renders the page without error" do
programs = [Fabricate(:program, author_username: nil)]
assign(:programs, programs)
render
rendered.should have_selector('div', id: 'title', contents: 'MyString')
end
end
end

0 comments on commit c7d261b

Please sign in to comment.