mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: user directory returns staged users during search
This commit is contained in:
parent
546b206da0
commit
92a831bae6
5 changed files with 90 additions and 53 deletions
|
@ -1,51 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe DirectoryItemsController do
|
||||
|
||||
it "requires a `period` param" do
|
||||
expect { get :index, format: :json }.to raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
|
||||
it "requires a proper `period` param" do
|
||||
get :index, params: { period: 'eviltrout' }, format: :json
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
context "without data" do
|
||||
|
||||
context "and a logged in user" do
|
||||
let!(:user) { log_in }
|
||||
|
||||
it "succeeds" do
|
||||
get :index, params: { period: 'all' }, format: :json
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "with data" do
|
||||
before do
|
||||
Fabricate(:user)
|
||||
DirectoryItem.refresh!
|
||||
end
|
||||
|
||||
it "succeeds with a valid value" do
|
||||
get :index, params: { period: 'all' }, format: :json
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items']).to be_present
|
||||
expect(json['total_rows_directory_items']).to be_present
|
||||
expect(json['load_more_directory_items']).to be_present
|
||||
end
|
||||
|
||||
it "fails when the directory is disabled" do
|
||||
SiteSetting.enable_user_directory = false
|
||||
|
||||
get :index, params: { period: 'all' }, format: :json
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue