summaryrefslogtreecommitdiff
path: root/spec/lib/atlassian/jira_connect/serializers/author_entity_spec.rb
blob: f31cf929244f2b4044044fe5941d42dea0b8b46b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Atlassian::JiraConnect::Serializers::AuthorEntity do
  subject { described_class.represent(user).as_json }

  context 'when object is a User model' do
    let(:user) { build_stubbed(:user) }

    it 'exposes all fields' do
      expect(subject.keys).to contain_exactly(:name, :email, :username, :url, :avatar)
    end
  end

  context 'when object is a CommitAuthor struct from a commit' do
    let(:user) { Atlassian::JiraConnect::Serializers::CommitEntity::CommitAuthor.new('Full Name', 'user@example.com') }

    it 'exposes name and email only' do
      expect(subject.keys).to contain_exactly(:name, :email)
    end
  end
end