Commit df9cbbc9 authored by Hiroyuki Sato's avatar Hiroyuki Sato

Drop support of root namespace in routing

parent e1ca9de0
......@@ -157,7 +157,7 @@ Gitlab::Application.routes.draw do
#
# 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
put :transfer
post :fork
......@@ -177,13 +177,13 @@ Gitlab::Application.routes.draw do
resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
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
get "raw"
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
get :pages
put ':id' => 'wikis#update'
......@@ -195,7 +195,7 @@ Gitlab::Application.routes.draw do
end
end
resource :wall, only: [:show] do
resource :wall, only: [:show], constraints: {id: /\d+/} do
member do
get 'notes'
end
......@@ -214,21 +214,21 @@ Gitlab::Application.routes.draw do
end
end
resources :deploy_keys do
resources :deploy_keys, constraints: {id: /\d+/} do
member do
put :enable
put :disable
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
get :recent
end
end
resources :tags, only: [:index, :new, :create, :destroy]
resources :protected_branches, only: [:index, :create, :destroy]
resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
resources :refs, only: [] do
collection do
......@@ -262,14 +262,14 @@ Gitlab::Application.routes.draw do
end
end
resources :hooks, only: [:index, :create, :destroy] do
resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
member do
get :test
end
end
resources :team, controller: 'team_members', only: [:index]
resources :milestones, except: [:destroy]
resources :milestones, except: [:destroy], constraints: {id: /\d+/}
resources :labels, only: [:index] do
collection do
......@@ -283,7 +283,7 @@ Gitlab::Application.routes.draw do
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
# Used for import team
......@@ -293,7 +293,7 @@ Gitlab::Application.routes.draw do
end
end
resources :notes, only: [:index, :create, :destroy, :update] do
resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
member do
delete :delete_attachment
end
......
......@@ -57,7 +57,7 @@ class Dashboard < Spinach::FeatureSteps
And 'I have group with projects' do
@group = create(:group)
@project = create(:project, group: @group)
@project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master]
......
......@@ -11,7 +11,7 @@ class Groups < Spinach::FeatureSteps
And 'I have group with projects' do
@group = create(:group, owner: current_user)
@project = create(:project, group: @group)
@project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master]
......
......@@ -38,11 +38,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
sleep 2
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
find('#filter_ref').click
sleep 2
......
......@@ -4,7 +4,7 @@ module API
before { authenticate! }
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
def handle_merge_request_errors!(errors)
if errors[:project_access].any?
......
......@@ -17,7 +17,7 @@ describe Projects::BlobController do
describe "GET show" do
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
let(:id) { 'master/README.md' }
......
......@@ -13,7 +13,7 @@ describe Projects::CommitController do
describe "#show" do
shared_examples "export as" do |format|
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
end
......@@ -21,11 +21,11 @@ describe Projects::CommitController do
it "should generate it" do
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
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}"))
end
......@@ -33,7 +33,7 @@ describe Projects::CommitController do
it "should not escape Html" do
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('&gt;')
......@@ -47,7 +47,7 @@ describe Projects::CommitController do
let(:format) { :diff }
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")
end
......@@ -58,13 +58,13 @@ describe Projects::CommitController do
let(:format) { :patch }
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}")
end
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/)
end
......
......@@ -13,7 +13,7 @@ describe Projects::CommitsController do
describe "GET show" do
context "as atom feed" 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.content_type.should == 'application/atom+xml'
end
......
......@@ -14,7 +14,7 @@ describe Projects::MergeRequestsController do
describe "#show" do
shared_examples "export merge as" do |format|
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
end
......@@ -22,11 +22,11 @@ describe Projects::MergeRequestsController do
it "should generate it" do
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
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)
end
......@@ -34,7 +34,7 @@ describe Projects::MergeRequestsController do
it "should not escape Html" do
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('&gt;')
......@@ -48,7 +48,7 @@ describe Projects::MergeRequestsController do
let(:format) { :diff }
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")
end
......@@ -59,13 +59,13 @@ describe Projects::MergeRequestsController do
let(:format) { :patch }
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}")
end
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/)
end
......
......@@ -18,7 +18,7 @@ describe Projects::TreeController do
# Make sure any errors accessing the tree in our views bubble up to this spec
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
let(:id) { 'master' }
......
......@@ -28,6 +28,7 @@ FactoryGirl.define do
factory :project do
sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') }
namespace
creator
trait :source do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe "Issues Feed" do
describe "GET /issues" do
let!(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace) }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) }
before { project.team << [user, :developer] }
......
......@@ -58,11 +58,11 @@ describe Project do
let!(:project) { create(:project) }
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 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(:description).is_within(0..2000) }
it { should validate_presence_of(:creator) }
......@@ -157,15 +157,6 @@ describe Project do
it { Project.find_with_namespace('gitlab/gitlab-ci').should == @project }
it { Project.find_with_namespace('gitlab-ci').should be_nil }
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
describe :to_param do
......@@ -177,14 +168,6 @@ describe Project do
it { @project.to_param.should == "gitlab/gitlab-ci" }
end
context 'w/o namespace' do
before do
@project = create(:project, name: 'gitlab-ci')
end
it { @project.to_param.should == "gitlab-ci" }
end
end
describe :repository do
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,11 +11,11 @@ end
# /:path Grack
describe "Mounted Apps", "routing" do
it "to API" do
get("/api").should be_routable
get("/api/issues").should be_routable
end
it "to Grack" do
get("/gitlabhq.git").should be_routable
get("/gitlab/gitlabhq.git").should be_routable
end
end
......
......@@ -48,7 +48,7 @@ describe GitPushService do
it { should include(id: @commit.id) }
it { should include(message: @commit.safe_message) }
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
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