2021-01-14 13:10:59 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MemberSerializer do
|
|
|
|
include MembersPresentation
|
|
|
|
|
|
|
|
let_it_be(:current_user) { create(:user) }
|
|
|
|
|
2021-01-28 13:09:27 -05:00
|
|
|
subject { described_class.new.represent(members, { current_user: current_user, group: group, source: source }) }
|
2021-01-14 13:10:59 -05:00
|
|
|
|
|
|
|
shared_examples 'members.json' do
|
|
|
|
it 'matches json schema' do
|
|
|
|
expect(subject.to_json).to match_schema('members')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'group member' do
|
|
|
|
let(:group) { create(:group) }
|
2021-01-28 13:09:27 -05:00
|
|
|
let(:source) { group }
|
2021-01-14 13:10:59 -05:00
|
|
|
let(:members) { present_members(create_list(:group_member, 1, group: group)) }
|
|
|
|
|
|
|
|
it_behaves_like 'members.json'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'project member' do
|
|
|
|
let(:project) { create(:project) }
|
2021-01-28 13:09:27 -05:00
|
|
|
let(:source) { project }
|
2021-01-14 13:10:59 -05:00
|
|
|
let(:group) { project.group }
|
|
|
|
let(:members) { present_members(create_list(:project_member, 1, project: project)) }
|
|
|
|
|
|
|
|
it_behaves_like 'members.json'
|
|
|
|
end
|
|
|
|
end
|