Commit 758a70e6 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'id-move-approvals-to-ce' into 'master'

Move Approval model to FOSS

See merge request gitlab-org/gitlab!35502
parents 86828cb3 99ad6088
...@@ -92,6 +92,9 @@ class MergeRequest < ApplicationRecord ...@@ -92,6 +92,9 @@ class MergeRequest < ApplicationRecord
has_many :draft_notes has_many :draft_notes
has_many :reviews, inverse_of: :merge_request has_many :reviews, inverse_of: :merge_request
has_many :approvals, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :approved_by_users, through: :approvals, source: :user
KNOWN_MERGE_PARAMS = [ KNOWN_MERGE_PARAMS = [
:auto_merge_strategy, :auto_merge_strategy,
:should_remove_source_branch, :should_remove_source_branch,
......
...@@ -15,8 +15,6 @@ module EE ...@@ -15,8 +15,6 @@ module EE
include DeprecatedApprovalsBeforeMerge include DeprecatedApprovalsBeforeMerge
include UsageStatistics include UsageStatistics
has_many :approvals, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :approved_by_users, through: :approvals, source: :user
has_many :approvers, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :approvers, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :approver_users, through: :approvers, source: :user has_many :approver_users, through: :approvers, source: :user
has_many :approver_groups, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :approver_groups, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Approval do
subject { create(:approval) }
it { is_expected.to be_valid }
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Approval do
context 'presence validation' do
it { is_expected.to validate_presence_of(:merge_request_id) }
it { is_expected.to validate_presence_of(:user_id) }
end
context 'uniqueness validation' do
let!(:existing_record) { create(:approval) }
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to([:merge_request_id]) }
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