Extend api v2 users service with project scope

pull/1065/head
Till Breuer 11 years ago
parent 77b930e237
commit 30095e6d54
  1. 4
      app/services/user_search_service.rb
  2. 1
      config/routes.rb
  3. 15
      spec/controllers/api/v2/users_controller_spec.rb

@ -31,6 +31,7 @@ class UserSearchService
attr_accessor :params
SEARCH_SCOPES = [
'project_id',
'ids',
'group_id',
'status',
@ -42,7 +43,8 @@ class UserSearchService
end
def search
scope = User
scope = params[:project_id] ? Project.find(params[:project_id]).users : User
params[:ids].present? ? ids_search(scope) : query_search(scope)
end

@ -93,6 +93,7 @@ OpenProject::Application.routes.draw do
get :available_projects, :on => :collection
end
resources :statuses, :only => [:index, :show]
resources :users, only: [:index]
member do
get :planning_element_custom_fields

@ -101,6 +101,21 @@ describe Api::V2::UsersController do
end
end
describe 'within a project' do
include_context "As a normal user"
let(:project) { FactoryGirl.create :project }
let!(:member) { FactoryGirl.create :user, member_in_project: project }
let!(:non_member) { FactoryGirl.create :user }
before { get 'index', project_id: project.to_param, format: :json }
it_behaves_like "valid user API call" do
let(:user_count) { 1 }
end
end
describe 'search for ids' do
include_context "As an admin"

Loading…
Cancel
Save