Commit 68ca8bf9 authored by Luke Duncalfe's avatar Luke Duncalfe
parent b25634b1
......@@ -11,9 +11,10 @@ class Admin::IntegrationsController < Admin::ApplicationController
def overrides
respond_to do |format|
format.json do
collection = Project.with_active_integration(integration.class).merge(::Integration.not_inherited)
projects = Project.with_active_integration(integration.class).merge(::Integration.not_inherited)
serializer = ::Integrations::ProjectSerializer.new.with_pagination(request, response)
render json: collection.page(params[:page]).per(20).to_json
render json: serializer.represent(projects)
end
# TODO frontend will add format.html
end
......
# frozen_string_literal: true
module Integrations
class ProjectEntity < Grape::Entity
include RequestAwareEntity
expose :avatar_url
expose :full_name
expose :name
expose :full_path do |project|
project_path(project)
end
end
end
# frozen_string_literal: true
module Integrations
class ProjectSerializer < BaseSerializer
include WithPagination
entity Integrations::ProjectEntity
end
end
......@@ -114,7 +114,8 @@ RSpec.describe Admin::IntegrationsController do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly(a_hash_including('id' => overridden_integration.project_id))
expect(response).to include_pagination_headers
expect(json_response).to contain_exactly(a_hash_including('full_name' => overridden_integration.project.full_name))
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::ProjectEntity do
let_it_be(:project) { create(:project, :with_avatar) }
let(:entity) do
described_class.new(project)
end
context 'as json' do
include Gitlab::Routing.url_helpers
subject { entity.as_json }
it 'contains needed attributes' do
expect(subject).to include(
avatar_url: include('uploads'),
name: project.name,
full_path: project_path(project),
full_name: project.full_name
)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::ProjectSerializer do
it 'represents Integrations::ProjectEntity entities' do
expect(described_class.entity_class).to eq(Integrations::ProjectEntity)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment