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

get_badges_query_spec.rb « rest « common « bulk_imports « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0a04c0a22430462f2737bfd960a6ce636f1952f5 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe BulkImports::Common::Rest::GetBadgesQuery do
  describe '.to_h' do
    shared_examples 'resource and page info query' do
      let(:tracker) { create(:bulk_import_tracker, entity: entity) }
      let(:context) { BulkImports::Pipeline::Context.new(tracker) }
      let(:encoded_full_path) { ERB::Util.url_encode(entity.source_full_path) }

      it 'returns correct query and page info' do
        expected = {
          resource: [entity.pluralized_name, encoded_full_path, 'badges'].join('/'),
          query: {
            page: context.tracker.next_page
          }
        }

        expect(described_class.to_h(context)).to eq(expected)
      end
    end

    context 'when entity is group' do
      let(:entity) { create(:bulk_import_entity) }

      include_examples 'resource and page info query'
    end

    context 'when entity is project' do
      let(:entity) { create(:bulk_import_entity, :project_entity) }

      include_examples 'resource and page info query'
    end
  end
end