Welcome to mirror list, hosted at ThFree Co, Russian Federation.

review_requests_spec.rb « pull_requests « representation « github_import « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0393f692a69a5f46c9212976381870192710be53 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::GithubImport::Representation::PullRequests::ReviewRequests do
  shared_examples 'Review requests' do
    it 'returns an instance of Review Request' do
      expect(review_requests).to be_an_instance_of(described_class)
    end

    context 'for returned Review Requests' do
      it 'includes merge request id' do
        expect(review_requests.merge_request_id).to eq(merge_request_id)
      end

      it 'includes reviewers' do
        expect(review_requests.users.size).to eq 2

        user = review_requests.users[0]
        expect(user).to be_an_instance_of(Gitlab::GithubImport::Representation::User)
        expect(user.id).to eq(4)
        expect(user.login).to eq('alice')
      end
    end
  end

  let(:merge_request_id) { 6501124486 }
  let(:response) do
    {
      'merge_request_id' => merge_request_id,
      'users' => [
        { 'id' => 4, 'login' => 'alice' },
        { 'id' => 5, 'login' => 'bob' }
      ]
    }
  end

  describe '.from_api_response' do
    it_behaves_like 'Review requests' do
      let(:review_requests) { described_class.from_api_response(response) }
    end
  end

  describe '.from_json_hash' do
    it_behaves_like 'Review requests' do
      let(:review_requests) { described_class.from_json_hash(response) }
    end
  end
end