Commit 81d437ab authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '218252-custom-integration-projects-fix' into 'master'

Fix list custom integration projects !33043

See merge request gitlab-org/gitlab!33838
parents c0c6ba9d c062666e
...@@ -4,13 +4,16 @@ module Integration ...@@ -4,13 +4,16 @@ module Integration
extend ActiveSupport::Concern extend ActiveSupport::Concern
class_methods do class_methods do
def with_custom_integration_compared_to(integration) def with_custom_integration_for(integration, page = nil, per = nil)
custom_integrations = Service custom_integration_project_ids = Service
.select('1') .where(type: integration.type)
.where(type: integration.type, inherit_from_id: nil) .where(inherit_from_id: nil)
.where('services.project_id = projects.id') .distinct # Required until https://gitlab.com/gitlab-org/gitlab/-/issues/207385
.page(page)
.per(per)
.pluck(:project_id)
Project.where('EXISTS (?)', custom_integrations) Project.where(id: custom_integration_project_ids)
end end
end end
end end
...@@ -118,7 +118,6 @@ namespace :admin do ...@@ -118,7 +118,6 @@ namespace :admin do
resources :services, only: [:index, :edit, :update] resources :services, only: [:index, :edit, :update]
resources :integrations, only: [:edit, :update] do resources :integrations, only: [:edit, :update] do
member do member do
get :custom_integration_projects
put :test put :test
end end
end end
......
...@@ -4,7 +4,6 @@ require 'spec_helper' ...@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec.describe Admin::IntegrationsController do RSpec.describe Admin::IntegrationsController do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:integration) { create(:jira_service, :instance) }
before do before do
sign_in(admin) sign_in(admin)
...@@ -34,6 +33,8 @@ RSpec.describe Admin::IntegrationsController do ...@@ -34,6 +33,8 @@ RSpec.describe Admin::IntegrationsController do
end end
describe '#update' do describe '#update' do
let(:integration) { create(:jira_service, :instance) }
before do before do
allow(PropagateIntegrationWorker).to receive(:perform_async) allow(PropagateIntegrationWorker).to receive(:perform_async)
...@@ -67,14 +68,4 @@ RSpec.describe Admin::IntegrationsController do ...@@ -67,14 +68,4 @@ RSpec.describe Admin::IntegrationsController do
end end
end end
end end
describe '#custom_integration_projects' do
it 'calls to get the custom integration projects' do
allow(Project).to receive_message_chain(:with_custom_integration_compared_to, :page, :per)
get :custom_integration_projects, params: { id: integration.class.to_param }
expect(Project).to have_received(:with_custom_integration_compared_to).with(integration)
end
end
end end
...@@ -13,9 +13,9 @@ RSpec.describe Integration do ...@@ -13,9 +13,9 @@ RSpec.describe Integration do
create(:slack_service, project: project_1, inherit_from_id: nil) create(:slack_service, project: project_1, inherit_from_id: nil)
end end
describe '#with_custom_integration_compared_to' do describe '#with_custom_integration_for' do
it 'returns projects with custom integrations' do it 'returns projects with custom integrations' do
expect(Project.with_custom_integration_compared_to(instance_integration)).to contain_exactly(project_2) expect(Project.with_custom_integration_for(instance_integration)).to contain_exactly(project_2)
end end
end end
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