summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/github_import/representation/user_spec.rb
blob: d7219556adab156c9eaac1fe22e01672898fed92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Gitlab::GithubImport::Representation::User do
  shared_examples 'a User' do
    it 'returns an instance of User' do
      expect(user).to be_an_instance_of(described_class)
    end

    context 'the returned User' do
      it 'includes the user ID' do
        expect(user.id).to eq(42)
      end

      it 'includes the username' do
        expect(user.login).to eq('alice')
      end
    end
  end

  describe '.from_api_response' do
    it_behaves_like 'a User' do
      let(:response) { double(:response, id: 42, login: 'alice') }
      let(:user) { described_class.from_api_response(response) }
    end
  end

  describe '.from_json_hash' do
    it_behaves_like 'a User' do
      let(:hash) { { 'id' => 42, 'login' => 'alice' } }
      let(:user) { described_class.from_json_hash(hash) }
    end
  end
end