mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Server error when no results on user directory while logged in
This commit is contained in:
@ -41,7 +41,7 @@ class DirectoryItemsController < ApplicationController
|
|||||||
more_params[:page] = page + 1
|
more_params[:page] = page + 1
|
||||||
|
|
||||||
# Put yourself at the top of the first page
|
# Put yourself at the top of the first page
|
||||||
if current_user.present? && page == 0 && result[0].user_id != current_user.id
|
if result.present? && current_user.present? && page == 0 && result[0].user_id != current_user.id
|
||||||
your_item = DirectoryItem.where(period_type: period_type, user_id: current_user.id).first
|
your_item = DirectoryItem.where(period_type: period_type, user_id: current_user.id).first
|
||||||
result.insert(0, your_item) if your_item
|
result.insert(0, your_item) if your_item
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,21 @@ describe DirectoryItemsController do
|
|||||||
response.should_not be_success
|
response.should_not be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "without data" do
|
||||||
|
|
||||||
|
context "and a logged in user" do
|
||||||
|
let!(:user) { log_in }
|
||||||
|
|
||||||
|
it "succeeds" do
|
||||||
|
xhr :get, :index, period: 'all'
|
||||||
|
response.should be_success
|
||||||
|
json = ::JSON.parse(response.body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
context "with data" do
|
context "with data" do
|
||||||
before do
|
before do
|
||||||
Fabricate(:user)
|
Fabricate(:user)
|
||||||
|
Reference in New Issue
Block a user