diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-08 20:22:33 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 23:49:41 +0300 |
commit | 8f6dac4991ba7f5771a24175784f19dc1bbd4103 (patch) | |
tree | 5d4f4c06f6bd56db03474dd5d97002d82331a91e /spec/controllers/groups_controller_spec.rb | |
parent | 518216c0627cb6c4b3db62f10877b44d0e912ddb (diff) |
Allow filtering children for a group
When fetching children for a group with a filter, we will search all
nested groups for results and render them in an expanded tree
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 9b4654dc3e4..9cddb538a59 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -224,6 +224,36 @@ describe GroupsController do expect(assigns(:children)).to contain_exactly(public_subgroup, public_project) end end + + context 'filtering children' do + def get_filtered_list + get :children, id: group.to_param, filter: 'filter', format: :json + end + + it 'expands the tree for matching projects' do + project = create(:project, :public, namespace: public_subgroup, name: 'filterme') + + get_filtered_list + + group_json = json_response.first + project_json = group_json['children'].first + + expect(group_json['id']).to eq(public_subgroup.id) + expect(project_json['id']).to eq(project.id) + end + + it 'expands the tree for matching subgroups' do + matched_group = create(:group, :public, parent: public_subgroup, name: 'filterme') + + get_filtered_list + + group_json = json_response.first + matched_group_json = group_json['children'].first + + expect(group_json['id']).to eq(public_subgroup.id) + expect(matched_group_json['id']).to eq(matched_group.id) + end + end end end |