diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-02-04 20:26:11 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-02-08 19:14:29 +0200 |
commit | 2989192d1aa8051aa09164cd097418bd3063d4ad (patch) | |
tree | e277adf2535ac10ed338481ef092731ef84b27e1 /spec/models/concerns/routable_spec.rb | |
parent | bbb7fbcd02c9d9a8a6d6ca44d7ce668b80962c21 (diff) | |
download | gitlab-ce-dz-refactor-full-path.tar.gz |
Store group and project full name and full path in routes tabledz-refactor-full-path
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models/concerns/routable_spec.rb')
-rw-r--r-- | spec/models/concerns/routable_spec.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index 30443534cca..e008ec28fa4 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -14,12 +14,14 @@ describe Group, 'Routable' do describe 'Callbacks' do it 'creates route record on create' do expect(group.route.path).to eq(group.path) + expect(group.route.name).to eq(group.name) end it 'updates route record on path change' do - group.update_attributes(path: 'wow') + group.update_attributes(path: 'wow', name: 'much') expect(group.route.path).to eq('wow') + expect(group.route.name).to eq('much') end it 'ensure route path uniqueness across different objects' do @@ -78,4 +80,34 @@ describe Group, 'Routable' do it { is_expected.to eq([nested_group]) } end + + describe '#full_path' do + let(:group) { create(:group) } + let(:nested_group) { create(:group, parent: group) } + + it { expect(group.full_path).to eq(group.path) } + it { expect(nested_group.full_path).to eq("#{group.path}/#{nested_group.path}") } + end + + describe '#full_name' do + let(:group) { create(:group) } + let(:nested_group) { create(:group, parent: group) } + + it { expect(group.full_name).to eq(group.name) } + it { expect(nested_group.full_name).to eq("#{group.name} / #{nested_group.name}") } + end +end + +describe Project, 'Routable' do + describe '#full_path' do + let(:project) { build_stubbed(:empty_project) } + + it { expect(project.full_path).to eq "#{project.namespace.path}/#{project.path}" } + end + + describe '#full_name' do + let(:project) { build_stubbed(:empty_project) } + + it { expect(project.full_name).to eq "#{project.namespace.human_name} / #{project.name}" } + end end |