Skip to content

Commit

Permalink
@Forum was never going to be nil in a method called find_forum... wha…
Browse files Browse the repository at this point in the history
…t was I on?
  • Loading branch information
radar committed Nov 18, 2008
1 parent 96195e9 commit 0f112e7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
9 changes: 1 addition & 8 deletions app/controllers/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,7 @@ def not_found
def find_forum
@forum = Forum.find(params[:forum_id], :include => [:topics, :posts]) if params[:forum_id]
if @forum.viewable?(logged_in?, current_user)
if params[:id]
if @forum.nil?
@topic = Topic.find(params[:id], :joins => :posts)
@forum = @topic.forum
else
@topic = @forum.topics.find(params[:id], :joins => :posts)
end
end
@topic = @forum.topics.find(params[:id], :joins => :posts)
else
flash[:notice] = t(:not_allowed_to_view_topics)
redirect_to root_path
Expand Down
2 changes: 1 addition & 1 deletion app/views/forums/_forum.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<td align='center'><%= forum.posts.size %></td>
<td align='right'><% if !forum.last_post.nil? %>
<%= time_ago_in_words(forum.last_post.created_at) %> <%= t(:ago) %>
<%= t(:Ryan) %> <%= link_to(h(forum.last_post.user.login), forum.last_post.user) %>
<%= t(:by) %> <%= link_to(h(forum.last_post.user.login), forum.last_post.user) %>
<%= t(:in) %> <%= link_to(h(forum.last_post.topic.subject), forum_topic_path(forum,forum.last_post.topic)) %>
<% if !forum.last_post_forum.nil? %>
<%= t(:in) %> <%= link_to(h(forum.last_post_forum), forum_path(forum.last_post_forum)) %>
Expand Down
11 changes: 0 additions & 11 deletions spec/controllers/topics_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,4 @@ def topic_does_not_belong

end

describe TopicsController, "for logged in moderator" do
before do
login_as(:moderator)
end

it "should not be able to lock any topic in the admin forum" do
put 'lock', { :id => @admin_topic.id, :forum_id => @admin_forum.id }
response.should redirect_to(root_path)
flash[:notice].should eql("You are not allowed to view topics in that forum.")
end
end
end

0 comments on commit 0f112e7

Please sign in to comment.