debian-mirror-gitlab/spec/models/forked_project_link_spec.rb

69 lines
1.7 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
describe ForkedProjectLink, "add link on fork" do
2018-03-17 18:26:18 +05:30
include ProjectForksHelper
2017-08-17 22:00:37 +05:30
let(:project_from) { create(:project, :repository) }
2017-09-10 17:25:29 +05:30
let(:project_to) { fork_project(project_from, user) }
let(:user) { create(:user) }
2014-09-02 18:07:02 +05:30
before do
2017-09-10 17:25:29 +05:30
project_from.add_reporter(user)
end
it 'project_from knows its forks' do
_ = project_to
expect(project_from.forks.count).to eq(1)
2014-09-02 18:07:02 +05:30
end
2016-09-13 17:45:13 +05:30
it "project_to knows it is forked" do
2017-09-10 17:25:29 +05:30
expect(project_to.forked?).to be_truthy
2014-09-02 18:07:02 +05:30
end
2016-09-13 17:45:13 +05:30
it "project knows who it is forked from" do
2017-09-10 17:25:29 +05:30
expect(project_to.forked_from_project).to eq(project_from)
2014-09-02 18:07:02 +05:30
end
2017-09-10 17:25:29 +05:30
context 'project_to is pending_delete' do
before do
project_to.update!(pending_delete: true)
end
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
it { expect(project_from.forks.count).to eq(0) }
2014-09-02 18:07:02 +05:30
end
2017-09-10 17:25:29 +05:30
context 'project_from is pending_delete' do
before do
project_from.update!(pending_delete: true)
end
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
it { expect(project_to.forked_from_project).to be_nil }
2014-09-02 18:07:02 +05:30
end
2017-09-10 17:25:29 +05:30
describe '#forked?' do
let(:project_to) { create(:project, :repository, forked_project_link: forked_project_link) }
let(:forked_project_link) { create(:forked_project_link) }
before do
forked_project_link.forked_from_project = project_from
forked_project_link.forked_to_project = project_to
forked_project_link.save!
end
it "project_to knows it is forked" do
expect(project_to.forked?).to be_truthy
end
it "project_from is not forked" do
expect(project_from.forked?).to be_falsey
end
it "project_to.destroy destroys fork_link" do
project_to.destroy
expect(ForkedProjectLink.exists?(id: forked_project_link.id)).to eq(false)
end
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
end