2021-06-30 11:08:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe API::Entities::BasicProjectDetails do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
2022-01-24 07:10:54 -05:00
|
|
|
let(:current_user) { project.first_owner }
|
2021-06-30 11:08:27 -04:00
|
|
|
|
|
|
|
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
|