2021-03-08 18:12:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MemberSerializer do
|
|
|
|
include MembersPresentation
|
|
|
|
|
|
|
|
let_it_be(:current_user) { create(:user) }
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
subject { described_class.new.represent(members, { current_user: current_user, group: group, source: source }) }
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
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-03-11 19:13:27 +05:30
|
|
|
let(:source) { group }
|
2021-03-08 18:12:59 +05:30
|
|
|
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-03-11 19:13:27 +05:30
|
|
|
let(:source) { project }
|
2021-03-08 18:12:59 +05:30
|
|
|
let(:group) { project.group }
|
|
|
|
let(:members) { present_members(create_list(:project_member, 1, project: project)) }
|
|
|
|
|
|
|
|
it_behaves_like 'members.json'
|
|
|
|
end
|
|
|
|
end
|