Merge pull request #2749 from evazion/fix-private-topic-ambiguous-column
Fix AmbiguousColumn exception in /forum_posts?search[creator_id]=1
This commit is contained in:
@@ -55,7 +55,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def permitted
|
||||
joins(:topic).where("min_level <= ?", CurrentUser.level)
|
||||
joins(:topic).where("forum_topics.min_level <= ?", CurrentUser.level)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
@@ -63,11 +63,11 @@ class ForumPost < ActiveRecord::Base
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
q = q.where("forum_posts.creator_id = ?", params[:creator_id].to_i)
|
||||
end
|
||||
|
||||
if params[:topic_id].present?
|
||||
q = q.where("topic_id = ?", params[:topic_id].to_i)
|
||||
q = q.where("forum_posts.topic_id = ?", params[:topic_id].to_i)
|
||||
end
|
||||
|
||||
if params[:topic_title_matches].present?
|
||||
|
||||
@@ -35,6 +35,12 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
assert_response :success
|
||||
assert_equal(0, assigns(:forum_posts).size)
|
||||
end
|
||||
|
||||
should "list by creator id" do
|
||||
get :index, {:search => {:creator_id => @user.id}}
|
||||
assert_response :success
|
||||
assert_equal(1, assigns(:forum_posts).size)
|
||||
end
|
||||
end
|
||||
|
||||
context "with private topics" do
|
||||
|
||||
Reference in New Issue
Block a user