Commit 87c18617 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Move EE specific code to their respective places

parent 5d4250ae
......@@ -8,6 +8,9 @@ module EE
has_many :approvals, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :approvers, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :approver_groups, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
delegate :codeclimate_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :codeclimate_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
end
def ff_merge_possible?
......@@ -64,5 +67,10 @@ module EE
def supports_weight?
false
end
def has_codeclimate_data?
!!(head_codeclimate_artifact&.success? &&
base_codeclimate_artifact&.success?)
end
end
end
......@@ -38,9 +38,6 @@ class MergeRequest < ActiveRecord::Base
delegate :commits, :real_size, :commit_shas, :commits_count,
to: :merge_request_diff, prefix: nil
delegate :codeclimate_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :codeclimate_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
attr_accessor :allow_broken
......@@ -952,9 +949,4 @@ class MergeRequest < ActiveRecord::Base
def base_pipeline
@base_pipeline ||= project.pipelines.find_by(sha: merge_request_diff&.base_commit_sha)
end
def has_codeclimate_data?
!!(head_codeclimate_artifact&.success? &&
base_codeclimate_artifact&.success?)
end
end
......@@ -73,4 +73,36 @@ describe EE::User, models: true do
expect(user.full_private_access?).to be_truthy
end
end
describe '#forget_me!' do
subject { create(:user, remember_created_at: Time.now) }
it 'clears remember_created_at' do
subject.forget_me!
expect(subject.reload.remember_created_at).to be_nil
end
it 'does not clear remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
end
end
describe '#remember_me!' do
subject { create(:user, remember_created_at: nil) }
it 'updates remember_created_at' do
subject.remember_me!
expect(subject.reload.remember_created_at).not_to be_nil
end
it 'does not update remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
end
end
end
......@@ -2054,36 +2054,4 @@ describe User, models: true do
user.invalidate_merge_request_cache_counts
end
end
describe '#forget_me!' do
subject { create(:user, remember_created_at: Time.now) }
it 'clears remember_created_at' do
subject.forget_me!
expect(subject.reload.remember_created_at).to be_nil
end
it 'does not clear remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
end
end
describe '#remember_me!' do
subject { create(:user, remember_created_at: nil) }
it 'updates remember_created_at' do
subject.remember_me!
expect(subject.reload.remember_created_at).not_to be_nil
end
it 'does not update remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
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