Commit cb1f3423 authored by Nick Thomas's avatar Nick Thomas

Don't resolve fork relationships for projects pending delete

parent 1501a4f5
class ForkedProjectLink < ActiveRecord::Base
belongs_to :forked_to_project, class_name: 'Project'
belongs_to :forked_from_project, class_name: 'Project'
belongs_to :forked_to_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
belongs_to :forked_from_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
end
......@@ -24,6 +24,22 @@ describe ForkedProjectLink, "add link on fork" do
expect(project_to.forked_from_project).to eq(project_from)
end
context 'project_to is pending_delete' do
before do
project_to.update!(pending_delete: true)
end
it { expect(project_from.forks.count).to eq(0) }
end
context 'project_from is pending_delete' do
before do
project_from.update!(pending_delete: true)
end
it { expect(project_to.forked_from_project).to be_nil }
end
describe '#forked?' do
let(:project_to) { create(:project, forked_project_link: forked_project_link) }
let(:forked_project_link) { build(:forked_project_link) }
......
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