diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-05 11:32:52 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-05 12:11:21 +0300 |
commit | 951abe2b2efc3a208ceea46d9c1c47d3d253ff63 (patch) | |
tree | beb57ac3312f4c0c45285ce82d7849220e5a7cdc /spec/models/concerns | |
parent | ec8a7a36c09f44c44a21444f632389e7d08166cf (diff) |
Load counts everywhere we render a group tree
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/loaded_in_group_list_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/concerns/loaded_in_group_list_spec.rb b/spec/models/concerns/loaded_in_group_list_spec.rb new file mode 100644 index 00000000000..d64b288aa0c --- /dev/null +++ b/spec/models/concerns/loaded_in_group_list_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe LoadedInGroupList do + let(:parent) { create(:group) } + subject(:found_group) { Group.with_selects_for_list.find_by(id: parent.id) } + + before do + create(:group, parent: parent) + create(:project, namespace: parent) + parent.add_developer(create(:user)) + end + + describe '.with_selects_for_list' do + it 'includes the preloaded counts for groups' do + found_group = Group.with_selects_for_list.find_by(id: parent.id) + + expect(found_group.preloaded_project_count).to eq(1) + expect(found_group.preloaded_subgroup_count).to eq(1) + expect(found_group.preloaded_member_count).to eq(1) + end + end + + describe '#children_count' do + it 'counts groups and projects' do + expect(found_group.children_count).to eq(2) + end + end +end |