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

basic_project_details_spec.rb « entities « api « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8419eb0a9322b00b46b8874d7939da31872c4083 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe API::Entities::BasicProjectDetails do
  let_it_be(:project) { create(:project) }

  let(:current_user) { project.first_owner }

  subject(:output) { described_class.new(project, current_user: current_user).as_json }

  describe '#default_branch' do
    it 'delegates to Project#default_branch_or_main' do
      expect(project).to receive(:default_branch_or_main).twice.and_call_original

      expect(output).to include(default_branch: project.default_branch_or_main)
    end

    context 'anonymous user' do
      let(:current_user) { nil }

      it 'is not included' do
        expect(output.keys).not_to include(:default_branch)
      end
    end
  end
end