kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.2 KiB
73 lines
2.2 KiB
9 years ago
|
shared_examples_for 'repository can be relocated' do |vendor|
|
||
|
let(:job) { ::Scm::RelocateRepositoryJob.new repository }
|
||
|
let(:project) { FactoryGirl.build :project }
|
||
|
let(:repository) {
|
||
|
repo = FactoryGirl.build("repository_#{vendor}".to_sym,
|
||
|
project: project,
|
||
|
scm_type: :managed)
|
||
|
|
||
|
repo.configure(:managed, nil)
|
||
|
repo.save!
|
||
|
|
||
|
repo
|
||
|
}
|
||
|
|
||
|
before do
|
||
|
allow(::Scm::RelocateRepositoryJob).to receive(:new).and_return(job)
|
||
|
allow(Repository).to receive(:find).and_return(repository)
|
||
|
end
|
||
|
|
||
|
context 'with managed local config' do
|
||
|
include_context 'with tmpdir'
|
||
|
let(:config) { { manages: File.join(tmpdir, 'myrepos') } }
|
||
|
|
||
|
it 'relocates when project identifier is updated' do
|
||
|
current_path = repository.root_url
|
||
|
expect(repository.root_url).to eq(repository.managed_repository_path)
|
||
|
expect(Dir.exists?(repository.managed_repository_path)).to be true
|
||
|
|
||
|
# Rename the project
|
||
|
project.update_attributes!(identifier: 'somenewidentifier')
|
||
|
repository.reload
|
||
|
|
||
|
job.perform
|
||
|
|
||
|
# Confirm that all paths are updated
|
||
|
expect(current_path).not_to eq(repository.managed_repository_path)
|
||
|
expect(current_path).not_to eq(repository.root_url)
|
||
|
expect(repository.url).to eq(repository.managed_repository_url)
|
||
|
|
||
|
expect(Dir.exists?(repository.managed_repository_path)).to be true
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'with managed remote config', webmock: true do
|
||
|
let(:url) { 'http://myreposerver.example.com/api/' }
|
||
|
let(:config) { { manages: url } }
|
||
|
|
||
|
let(:repository) {
|
||
|
stub_request(:post, url).to_return(status: 200)
|
||
|
FactoryGirl.create("repository_#{vendor}".to_sym,
|
||
|
project: project,
|
||
|
scm_type: :managed)
|
||
|
}
|
||
|
|
||
|
before do
|
||
|
stub_request(:post, url).to_return(status: 200)
|
||
|
end
|
||
|
|
||
|
it 'sends a relocation request when project identifier is updated' do
|
||
|
current_path = repository.root_url
|
||
|
|
||
|
# Rename the project
|
||
|
project.identifier = 'somenewidentifier'
|
||
|
job.perform
|
||
|
|
||
|
expect(WebMock)
|
||
|
.to have_requested(:post, url)
|
||
|
.with(body: hash_including(old_repository: current_path,
|
||
|
action: 'relocate'))
|
||
|
end
|
||
|
end
|
||
|
end
|