diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 21:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 21:07:51 +0300 |
commit | 6cae2159b8ce1e84fad48f3dbd5368995cbd87b1 (patch) | |
tree | 46d6b7cbd78d72fe5dcb5d6b1ed973b30deadc71 /spec/serializers/import/github_realtime_repo_serializer_spec.rb | |
parent | 84f9f0cb8137637708a41152347e7754c1e9fb83 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/import/github_realtime_repo_serializer_spec.rb')
-rw-r--r-- | spec/serializers/import/github_realtime_repo_serializer_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/serializers/import/github_realtime_repo_serializer_spec.rb b/spec/serializers/import/github_realtime_repo_serializer_spec.rb new file mode 100644 index 00000000000..b656132e332 --- /dev/null +++ b/spec/serializers/import/github_realtime_repo_serializer_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Import::GithubRealtimeRepoSerializer, feature_category: :importers do + subject(:serializer) { described_class.new } + + it '.entity_class' do + expect(described_class.entity_class).to eq(Import::GithubRealtimeRepoEntity) + end + + describe '#represent' do + let(:import_state) { instance_double(ProjectImportState, failed?: false, in_progress?: true) } + let(:project) do + instance_double( + Project, + id: 100500, + import_status: 'importing', + import_state: import_state + ) + end + + let(:expected_data) do + { + id: project.id, + import_status: 'importing', + stats: { fetched: {}, imported: {} } + }.deep_stringify_keys + end + + context 'when a single object is being serialized' do + let(:resource) { project } + + it 'serializes organization object' do + expect(serializer.represent(resource).as_json).to eq expected_data + end + end + + context 'when multiple objects are being serialized' do + let(:count) { 3 } + let(:resource) { Array.new(count, project) } + + it 'serializes array of organizations' do + expect(serializer.represent(resource).as_json).to all(eq(expected_data)) + end + end + end +end |