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
expect(described_class.find_by_pages_host(host)).to eq(namespace)
end
it 'finds correct namespace even if there is sub-namespace with same path' do
group = create(:group, path: 'pages')
subgroup = create(:group, :nested, path: 'pages')
context 'when there is non-top-level group with searched name' do
before do
create(:group, :nested, path: 'pages')
end
it 'ignores this group' do
host = "pages.#{Settings.pages.host.upcase}"
# This is to ensure the method does the right thing
# becasue there is no way to be 100% sure which exact
# group will be returned by the database
expect(described_class).to receive(:where).with(parent_id: nil).and_call_original
expect(described_class.find_by_pages_host(host)).to be_nil
end
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)
end
end
it "returns no result if the provided host is not subdomain of the Pages host" do
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