Commit 2898d923 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #4996 from hiroponz/drop-support-of-root-namespace

[WIP]Drop support of root namespace in routing
parents df92d4ff 553841ec
...@@ -157,7 +157,7 @@ Gitlab::Application.routes.draw do ...@@ -157,7 +157,7 @@ Gitlab::Application.routes.draw do
# #
# Project Area # Project Area
# #
resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
member do member do
put :transfer put :transfer
post :fork post :fork
...@@ -177,13 +177,13 @@ Gitlab::Application.routes.draw do ...@@ -177,13 +177,13 @@ Gitlab::Application.routes.draw do
resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/} match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}
resources :snippets do resources :snippets, constraints: {id: /\d+/} do
member do member do
get "raw" get "raw"
end end
end end
resources :wikis, only: [:show, :edit, :destroy, :create] do resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
collection do collection do
get :pages get :pages
put ':id' => 'wikis#update' put ':id' => 'wikis#update'
...@@ -195,7 +195,7 @@ Gitlab::Application.routes.draw do ...@@ -195,7 +195,7 @@ Gitlab::Application.routes.draw do
end end
end end
resource :wall, only: [:show] do resource :wall, only: [:show], constraints: {id: /\d+/} do
member do member do
get 'notes' get 'notes'
end end
...@@ -214,21 +214,21 @@ Gitlab::Application.routes.draw do ...@@ -214,21 +214,21 @@ Gitlab::Application.routes.draw do
end end
end end
resources :deploy_keys do resources :deploy_keys, constraints: {id: /\d+/} do
member do member do
put :enable put :enable
put :disable put :disable
end end
end end
resources :branches, only: [:index, :new, :create, :destroy] do resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
collection do collection do
get :recent get :recent
end end
end end
resources :tags, only: [:index, :new, :create, :destroy] resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
resources :protected_branches, only: [:index, :create, :destroy] resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
resources :refs, only: [] do resources :refs, only: [] do
collection do collection do
...@@ -262,14 +262,14 @@ Gitlab::Application.routes.draw do ...@@ -262,14 +262,14 @@ Gitlab::Application.routes.draw do
end end
end end
resources :hooks, only: [:index, :create, :destroy] do resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
member do member do
get :test get :test
end end
end end
resources :team, controller: 'team_members', only: [:index] resources :team, controller: 'team_members', only: [:index]
resources :milestones, except: [:destroy] resources :milestones, except: [:destroy], constraints: {id: /\d+/}
resources :labels, only: [:index] do resources :labels, only: [:index] do
collection do collection do
...@@ -283,7 +283,7 @@ Gitlab::Application.routes.draw do ...@@ -283,7 +283,7 @@ Gitlab::Application.routes.draw do
end end
end end
resources :team_members, except: [:index, :edit] do resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
collection do collection do
# Used for import team # Used for import team
...@@ -293,7 +293,7 @@ Gitlab::Application.routes.draw do ...@@ -293,7 +293,7 @@ Gitlab::Application.routes.draw do
end end
end end
resources :notes, only: [:index, :create, :destroy, :update] do resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
member do member do
delete :delete_attachment delete :delete_attachment
end end
......
...@@ -57,7 +57,7 @@ class Dashboard < Spinach::FeatureSteps ...@@ -57,7 +57,7 @@ class Dashboard < Spinach::FeatureSteps
And 'I have group with projects' do And 'I have group with projects' do
@group = create(:group) @group = create(:group)
@project = create(:project, group: @group) @project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master] @project.team << [current_user, :master]
......
...@@ -11,7 +11,7 @@ class Groups < Spinach::FeatureSteps ...@@ -11,7 +11,7 @@ class Groups < Spinach::FeatureSteps
And 'I have group with projects' do And 'I have group with projects' do
@group = create(:group, owner: current_user) @group = create(:group, owner: current_user)
@project = create(:project, group: @group) @project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master] @project.team << [current_user, :master]
......
...@@ -38,11 +38,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -38,11 +38,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
sleep 2 sleep 2
end end
When 'I switch ref to "v2.1.0"' do
page.select 'v2.1.0', from: 'ref'
sleep 2
end
When 'click "Show only selected branch" checkbox' do When 'click "Show only selected branch" checkbox' do
find('#filter_ref').click find('#filter_ref').click
sleep 2 sleep 2
......
...@@ -26,10 +26,13 @@ WebMock.allow_net_connect! ...@@ -26,10 +26,13 @@ WebMock.allow_net_connect!
# #
require 'capybara/poltergeist' require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :js_errors => false, :timeout => 60)
end
Spinach.hooks.on_tag("javascript") do Spinach.hooks.on_tag("javascript") do
::Capybara.current_driver = ::Capybara.javascript_driver ::Capybara.current_driver = ::Capybara.javascript_driver
end end
Capybara.default_wait_time = 10 Capybara.default_wait_time = 60
Capybara.ignore_hidden_elements = false Capybara.ignore_hidden_elements = false
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
......
...@@ -4,7 +4,7 @@ module API ...@@ -4,7 +4,7 @@ module API
before { authenticate! } before { authenticate! }
before { Thread.current[:current_user] = current_user } before { Thread.current[:current_user] = current_user }
resource :projects do resource :projects, requirements: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ } do
helpers do helpers do
def handle_merge_request_errors!(errors) def handle_merge_request_errors!(errors)
if errors[:project_access].any? if errors[:project_access].any?
......
...@@ -17,7 +17,7 @@ describe Projects::BlobController do ...@@ -17,7 +17,7 @@ describe Projects::BlobController do
describe "GET show" do describe "GET show" do
render_views render_views
before { get :show, project_id: project.code, id: id } before { get :show, project_id: project.to_param, id: id }
context "valid branch, valid file" do context "valid branch, valid file" do
let(:id) { 'master/README.md' } let(:id) { 'master/README.md' }
......
...@@ -13,7 +13,7 @@ describe Projects::CommitController do ...@@ -13,7 +13,7 @@ describe Projects::CommitController do
describe "#show" do describe "#show" do
shared_examples "export as" do |format| shared_examples "export as" do |format|
it "should generally work" do it "should generally work" do
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response).to be_success expect(response).to be_success
end end
...@@ -21,11 +21,11 @@ describe Projects::CommitController do ...@@ -21,11 +21,11 @@ describe Projects::CommitController do
it "should generate it" do it "should generate it" do
Commit.any_instance.should_receive(:"to_#{format}") Commit.any_instance.should_receive(:"to_#{format}")
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
end end
it "should render it" do it "should render it" do
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response.body).to eq(commit.send(:"to_#{format}")) expect(response.body).to eq(commit.send(:"to_#{format}"))
end end
...@@ -33,7 +33,7 @@ describe Projects::CommitController do ...@@ -33,7 +33,7 @@ describe Projects::CommitController do
it "should not escape Html" do it "should not escape Html" do
Commit.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ') Commit.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response.body).to_not include('&amp;') expect(response.body).to_not include('&amp;')
expect(response.body).to_not include('&gt;') expect(response.body).to_not include('&gt;')
...@@ -47,7 +47,7 @@ describe Projects::CommitController do ...@@ -47,7 +47,7 @@ describe Projects::CommitController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
...@@ -58,13 +58,13 @@ describe Projects::CommitController do ...@@ -58,13 +58,13 @@ describe Projects::CommitController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch" do it "should really be a git email patch" do
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response.body).to start_with("From #{commit.id}") expect(response.body).to start_with("From #{commit.id}")
end end
it "should contain a git diff" do it "should contain a git diff" do
get :show, project_id: project.code, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
......
...@@ -13,7 +13,7 @@ describe Projects::CommitsController do ...@@ -13,7 +13,7 @@ describe Projects::CommitsController do
describe "GET show" do describe "GET show" do
context "as atom feed" do context "as atom feed" do
it "should render as atom" do it "should render as atom" do
get :show, project_id: project.path, id: "master", format: "atom" get :show, project_id: project.to_param, id: "master", format: "atom"
response.should be_success response.should be_success
response.content_type.should == 'application/atom+xml' response.content_type.should == 'application/atom+xml'
end end
......
...@@ -14,7 +14,7 @@ describe Projects::MergeRequestsController do ...@@ -14,7 +14,7 @@ describe Projects::MergeRequestsController do
describe "#show" do describe "#show" do
shared_examples "export merge as" do |format| shared_examples "export merge as" do |format|
it "should generally work" do it "should generally work" do
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response).to be_success expect(response).to be_success
end end
...@@ -22,11 +22,11 @@ describe Projects::MergeRequestsController do ...@@ -22,11 +22,11 @@ describe Projects::MergeRequestsController do
it "should generate it" do it "should generate it" do
MergeRequest.any_instance.should_receive(:"to_#{format}") MergeRequest.any_instance.should_receive(:"to_#{format}")
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
end end
it "should render it" do it "should render it" do
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s) expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s)
end end
...@@ -34,7 +34,7 @@ describe Projects::MergeRequestsController do ...@@ -34,7 +34,7 @@ describe Projects::MergeRequestsController do
it "should not escape Html" do it "should not escape Html" do
MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ') MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response.body).to_not include('&amp;') expect(response.body).to_not include('&amp;')
expect(response.body).to_not include('&gt;') expect(response.body).to_not include('&gt;')
...@@ -48,7 +48,7 @@ describe Projects::MergeRequestsController do ...@@ -48,7 +48,7 @@ describe Projects::MergeRequestsController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
...@@ -59,13 +59,13 @@ describe Projects::MergeRequestsController do ...@@ -59,13 +59,13 @@ describe Projects::MergeRequestsController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch with commit" do it "should really be a git email patch with commit" do
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}")
end end
it "should contain git diffs" do it "should contain git diffs" do
get :show, project_id: project.code, id: merge_request.iid, format: format get :show, project_id: project.to_param, id: merge_request.iid, format: format
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
......
...@@ -18,7 +18,7 @@ describe Projects::TreeController do ...@@ -18,7 +18,7 @@ describe Projects::TreeController do
# Make sure any errors accessing the tree in our views bubble up to this spec # Make sure any errors accessing the tree in our views bubble up to this spec
render_views render_views
before { get :show, project_id: project.code, id: id } before { get :show, project_id: project.to_param, id: id }
context "valid branch, no path" do context "valid branch, no path" do
let(:id) { 'master' } let(:id) { 'master' }
......
...@@ -28,6 +28,7 @@ FactoryGirl.define do ...@@ -28,6 +28,7 @@ FactoryGirl.define do
factory :project do factory :project do
sequence(:name) { |n| "project#{n}" } sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
namespace
creator creator
trait :source do trait :source do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe "Issues Feed" do describe "Issues Feed" do
describe "GET /issues" do describe "GET /issues" do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace) } let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) } let!(:issue) { create(:issue, author: user, project: project) }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
......
...@@ -58,11 +58,11 @@ describe Project do ...@@ -58,11 +58,11 @@ describe Project do
let!(:project) { create(:project) } let!(:project) { create(:project) }
it { should validate_presence_of(:name) } it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:name).scoped_to(:namespace_id) }
it { should ensure_length_of(:name).is_within(0..255) } it { should ensure_length_of(:name).is_within(0..255) }
it { should validate_presence_of(:path) } it { should validate_presence_of(:path) }
it { should validate_uniqueness_of(:path) } it { should validate_uniqueness_of(:path).scoped_to(:namespace_id) }
it { should ensure_length_of(:path).is_within(0..255) } it { should ensure_length_of(:path).is_within(0..255) }
it { should ensure_length_of(:description).is_within(0..2000) } it { should ensure_length_of(:description).is_within(0..2000) }
it { should validate_presence_of(:creator) } it { should validate_presence_of(:creator) }
...@@ -157,15 +157,6 @@ describe Project do ...@@ -157,15 +157,6 @@ describe Project do
it { Project.find_with_namespace('gitlab/gitlab-ci').should == @project } it { Project.find_with_namespace('gitlab/gitlab-ci').should == @project }
it { Project.find_with_namespace('gitlab-ci').should be_nil } it { Project.find_with_namespace('gitlab-ci').should be_nil }
end end
context 'w/o namespace' do
before do
@project = create(:project, name: 'gitlab-ci')
end
it { Project.find_with_namespace('gitlab-ci').should == @project }
it { Project.find_with_namespace('gitlab/gitlab-ci').should be_nil }
end
end end
describe :to_param do describe :to_param do
...@@ -177,14 +168,6 @@ describe Project do ...@@ -177,14 +168,6 @@ describe Project do
it { @project.to_param.should == "gitlab/gitlab-ci" } it { @project.to_param.should == "gitlab/gitlab-ci" }
end end
context 'w/o namespace' do
before do
@project = create(:project, name: 'gitlab-ci')
end
it { @project.to_param.should == "gitlab-ci" }
end
end end
describe :repository do describe :repository do
......
This diff is collapsed.
This diff is collapsed.
...@@ -11,11 +11,11 @@ end ...@@ -11,11 +11,11 @@ end
# /:path Grack # /:path Grack
describe "Mounted Apps", "routing" do describe "Mounted Apps", "routing" do
it "to API" do it "to API" do
get("/api").should be_routable get("/api/issues").should be_routable
end end
it "to Grack" do it "to Grack" do
get("/gitlabhq.git").should be_routable get("/gitlab/gitlabhq.git").should be_routable
end end
end end
......
...@@ -48,7 +48,7 @@ describe GitPushService do ...@@ -48,7 +48,7 @@ describe GitPushService do
it { should include(id: @commit.id) } it { should include(id: @commit.id) }
it { should include(message: @commit.safe_message) } it { should include(message: @commit.safe_message) }
it { should include(timestamp: @commit.date.xmlschema) } it { should include(timestamp: @commit.date.xmlschema) }
it { should include(url: "#{Gitlab.config.gitlab.url}/#{project.code}/commit/#{@commit.id}") } it { should include(url: "#{Gitlab.config.gitlab.url}/#{project.to_param}/commit/#{@commit.id}") }
context "with a author" do context "with a author" do
subject { @push_data[:commits].first[:author] } subject { @push_data[:commits].first[:author] }
......
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