diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-14 10:01:29 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 23:49:41 +0300 |
commit | ea4e17e2aec525f249430b0a22dc6a8450648837 (patch) | |
tree | 99246d63a3bec435c9a62dcdf111ae2d86c610e7 /spec/controllers/concerns | |
parent | 3a4dc55f2924debcdbb37eb63d8ce57b1358df81 (diff) |
Search subgroups on dashboard and explore views
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r-- | spec/controllers/concerns/group_tree_spec.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/controllers/concerns/group_tree_spec.rb b/spec/controllers/concerns/group_tree_spec.rb index 19387f2d271..5d4fb66b492 100644 --- a/spec/controllers/concerns/group_tree_spec.rb +++ b/spec/controllers/concerns/group_tree_spec.rb @@ -5,7 +5,8 @@ describe GroupTree do let(:user) { create(:user) } controller(ApplicationController) do - include GroupTree # rubocop:disable Rspec/DescribedClass + # `described_class` is not available in this context + include GroupTree # rubocop:disable RSpec/DescribedClass def index render_group_tree Group.all @@ -43,6 +44,14 @@ describe GroupTree do expect(assigns(:groups)).to contain_exactly(subgroup) end + + it 'allows filtering for subgroups' do + subgroup = create(:group, :public, parent: group, name: 'filter') + + get :index, filter: 'filt', format: :json + + expect(assigns(:groups)).to contain_exactly(subgroup) + end end context 'json content' do @@ -51,6 +60,19 @@ describe GroupTree do expect(json_response.first['id']).to eq(group.id) end + + context 'nested groups', :nested_groups do + it 'expands the tree when filtering' do + subgroup = create(:group, :public, parent: group, name: 'filter') + + get :index, filter: 'filt', format: :json + + children_response = json_response.first['children'] + + expect(json_response.first['id']).to eq(group.id) + expect(children_response.first['id']).to eq(subgroup.id) + end + end end end end |