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

namespace_basic_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: 9a0352991c865311ef6bcac66bd04540f1a70af3 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ::API::Entities::NamespaceBasic, feature_category: :groups_and_projects do
  let_it_be(:current_user) { create(:user) }
  let_it_be(:namespace) { create(:namespace) }

  let(:options) { { current_user: current_user } }

  let(:entity) do
    described_class.new(namespace, options)
  end

  subject(:json) { entity.as_json }

  shared_examples 'returns a response' do
    it 'returns required fields' do
      expect(json[:id]).to be_present
      expect(json[:name]).to be_present
      expect(json[:path]).to be_present
      expect(json[:kind]).to be_present
      expect(json[:full_path]).to be_present
      expect(json[:web_url]).to be_present
    end
  end

  include_examples 'returns a response'

  context 'for a user namespace' do
    let_it_be(:namespace) { create(:user_namespace) }

    include_examples 'returns a response'

    context 'when user namespece owner is missing' do
      before do
        namespace.update_column(:owner_id, non_existing_record_id)
      end

      include_examples 'returns a response'

      it 'returns correct web_url' do
        expect(json[:web_url]).to include(namespace.path)
      end
    end
  end
end