Commit 185a8b2d authored by Vladimir Shushlin's avatar Vladimir Shushlin

Assert that pages API can't return subgroup

parent 9082e910
...@@ -201,18 +201,25 @@ describe Namespace do ...@@ -201,18 +201,25 @@ describe Namespace do
expect(described_class.find_by_pages_host(host)).to eq(namespace) expect(described_class.find_by_pages_host(host)).to eq(namespace)
end end
it 'finds correct namespace even if there is sub-namespace with same path' do context 'when there is non-top-level group with searched name' do
group = create(:group, path: 'pages') before do
subgroup = create(:group, :nested, path: 'pages') create(:group, :nested, path: 'pages')
end
it 'ignores this group' do
host = "pages.#{Settings.pages.host.upcase}" host = "pages.#{Settings.pages.host.upcase}"
# This is to ensure the method does the right thing expect(described_class.find_by_pages_host(host)).to be_nil
# becasue there is no way to be 100% sure which exact end
# group will be returned by the database
expect(described_class).to receive(:where).with(parent_id: nil).and_call_original it 'finds right top level group' do
group = create(:group, path: 'pages')
host = "pages.#{Settings.pages.host.upcase}"
expect(described_class.find_by_pages_host(host)).to eq(group) expect(described_class.find_by_pages_host(host)).to eq(group)
end end
end
it "returns no result if the provided host is not subdomain of the Pages host" do it "returns no result if the provided host is not subdomain of the Pages host" do
create(:namespace, name: 'namespace.io') create(:namespace, name: 'namespace.io')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment