Commit a7046b5b authored by Sean McGivern's avatar Sean McGivern

Merge branch '4024-avoid-deleting-events-when-group-removed' into 'master'

Removed dependent constraint!

Closes #4024

See merge request gitlab-org/gitlab-ee!3377
parents a0775070 8882da71
......@@ -37,7 +37,7 @@ class Group < Namespace
# We cannot simply set `has_many :audit_events, as: :entity, dependent: :destroy`
# here since Group inherits from Namespace, the entity_type would be set to `Namespace`.
has_many :audit_events, -> { where(entity_type: Group) }, dependent: :delete_all, foreign_key: 'entity_id' # rubocop:disable Cop/ActiveRecordDependent
has_many :audit_events, -> { where(entity_type: Group) }, foreign_key: 'entity_id'
validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? }
validate :visibility_level_allowed_by_projects
......
......@@ -16,7 +16,7 @@ describe Project do
it { is_expected.to have_many(:path_locks) }
it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_many(:source_pipelines) }
it { is_expected.to have_many(:audit_events) }
it { is_expected.to have_many(:audit_events).dependent(false) }
end
describe '.mirrors_to_sync' do
......
......@@ -18,6 +18,7 @@ describe Group do
it { is_expected.to have_many(:uploads).dependent(:destroy) }
it { is_expected.to have_one(:chat_team) }
it { is_expected.to have_many(:custom_attributes).class_name('GroupCustomAttribute') }
it { is_expected.to have_many(:audit_events).dependent(false) }
describe '#members & #requesters' do
let(:requester) { create(:user) }
......
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