Commit 47555ef8 authored by Robert Speicher's avatar Robert Speicher

Merge branch '6020-extract-ee-specific-controller-lines' into 'master'

[CE]  Resolve "Extract EE specific files/lines for some controllers"

See merge request gitlab-org/gitlab-ce!18994
parents 4583e67c 8d024ba7
...@@ -94,7 +94,7 @@ module Boards ...@@ -94,7 +94,7 @@ module Boards
def serialize_as_json(resource) def serialize_as_json(resource)
resource.as_json( resource.as_json(
only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position], only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position, :weight],
labels: true, labels: true,
issue_endpoints: true, issue_endpoints: true,
include_full_project_path: board.group_board?, include_full_project_path: board.group_board?,
......
...@@ -23,7 +23,7 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -23,7 +23,7 @@ class Profiles::KeysController < Profiles::ApplicationController
def destroy def destroy
@key = current_user.keys.find(params[:id]) @key = current_user.keys.find(params[:id])
@key.destroy Keys::DestroyService.new(current_user).execute(@key)
respond_to do |format| respond_to do |format|
format.html { redirect_to profile_keys_url, status: 302 } format.html { redirect_to profile_keys_url, status: 302 }
......
...@@ -11,7 +11,14 @@ module Projects ...@@ -11,7 +11,14 @@ module Projects
@hook = ProjectHook.new @hook = ProjectHook.new
# Services # Services
@services = @project.find_or_initialize_services @services = @project.find_or_initialize_services(exceptions: service_exceptions)
end
private
# Returns a list of services that should be hidden from the list
def service_exceptions
@project.disabled_services.dup
end end
end end
end end
......
...@@ -997,7 +997,7 @@ class Project < ActiveRecord::Base ...@@ -997,7 +997,7 @@ class Project < ActiveRecord::Base
available_services_names = Service.available_services_names - exceptions available_services_names = Service.available_services_names - exceptions
available_services_names.map do |service_name| available_services = available_services_names.map do |service_name|
service = find_service(services, service_name) service = find_service(services, service_name)
if service if service
...@@ -1014,6 +1014,14 @@ class Project < ActiveRecord::Base ...@@ -1014,6 +1014,14 @@ class Project < ActiveRecord::Base
end end
end end
end end
available_services.reject do |service|
disabled_services.include?(service.to_param)
end
end
def disabled_services
[]
end end
def find_or_initialize_service(name) def find_or_initialize_service(name)
......
...@@ -2,7 +2,7 @@ module Keys ...@@ -2,7 +2,7 @@ module Keys
class BaseService class BaseService
attr_accessor :user, :params attr_accessor :user, :params
def initialize(user, params) def initialize(user, params = {})
@user, @params = user, params @user, @params = user, params
@ip_address = @params.delete(:ip_address) @ip_address = @params.delete(:ip_address)
end end
......
module Keys
class DestroyService < ::Keys::BaseService
def execute(key)
key.destroy if destroy_possible?(key)
end
# overriden in EE::Keys::DestroyService
def destroy_possible?(key)
true
end
end
end
require 'spec_helper'
describe Keys::DestroyService do
let(:user) { create(:user) }
subject { described_class.new(user) }
it 'destroys a key' do
key = create(:key)
expect { subject.execute(key) }.to change(Key, :count).by(-1)
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