dashboards for users with nil root_discussion_entries. fixes #5854

Change-Id: I5509461616725a7891977f40a56d527a15c16ef3
Reviewed-on: https://gerrit.instructure.com/6009
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
JT Olds 2011-10-05 18:42:30 -06:00
parent 94b8560986
commit c780d10e15
2 changed files with 30 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<% topic = dashboard_topic || nil; show_context ||= false; is_announcement ||= false; contextless ||= false %>
<% context_code = topic.try_rescue(:context_code) %>
<% post_date = ([topic] + topic.try_rescue(:root_discussion_entries) || []).compact.last.created_at %>
<% post_date = ([topic] + (topic.try_rescue(:root_discussion_entries) || [])).compact.last.created_at %>
<% assignment = topic && topic.assignment_id.present? && Assignment.find_by_id(topic.assignment_id) %>
<% if !topic || can_do(topic, @current_user, :read) %>
<div style="<%= hidden unless topic %>" class="<%= is_announcement || topic.try_rescue(:type) == 'Announcement' || topic.try_rescue(:is_announcement) ? 'announcement' : 'discussion_topic' %> message_<%= contextless ? "blank" : context_code %> communication_message">

View File

@ -0,0 +1,29 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
describe "context/dashboard_topic" do
it "should render" do
render :partial => "context/dashboard_topic", :locals =>
{ :dashboard_topic => OpenObject.new({:root_discussion_entries => nil,
:created_at => Time.now.utc})}
response.should_not be_nil
end
end