mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Server error when no results on user directory while logged in
This commit is contained in:
parent
e5c3266c30
commit
33e35930b0
2 changed files with 16 additions and 1 deletions
|
@ -41,7 +41,7 @@ class DirectoryItemsController < ApplicationController
|
|||
more_params[:page] = page + 1
|
||||
|
||||
# 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
|
||||
result.insert(0, your_item) if your_item
|
||||
end
|
||||
|
|
|
@ -11,6 +11,21 @@ describe DirectoryItemsController do
|
|||
response.should_not be_success
|
||||
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
|
||||
before do
|
||||
Fabricate(:user)
|
||||
|
|
Loading…
Reference in a new issue