Commit ed16c351 authored by Douwe Maan's avatar Douwe Maan

Fix specs

parent 4345bb8c
...@@ -22,7 +22,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d ...@@ -22,7 +22,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get :contributed, as: :contributed_projects get :contributed, as: :contributed_projects
get :snippets get :snippets
get :exists get :exists
get '/', to: redirect('/%{username}') get '/', to: redirect('/%{username}'), as: nil
end end
# Compatibility with old routing # Compatibility with old routing
......
...@@ -71,7 +71,7 @@ structure. ...@@ -71,7 +71,7 @@ structure.
- You need to be an Owner of a group in order to be able to create - You need to be an Owner of a group in order to be able to create
a subgroup. For more information check the [permissions table][permissions]. a subgroup. For more information check the [permissions table][permissions].
- For a list of words that are not allowed to be used as group names see the - For a list of words that are not allowed to be used as group names see the
[`dynamic_path_validator.rb` file][reserved] under the `TOP_LEVEL_ROUTES`, `PROJECT_WILDCARD_ROUTES` and `GROUP_ROUTES` lists: [`path_regex.rb` file][reserved] under the `TOP_LEVEL_ROUTES`, `PROJECT_WILDCARD_ROUTES` and `GROUP_ROUTES` lists:
- `TOP_LEVEL_ROUTES`: are names that are reserved as usernames or top level groups - `TOP_LEVEL_ROUTES`: are names that are reserved as usernames or top level groups
- `PROJECT_WILDCARD_ROUTES`: are names that are reserved for child groups or projects. - `PROJECT_WILDCARD_ROUTES`: are names that are reserved for child groups or projects.
- `GROUP_ROUTES`: are names that are reserved for all groups or projects. - `GROUP_ROUTES`: are names that are reserved for all groups or projects.
...@@ -163,4 +163,4 @@ Here's a list of what you can't do with subgroups: ...@@ -163,4 +163,4 @@ Here's a list of what you can't do with subgroups:
[ce-2772]: https://gitlab.com/gitlab-org/gitlab-ce/issues/2772 [ce-2772]: https://gitlab.com/gitlab-org/gitlab-ce/issues/2772
[permissions]: ../../permissions.md#group [permissions]: ../../permissions.md#group
[reserved]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/validators/dynamic_path_validator.rb [reserved]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/path_regex.rb
...@@ -133,9 +133,13 @@ describe Import::BitbucketController do ...@@ -133,9 +133,13 @@ describe Import::BitbucketController do
end end
context "when a namespace with the Bitbucket user's username already exists" do context "when a namespace with the Bitbucket user's username already exists" do
let!(:existing_namespace) { create(:namespace, name: other_username, owner: user) } let!(:existing_namespace) { create(:group, name: other_username) }
context "when the namespace is owned by the GitLab user" do context "when the namespace is owned by the GitLab user" do
before do
existing_namespace.add_owner(user)
end
it "takes the existing namespace" do it "takes the existing namespace" do
expect(Gitlab::BitbucketImport::ProjectCreator). expect(Gitlab::BitbucketImport::ProjectCreator).
to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params). to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params).
...@@ -146,11 +150,6 @@ describe Import::BitbucketController do ...@@ -146,11 +150,6 @@ describe Import::BitbucketController do
end end
context "when the namespace is not owned by the GitLab user" do context "when the namespace is not owned by the GitLab user" do
before do
existing_namespace.owner = create(:user)
existing_namespace.save
end
it "doesn't create a project" do it "doesn't create a project" do
expect(Gitlab::BitbucketImport::ProjectCreator). expect(Gitlab::BitbucketImport::ProjectCreator).
not_to receive(:new) not_to receive(:new)
...@@ -202,10 +201,14 @@ describe Import::BitbucketController do ...@@ -202,10 +201,14 @@ describe Import::BitbucketController do
end end
context 'user has chosen an existing nested namespace and name for the project' do context 'user has chosen an existing nested namespace and name for the project' do
let(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let(:parent_namespace) { create(:group, name: 'foo', owner: user) }
let(:nested_namespace) { create(:namespace, name: 'bar', parent: parent_namespace, owner: user) } let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
before do
nested_namespace.add_owner(user)
end
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::BitbucketImport::ProjectCreator). expect(Gitlab::BitbucketImport::ProjectCreator).
to receive(:new).with(bitbucket_repo, test_name, nested_namespace, user, access_params). to receive(:new).with(bitbucket_repo, test_name, nested_namespace, user, access_params).
...@@ -248,7 +251,7 @@ describe Import::BitbucketController do ...@@ -248,7 +251,7 @@ describe Import::BitbucketController do
context 'user has chosen existent and non-existent nested namespaces and name for the project' do context 'user has chosen existent and non-existent nested namespaces and name for the project' do
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
let!(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let!(:parent_namespace) { create(:group, name: 'foo', owner: user) }
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::BitbucketImport::ProjectCreator). expect(Gitlab::BitbucketImport::ProjectCreator).
......
...@@ -108,9 +108,13 @@ describe Import::GitlabController do ...@@ -108,9 +108,13 @@ describe Import::GitlabController do
end end
context "when a namespace with the GitLab.com user's username already exists" do context "when a namespace with the GitLab.com user's username already exists" do
let!(:existing_namespace) { create(:namespace, name: other_username, owner: user) } let!(:existing_namespace) { create(:group, name: other_username) }
context "when the namespace is owned by the GitLab server user" do context "when the namespace is owned by the GitLab server user" do
before do
existing_namespace.add_owner(user)
end
it "takes the existing namespace" do it "takes the existing namespace" do
expect(Gitlab::GitlabImport::ProjectCreator). expect(Gitlab::GitlabImport::ProjectCreator).
to receive(:new).with(gitlab_repo, existing_namespace, user, access_params). to receive(:new).with(gitlab_repo, existing_namespace, user, access_params).
...@@ -121,11 +125,6 @@ describe Import::GitlabController do ...@@ -121,11 +125,6 @@ describe Import::GitlabController do
end end
context "when the namespace is not owned by the GitLab server user" do context "when the namespace is not owned by the GitLab server user" do
before do
existing_namespace.owner = create(:user)
existing_namespace.save
end
it "doesn't create a project" do it "doesn't create a project" do
expect(Gitlab::GitlabImport::ProjectCreator). expect(Gitlab::GitlabImport::ProjectCreator).
not_to receive(:new) not_to receive(:new)
...@@ -174,10 +173,14 @@ describe Import::GitlabController do ...@@ -174,10 +173,14 @@ describe Import::GitlabController do
end end
end end
end end
context 'user has chosen an existing nested namespace for the project' do context 'user has chosen an existing nested namespace for the project' do
let(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let(:parent_namespace) { create(:group, name: 'foo', owner: user) }
let(:nested_namespace) { create(:namespace, name: 'bar', parent: parent_namespace, owner: user) } let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
before do
nested_namespace.add_owner(user)
end
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::GitlabImport::ProjectCreator). expect(Gitlab::GitlabImport::ProjectCreator).
...@@ -221,7 +224,7 @@ describe Import::GitlabController do ...@@ -221,7 +224,7 @@ describe Import::GitlabController do
context 'user has chosen existent and non-existent nested namespaces and name for the project' do context 'user has chosen existent and non-existent nested namespaces and name for the project' do
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
let!(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let!(:parent_namespace) { create(:group, name: 'foo', owner: user) }
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::GitlabImport::ProjectCreator). expect(Gitlab::GitlabImport::ProjectCreator).
......
...@@ -18,8 +18,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -18,8 +18,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
let(:subject) { described_class.new(['parent/the-Path'], migration) } let(:subject) { described_class.new(['parent/the-Path'], migration) }
it 'includes the namespace' do it 'includes the namespace' do
parent = create(:namespace, path: 'parent') parent = create(:group, path: 'parent')
child = create(:namespace, path: 'the-path', parent: parent) child = create(:group, path: 'the-path', parent: parent)
found_ids = subject.namespaces_for_paths(type: :child). found_ids = subject.namespaces_for_paths(type: :child).
map(&:id) map(&:id)
...@@ -30,13 +30,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -30,13 +30,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
context 'for child namespaces' do context 'for child namespaces' do
it 'only returns child namespaces with the correct path' do it 'only returns child namespaces with the correct path' do
_root_namespace = create(:namespace, path: 'THE-path') _root_namespace = create(:group, path: 'THE-path')
_other_path = create(:namespace, _other_path = create(:group,
path: 'other', path: 'other',
parent: create(:namespace)) parent: create(:group))
namespace = create(:namespace, namespace = create(:group,
path: 'the-path', path: 'the-path',
parent: create(:namespace)) parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :child). found_ids = subject.namespaces_for_paths(type: :child).
map(&:id) map(&:id)
...@@ -45,13 +45,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -45,13 +45,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
end end
it 'has no namespaces that look the same' do it 'has no namespaces that look the same' do
_root_namespace = create(:namespace, path: 'THE-path') _root_namespace = create(:group, path: 'THE-path')
_similar_path = create(:namespace, _similar_path = create(:group,
path: 'not-really-the-path', path: 'not-really-the-path',
parent: create(:namespace)) parent: create(:group))
namespace = create(:namespace, namespace = create(:group,
path: 'the-path', path: 'the-path',
parent: create(:namespace)) parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :child). found_ids = subject.namespaces_for_paths(type: :child).
map(&:id) map(&:id)
...@@ -62,11 +62,11 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -62,11 +62,11 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
context 'for top levelnamespaces' do context 'for top levelnamespaces' do
it 'only returns child namespaces with the correct path' do it 'only returns child namespaces with the correct path' do
root_namespace = create(:namespace, path: 'the-path') root_namespace = create(:group, path: 'the-path')
_other_path = create(:namespace, path: 'other') _other_path = create(:group, path: 'other')
_child_namespace = create(:namespace, _child_namespace = create(:group,
path: 'the-path', path: 'the-path',
parent: create(:namespace)) parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :top_level). found_ids = subject.namespaces_for_paths(type: :top_level).
map(&:id) map(&:id)
...@@ -75,11 +75,11 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -75,11 +75,11 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
end end
it 'has no namespaces that just look the same' do it 'has no namespaces that just look the same' do
root_namespace = create(:namespace, path: 'the-path') root_namespace = create(:group, path: 'the-path')
_similar_path = create(:namespace, path: 'not-really-the-path') _similar_path = create(:group, path: 'not-really-the-path')
_child_namespace = create(:namespace, _child_namespace = create(:group,
path: 'the-path', path: 'the-path',
parent: create(:namespace)) parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :top_level). found_ids = subject.namespaces_for_paths(type: :top_level).
map(&:id) map(&:id)
...@@ -124,10 +124,10 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -124,10 +124,10 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
describe "#child_ids_for_parent" do describe "#child_ids_for_parent" do
it "collects child ids for all levels" do it "collects child ids for all levels" do
parent = create(:namespace) parent = create(:group)
first_child = create(:namespace, parent: parent) first_child = create(:group, parent: parent)
second_child = create(:namespace, parent: parent) second_child = create(:group, parent: parent)
third_child = create(:namespace, parent: second_child) third_child = create(:group, parent: second_child)
all_ids = [parent.id, first_child.id, second_child.id, third_child.id] all_ids = [parent.id, first_child.id, second_child.id, third_child.id]
collected_ids = subject.child_ids_for_parent(parent, ids: [parent.id]) collected_ids = subject.child_ids_for_parent(parent, ids: [parent.id])
...@@ -205,9 +205,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do ...@@ -205,9 +205,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
end end
describe '#rename_namespaces' do describe '#rename_namespaces' do
let!(:top_level_namespace) { create(:namespace, path: 'the-path') } let!(:top_level_namespace) { create(:group, path: 'the-path') }
let!(:child_namespace) do let!(:child_namespace) do
create(:namespace, path: 'the-path', parent: create(:namespace)) create(:group, path: 'the-path', parent: create(:group))
end end
it 'renames top level namespaces the namespace' do it 'renames top level namespaces the namespace' do
......
...@@ -209,9 +209,13 @@ shared_examples 'a GitHub-ish import controller: POST create' do ...@@ -209,9 +209,13 @@ shared_examples 'a GitHub-ish import controller: POST create' do
end end
context 'user has chosen a namespace and name for the project' do context 'user has chosen a namespace and name for the project' do
let(:test_namespace) { create(:namespace, name: 'test_namespace', owner: user) } let(:test_namespace) { create(:group, name: 'test_namespace') }
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
before do
test_namespace.add_owner(user)
end
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::GithubImport::ProjectCreator). expect(Gitlab::GithubImport::ProjectCreator).
to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider). to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider).
...@@ -230,10 +234,14 @@ shared_examples 'a GitHub-ish import controller: POST create' do ...@@ -230,10 +234,14 @@ shared_examples 'a GitHub-ish import controller: POST create' do
end end
context 'user has chosen an existing nested namespace and name for the project' do context 'user has chosen an existing nested namespace and name for the project' do
let(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let(:parent_namespace) { create(:group, name: 'foo', owner: user) }
let(:nested_namespace) { create(:namespace, name: 'bar', parent: parent_namespace, owner: user) } let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
before do
nested_namespace.add_owner(user)
end
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::GithubImport::ProjectCreator). expect(Gitlab::GithubImport::ProjectCreator).
to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider). to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider).
...@@ -276,7 +284,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do ...@@ -276,7 +284,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do
context 'user has chosen existent and non-existent nested namespaces and name for the project' do context 'user has chosen existent and non-existent nested namespaces and name for the project' do
let(:test_name) { 'test_name' } let(:test_name) { 'test_name' }
let!(:parent_namespace) { create(:namespace, name: 'foo', owner: user) } let!(:parent_namespace) { create(:group, name: 'foo', owner: user) }
it 'takes the selected namespace and name' do it 'takes the selected namespace and name' do
expect(Gitlab::GithubImport::ProjectCreator). expect(Gitlab::GithubImport::ProjectCreator).
......
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