Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes Issue #548 and #731. Handles cases where author is nil and that…
… causes errors in the view.

I don't know how update authors get to be nil, but here we are.
  • Loading branch information
carols10cents committed Nov 24, 2012
1 parent b64c263 commit abde4c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/views/updates/_list.html.haml
Expand Up @@ -6,14 +6,15 @@
- unless defined?(no_highlight) and no_highlight
- mine = current_user.nil? ? false : (update.author.user == current_user)
- mentioned = current_user.nil? ? false : update.mentioned?(current_user.username)
%li.update.hentry.message{:class => (mentioned ? "mention " : "") + (mine ? "mine " : ""), :id => "update-#{update.id}", "data-id" => update.id, "data-name" => update.author.fully_qualified_name}
.author.vcard
%a.url{:href => update.author.url, :rel => "user"}
= AuthorDecorator.decorate(update.author).avatar
%span.fn
%a.url{:href => update.author.url}
= update.author.display_name
(<span class="nickname user-text">#{update.author.username}</span>)
%li.update.hentry.message{:class => (mentioned ? "mention " : "") + (mine ? "mine " : ""), :id => "update-#{update.id}", "data-id" => update.id, "data-name" => update.author ? update.author.fully_qualified_name : ""}
- if update.author
.author.vcard
%a.url{:href => update.author.url, :rel => "user"}
= AuthorDecorator.decorate(update.author).avatar
%span.fn
%a.url{:href => update.author.url}
= update.author.display_name
(<span class="nickname user-text">#{update.author.username}</span>)
.entry-content
%span.message-text
!= update.to_html
Expand All @@ -25,7 +26,10 @@
%span.in-reply
%a{:href => "/updates/#{update.referral.id}"}
in reply to
%span.name= update.referral.author.username
- if update.referral.author
%span.name= update.referral.author.username
- else
an update
- elsif !update.referral_url.nil?
%span.in-reply
%a{:href => update.referral_url}
Expand Down
17 changes: 17 additions & 0 deletions test/acceptance/update_test.rb
Expand Up @@ -106,6 +106,23 @@
end
end

it "shows an update in reply to another update that has a nil author" do
# Not sure how this happens, but it does. author_id exists but the
# associated author does not.
update = Fabricate(:update, :author_id => "999999")

update2 = Fabricate(:update)
update2.referral_id = update.id
update2.save

visit "/updates"

within "#page" do
text.must_include update2.text
text.must_include update.text
end
end

describe "update with hashtag" do
it "creates a working hashtag link" do
log_in_as_some_user
Expand Down

0 comments on commit abde4c9

Please sign in to comment.