2016-10-31 07:00:53 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Route, models: true do
|
2016-12-19 15:36:47 -05:00
|
|
|
let!(:group) { create(:group, path: 'gitlab') }
|
2016-10-31 07:00:53 -04:00
|
|
|
let!(:route) { group.route }
|
|
|
|
|
|
|
|
describe 'relationships' do
|
|
|
|
it { is_expected.to belong_to(:source) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:source) }
|
|
|
|
it { is_expected.to validate_presence_of(:path) }
|
|
|
|
it { is_expected.to validate_uniqueness_of(:path) }
|
|
|
|
end
|
|
|
|
|
2017-01-05 07:43:50 -05:00
|
|
|
describe '#rename_descendants' do
|
2016-10-31 07:00:53 -04:00
|
|
|
let!(:nested_group) { create(:group, path: "test", parent: group) }
|
|
|
|
let!(:deep_nested_group) { create(:group, path: "foo", parent: nested_group) }
|
2016-12-19 15:36:47 -05:00
|
|
|
let!(:similar_group) { create(:group, path: 'gitlab-org') }
|
2016-10-31 07:00:53 -04:00
|
|
|
|
2016-12-19 15:36:47 -05:00
|
|
|
before { route.update_attributes(path: 'bar') }
|
2016-10-31 07:00:53 -04:00
|
|
|
|
2016-12-19 15:36:47 -05:00
|
|
|
it "updates children routes with new path" do
|
2016-10-31 07:00:53 -04:00
|
|
|
expect(described_class.exists?(path: 'bar')).to be_truthy
|
|
|
|
expect(described_class.exists?(path: 'bar/test')).to be_truthy
|
|
|
|
expect(described_class.exists?(path: 'bar/test/foo')).to be_truthy
|
2016-12-19 15:36:47 -05:00
|
|
|
expect(described_class.exists?(path: 'gitlab-org')).to be_truthy
|
2016-10-31 07:00:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|