diff options
Diffstat (limited to 'spec/helpers/groups')
-rw-r--r-- | spec/helpers/groups/group_members_helper_spec.rb | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/spec/helpers/groups/group_members_helper_spec.rb b/spec/helpers/groups/group_members_helper_spec.rb index a25bf1c4157..bb92445cb19 100644 --- a/spec/helpers/groups/group_members_helper_spec.rb +++ b/spec/helpers/groups/group_members_helper_spec.rb @@ -5,9 +5,15 @@ require "spec_helper" RSpec.describe Groups::GroupMembersHelper do include MembersPresentation - describe '.group_member_select_options' do - let(:group) { create(:group) } + let_it_be(:current_user) { create(:user) } + let_it_be(:group) { create(:group) } + + before do + allow(helper).to receive(:can?).with(current_user, :owner_access, group).and_return(true) + allow(helper).to receive(:current_user).and_return(current_user) + end + describe '.group_member_select_options' do before do helper.instance_variable_set(:@group, group) end @@ -28,14 +34,6 @@ RSpec.describe Groups::GroupMembersHelper do end describe '#members_data_json' do - let(:current_user) { create(:user) } - let(:group) { create(:group) } - - before do - allow(helper).to receive(:can?).with(current_user, :owner_access, group).and_return(true) - allow(helper).to receive(:current_user).and_return(current_user) - end - shared_examples 'group_members.json' do it 'matches json schema' do json = helper.members_data_json(group, present_members([group_member])) @@ -48,6 +46,14 @@ RSpec.describe Groups::GroupMembersHelper do let(:group_member) { create(:group_member, group: group, created_by: current_user) } it_behaves_like 'group_members.json' + + context 'with user status set' do + let(:user) { create(:user) } + let!(:status) { create(:user_status, user: user) } + let(:group_member) { create(:group_member, group: group, user: user, created_by: current_user) } + + it_behaves_like 'group_members.json' + end end context 'for an invited group member' do @@ -62,4 +68,36 @@ RSpec.describe Groups::GroupMembersHelper do it_behaves_like 'group_members.json' end end + + describe '#group_members_list_data_attributes' do + let(:group_member) { create(:group_member, group: group, created_by: current_user) } + + before do + allow(helper).to receive(:group_group_member_path).with(group, ':id').and_return('/groups/foo-bar/-/group_members/:id') + end + + it 'returns expected hash' do + expect(helper.group_members_list_data_attributes(group, present_members([group_member]))).to include({ + members: helper.members_data_json(group, present_members([group_member])), + member_path: '/groups/foo-bar/-/group_members/:id', + group_id: group.id + }) + end + end + + describe '#linked_groups_list_data_attributes' do + include_context 'group_group_link' + + before do + allow(helper).to receive(:group_group_link_path).with(shared_group, ':id').and_return('/groups/foo-bar/-/group_links/:id') + end + + it 'returns expected hash' do + expect(helper.linked_groups_list_data_attributes(shared_group)).to include({ + members: helper.linked_groups_data_json(shared_group.shared_with_group_links), + member_path: '/groups/foo-bar/-/group_links/:id', + group_id: shared_group.id + }) + end + end end |