diff options
author | Valery Sizov <valery@gitlab.com> | 2017-04-18 19:24:41 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-04-18 21:07:45 +0300 |
commit | 59a330f4cde708986b9112883b4d4f92b76e5c08 (patch) | |
tree | 1c7ef569ffe1a4b29bb0ae388ebdd47a7c9acfd1 | |
parent | d910a777cc53a9d087ede3079522870631baec07 (diff) | |
download | gitlab-ce-59a330f4cde708986b9112883b4d4f92b76e5c08.tar.gz |
Remove assigned_(issues|merge_requests) methods from the issuable
-rw-r--r-- | app/helpers/issuables_helper.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 7 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/members/authorized_destroy_service_spec.rb | 3 |
4 files changed, 4 insertions, 10 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 02780a4fe62..2b2b885bf52 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -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? diff --git a/app/models/user.rb b/app/models/user.rb index 457ba05fb04..87c409104b9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9de16c41e94..5cdf4e87ba5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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) } diff --git a/spec/services/members/authorized_destroy_service_spec.rb b/spec/services/members/authorized_destroy_service_spec.rb index 9912800da53..5cf2a4f656c 100644 --- a/spec/services/members/authorized_destroy_service_spec.rb +++ b/spec/services/members/authorized_destroy_service_spec.rb @@ -1,14 +1,13 @@ 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 |