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

Assert that pages API can't return subgroup

parent 9082e910
...@@ -201,17 +201,24 @@ describe Namespace do ...@@ -201,17 +201,24 @@ 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')
host = "pages.#{Settings.pages.host.upcase}" end
# This is to ensure the method does the right thing it 'ignores this group' do
# becasue there is no way to be 100% sure which exact host = "pages.#{Settings.pages.host.upcase}"
# 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
expect(described_class.find_by_pages_host(host)).to eq(group) 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 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
......
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