#265: added specs for PullRequest model
This commit is contained in:
parent
81f82cbb7d
commit
01098152e9
|
@ -294,9 +294,12 @@ class Project < ActiveRecord::Base
|
|||
self.name = new_name
|
||||
FileUtils.mv old_path, new_path, :force => true
|
||||
|
||||
FileUtils.mv File.join(APP_CONFIG['git_path'], 'pull_requests', owner.uname, old_name),
|
||||
File.join(APP_CONFIG['git_path'], 'pull_requests', owner.uname, new_name),
|
||||
:force => true
|
||||
pull_requests_old_path = File.join(APP_CONFIG['git_path'], 'pull_requests', owner.uname, old_name)
|
||||
if Dir.exists?(pull_requests_old_path)
|
||||
FileUtils.mv pull_requests_old_path,
|
||||
File.join(APP_CONFIG['git_path'], 'pull_requests', owner.uname, new_name),
|
||||
:force => true
|
||||
end
|
||||
|
||||
PullRequest.where(:from_project_id => id).update_all(:from_project_name => new_name)
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def update_relations(old_from_project_name)
|
||||
def update_relations(old_from_project_name = nil)
|
||||
FileUtils.mv path(old_from_project_name), path, :force => true if old_from_project_name
|
||||
return unless Dir.exists?(path)
|
||||
Dir.chdir(path) do
|
||||
system 'git', 'remote', 'remove', 'origin'
|
||||
system 'git', 'remote', 'add', 'origin', to_project.path
|
||||
if to_project != from_project
|
||||
if cross_pull?
|
||||
system 'git', 'remote', 'remove', 'head'
|
||||
system 'git', 'remote', 'add', 'head', from_project.path
|
||||
end
|
||||
|
@ -123,11 +123,7 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def from_branch
|
||||
if to_project_id != from_project_id
|
||||
"head_#{from_ref}"
|
||||
else
|
||||
from_ref
|
||||
end
|
||||
cross_pull? ? "head_#{from_ref}" : from_ref
|
||||
end
|
||||
|
||||
def common_ancestor
|
||||
|
@ -196,7 +192,7 @@ class PullRequest < ActiveRecord::Base
|
|||
`rm -rf #{path}`
|
||||
git.fs_mkdir('..')
|
||||
git.clone(options, to_project.path, path)
|
||||
if to_project != from_project
|
||||
if cross_pull?
|
||||
Dir.chdir(path) do
|
||||
system 'git', 'remote', 'add', 'head', from_project.path
|
||||
end
|
||||
|
|
|
@ -94,9 +94,7 @@ describe Project do
|
|||
|
||||
it 'ensures that path to git repository has been changed after rename of project' do
|
||||
project = FactoryGirl.create(:project_with_commit)
|
||||
project.name = "#{project.name}_renamed"
|
||||
project.save
|
||||
project.reload
|
||||
project.update_attributes(:name => "#{project.name}-new")
|
||||
Dir.exists?(project.path).should be_true
|
||||
end
|
||||
|
||||
|
|
|
@ -33,6 +33,13 @@ describe PullRequest do
|
|||
@other_pull.save
|
||||
end
|
||||
|
||||
it 'ensures that path to pull_request repository has been changed after rename of project' do
|
||||
@pull.check
|
||||
@project.update_attributes(:name => "#{@project.name}-new")
|
||||
@pull.reload
|
||||
Dir.exists?(@pull.path).should be_true
|
||||
end
|
||||
|
||||
it 'master should merge with non_conflicts branch' do
|
||||
@pull.check
|
||||
@pull.status.should == 'ready'
|
||||
|
|
Loading…
Reference in New Issue