提交 47555ef8 编写于 作者: R 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
......@@ -94,7 +94,7 @@ module Boards
def serialize_as_json(resource)
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,
issue_endpoints: true,
include_full_project_path: board.group_board?,
......
......@@ -23,7 +23,7 @@ class Profiles::KeysController < Profiles::ApplicationController
def destroy
@key = current_user.keys.find(params[:id])
@key.destroy
Keys::DestroyService.new(current_user).execute(@key)
respond_to do |format|
format.html { redirect_to profile_keys_url, status: 302 }
......
......@@ -11,7 +11,14 @@ module Projects
@hook = ProjectHook.new
# 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
......
......@@ -997,7 +997,7 @@ class Project < ActiveRecord::Base
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)
if service
......@@ -1014,6 +1014,14 @@ class Project < ActiveRecord::Base
end
end
end
available_services.reject do |service|
disabled_services.include?(service.to_param)
end
end
def disabled_services
[]
end
def find_or_initialize_service(name)
......
......@@ -2,7 +2,7 @@ module Keys
class BaseService
attr_accessor :user, :params
def initialize(user, params)
def initialize(user, params = {})
@user, @params = user, params
@ip_address = @params.delete(:ip_address)
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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册