Commit 59a330f4 authored by Valery Sizov's avatar Valery Sizov

Remove assigned_(issues|merge_requests) methods from the issuable

parent d910a777
......@@ -194,7 +194,7 @@ module IssuablesHelper
def assigned_issuables_count(assignee, issuable_type, state)
params = { assignee_id: assignee.id, state: state }
Object::const_get("#{issuable_type.to_s.camelize}Finder").new(current_user, params).execute.count
Object.const_get("#{issuable_type.to_s.camelize}Finder").new(current_user, params).execute.count
end
def sidebar_gutter_collapsed?
......
......@@ -99,9 +99,6 @@ class User < ActiveRecord::Base
has_many :award_emoji, dependent: :destroy
has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :owner_id
has_many :assigned_issues, dependent: :nullify, foreign_key: :assignee_id, class_name: "Issue"
has_many :assigned_merge_requests, dependent: :nullify, foreign_key: :assignee_id, class_name: "MergeRequest"
# Issues that a user owns are expected to be moved to the "ghost" user before
# the user is destroyed. If the user owns any issues during deletion, this
# should be treated as an exceptional condition.
......@@ -893,13 +890,13 @@ class User < ActiveRecord::Base
def assigned_open_merge_request_count(force: false)
Rails.cache.fetch(['users', id, 'assigned_open_merge_request_count'], force: force) do
assigned_merge_requests.opened.count
MergeRequestsFinder.new(self, assignee_id: self.id, state: 'opened').execute.count
end
end
def assigned_open_issues_count(force: false)
Rails.cache.fetch(['users', id, 'assigned_open_issues_count'], force: force) do
assigned_issues.opened.count
IssuesFinder.new(self, assignee_id: self.id, state: 'opened').execute.count
end
end
......
......@@ -24,9 +24,7 @@ describe User, models: true do
it { is_expected.to have_many(:recent_events).class_name('Event') }
it { is_expected.to have_many(:issues).dependent(:restrict_with_exception) }
it { is_expected.to have_many(:notes).dependent(:destroy) }
it { is_expected.to have_many(:assigned_issues).dependent(:nullify) }
it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
it { is_expected.to have_many(:assigned_merge_requests).dependent(:nullify) }
it { is_expected.to have_many(:identities).dependent(:destroy) }
it { is_expected.to have_many(:spam_logs).dependent(:destroy) }
it { is_expected.to have_many(:todos).dependent(:destroy) }
......
require 'spec_helper'
describe Members::AuthorizedDestroyService, services: true do
let(:user) { create(:user) }
let(:member_user) { create(:user) }
let(:project) { create(:empty_project, :public) }
let(:group) { create(:group, :public) }
let(:group_project) { create(:empty_project, :public, group: group) }
def number_of_assigned_issuables(user)
user.assigned_issues.count + user.assigned_merge_requests.count
Issue.assigned_to(user).count + MergeRequest.assigned_to(user).count
end
context 'Group member' do
......
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