diff --git a/config/routes.rb b/config/routes.rb index d0e29a5ab96..2b444c2a296 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 5baf4e757ac..bde32128b92 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -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] diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb index 45dda6ff55e..71f29121179 100644 --- a/features/steps/group/group.rb +++ b/features/steps/group/group.rb @@ -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] diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/project_network_graph.rb index 57015f76626..127adecf7ed 100644 --- a/features/steps/project/project_network_graph.rb +++ b/features/steps/project/project_network_graph.rb @@ -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 diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index d690f1d07e7..4a521c3daeb 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -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? diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index 05d16f35545..479d8fc1a1d 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -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' } diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index 893d0fe089a..fdf0884f4e2 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -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('&') expect(response.body).to_not include('>') @@ -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 diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb index facae17a0ad..8263afc97a2 100644 --- a/spec/controllers/commits_controller_spec.rb +++ b/spec/controllers/commits_controller_spec.rb @@ -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 diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb index 3c1a9cb7268..69708edd8b1 100644 --- a/spec/controllers/merge_requests_controller_spec.rb +++ b/spec/controllers/merge_requests_controller_spec.rb @@ -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('&') expect(response.body).to_not include('>') @@ -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 diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb index 3e41b406c4f..bb1232e6264 100644 --- a/spec/controllers/tree_controller_spec.rb +++ b/spec/controllers/tree_controller_spec.rb @@ -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' } diff --git a/spec/factories.rb b/spec/factories.rb index e657321c294..4c5e687ac3e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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 diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index 0488c1f2266..c9bbdad380f 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -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] } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 172adb5fc7a..3bac142f4e2 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 7b893c43379..fb4a7d9bc19 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -2,9 +2,10 @@ require "spec_helper" describe API::API do include ApiHelpers - + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } let(:user) { create(:user) } - let!(:project) {create(:project_with_code, creator_id: user.id) } + let!(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } before { project.team << [user, :reporters] @@ -13,14 +14,14 @@ describe API::API do describe "GET /projects/:id/merge_requests" do context "when unauthenticated" do it "should return authentication error" do - get api("/projects/#{project.id}/merge_requests") + get api("/projects/#{project.to_param}/merge_requests") response.status.should == 401 end end context "when authenticated" do it "should return an array of merge_requests" do - get api("/projects/#{project.id}/merge_requests", user) + get api("/projects/#{project.to_param}/merge_requests", user) response.status.should == 200 json_response.should be_an Array json_response.first['title'].should == merge_request.title @@ -30,13 +31,13 @@ describe API::API do describe "GET /projects/:id/merge_request/:merge_request_id" do it "should return merge_request" do - get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user) + get api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user) response.status.should == 200 json_response['title'].should == merge_request.title end it "should return a 404 error if merge_request_id not found" do - get api("/projects/#{project.id}/merge_request/999", user) + get api("/projects/#{project.to_param}/merge_request/999", user) response.status.should == 404 end end @@ -44,32 +45,32 @@ describe API::API do describe "POST /projects/:id/merge_requests" do context 'between branches projects' do it "should return merge_request" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user response.status.should == 201 json_response['title'].should == 'Test merge_request' end it "should return 422 when source_branch equals target_branch" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), title: "Test merge_request", source_branch: "master", target_branch: "master", author: user response.status.should == 422 end it "should return 400 when source_branch is missing" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), title: "Test merge_request", target_branch: "master", author: user response.status.should == 400 end it "should return 400 when target_branch is missing" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), title: "Test merge_request", source_branch: "stable", author: user response.status.should == 400 end it "should return 400 when title is missing" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), target_branch: 'master', source_branch: 'stable' response.status.should == 400 end @@ -89,54 +90,54 @@ describe API::API do end it "should return merge_request" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id response.status.should == 201 json_response['title'].should == 'Test merge_request' end it "should not return 422 when source_branch equals target_branch" do - project.id.should_not == fork_project.id + project.to_param.should_not == fork_project.to_param fork_project.forked?.should be_true fork_project.forked_from_project.should == project - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id response.status.should == 201 json_response['title'].should == 'Test merge_request' end it "should return 400 when source_branch is missing" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id response.status.should == 400 end it "should return 400 when target_branch is missing" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id response.status.should == 400 end it "should return 400 when title is missing" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id response.status.should == 400 end it "should return 400 when target_branch is specified and not a forked project" do - post api("/projects/#{project.id}/merge_requests", user), + post api("/projects/#{project.to_param}/merge_requests", user), title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id response.status.should == 400 end it "should return 400 when target_branch is specified and for a different fork" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id response.status.should == 400 end it "should return 201 when target_branch is specified and for the same project" do - post api("/projects/#{fork_project.id}/merge_requests", user2), + post api("/projects/#{fork_project.to_param}/merge_requests", user2), title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id response.status.should == 201 end @@ -145,7 +146,7 @@ describe API::API do describe "PUT /projects/:id/merge_request/:merge_request_id to close MR" do it "should return merge_request" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "close" + put api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user), state_event: "close" response.status.should == 200 json_response['state'].should == 'closed' end @@ -153,7 +154,7 @@ describe API::API do describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do it "should return merge_request" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge" + put api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user), state_event: "merge" response.status.should == 200 json_response['state'].should == 'merged' end @@ -161,19 +162,19 @@ describe API::API do describe "PUT /projects/:id/merge_request/:merge_request_id" do it "should return merge_request" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title" + put api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user), title: "New title" response.status.should == 200 json_response['title'].should == 'New title' end it "should return 422 when source_branch and target_branch are renamed the same" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), + put api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user), source_branch: "master", target_branch: "master" response.status.should == 422 end it "should return merge_request with renamed target_branch" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), target_branch: "wiki" + put api("/projects/#{project.to_param}/merge_request/#{merge_request.id}", user), target_branch: "wiki" response.status.should == 200 json_response['target_branch'].should == 'wiki' end @@ -181,18 +182,18 @@ describe API::API do describe "POST /projects/:id/merge_request/:merge_request_id/comments" do it "should return comment" do - post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user), note: "My comment" + post api("/projects/#{project.to_param}/merge_request/#{merge_request.id}/comments", user), note: "My comment" response.status.should == 201 json_response['note'].should == 'My comment' end it "should return 400 if note is missing" do - post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user) + post api("/projects/#{project.to_param}/merge_request/#{merge_request.id}/comments", user) response.status.should == 400 end it "should return 404 if note is attached to non existent merge request" do - post api("/projects/#{project.id}/merge_request/111/comments", user), note: "My comment" + post api("/projects/#{project.to_param}/merge_request/111/comments", user), note: "My comment" response.status.should == 404 end end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 5fb0f860c42..20c04e94c24 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -25,31 +25,31 @@ shared_examples "RESTful project resources" do let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] } it "to #index" do - get("/gitlabhq/#{controller}").should route_to("projects/#{controller}#index", project_id: 'gitlabhq') if actions.include?(:index) + get("/gitlab/gitlabhq/#{controller}").should route_to("projects/#{controller}#index", project_id: 'gitlab/gitlabhq') if actions.include?(:index) end it "to #create" do - post("/gitlabhq/#{controller}").should route_to("projects/#{controller}#create", project_id: 'gitlabhq') if actions.include?(:create) + post("/gitlab/gitlabhq/#{controller}").should route_to("projects/#{controller}#create", project_id: 'gitlab/gitlabhq') if actions.include?(:create) end it "to #new" do - get("/gitlabhq/#{controller}/new").should route_to("projects/#{controller}#new", project_id: 'gitlabhq') if actions.include?(:new) + get("/gitlab/gitlabhq/#{controller}/new").should route_to("projects/#{controller}#new", project_id: 'gitlab/gitlabhq') if actions.include?(:new) end it "to #edit" do - get("/gitlabhq/#{controller}/1/edit").should route_to("projects/#{controller}#edit", project_id: 'gitlabhq', id: '1') if actions.include?(:edit) + get("/gitlab/gitlabhq/#{controller}/1/edit").should route_to("projects/#{controller}#edit", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:edit) end it "to #show" do - get("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#show", project_id: 'gitlabhq', id: '1') if actions.include?(:show) + get("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#show", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:show) end it "to #update" do - put("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#update", project_id: 'gitlabhq', id: '1') if actions.include?(:update) + put("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#update", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:update) end it "to #destroy" do - delete("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#destroy", project_id: 'gitlabhq', id: '1') if actions.include?(:destroy) + delete("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#destroy", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:destroy) end end @@ -72,31 +72,31 @@ describe ProjectsController, "routing" do end it "to #fork" do - post("/gitlabhq/fork").should route_to('projects#fork', id: 'gitlabhq') + post("/gitlab/gitlabhq/fork").should route_to('projects#fork', id: 'gitlab/gitlabhq') end it "to #wall" do - get("/gitlabhq/wall").should route_to('projects/walls#show', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/wall").should route_to('projects/walls#show', project_id: 'gitlab/gitlabhq') end it "to #edit" do - get("/gitlabhq/edit").should route_to('projects#edit', id: 'gitlabhq') + get("/gitlab/gitlabhq/edit").should route_to('projects#edit', id: 'gitlab/gitlabhq') end it "to #autocomplete_sources" do - get('/gitlabhq/autocomplete_sources').should route_to('projects#autocomplete_sources', id: "gitlabhq") + get('/gitlab/gitlabhq/autocomplete_sources').should route_to('projects#autocomplete_sources', id: "gitlab/gitlabhq") end it "to #show" do - get("/gitlabhq").should route_to('projects#show', id: 'gitlabhq') + get("/gitlab/gitlabhq").should route_to('projects#show', id: 'gitlab/gitlabhq') end it "to #update" do - put("/gitlabhq").should route_to('projects#update', id: 'gitlabhq') + put("/gitlab/gitlabhq").should route_to('projects#update', id: 'gitlab/gitlabhq') end it "to #destroy" do - delete("/gitlabhq").should route_to('projects#destroy', id: 'gitlabhq') + delete("/gitlab/gitlabhq").should route_to('projects#destroy', id: 'gitlab/gitlabhq') end end @@ -108,11 +108,11 @@ end # DELETE /:project_id/wikis/:id(.:format) projects/wikis#destroy describe Projects::WikisController, "routing" do it "to #pages" do - get("/gitlabhq/wikis/pages").should route_to('projects/wikis#pages', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/wikis/pages").should route_to('projects/wikis#pages', project_id: 'gitlab/gitlabhq') end it "to #history" do - get("/gitlabhq/wikis/1/history").should route_to('projects/wikis#history', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/wikis/1/history").should route_to('projects/wikis#history', project_id: 'gitlab/gitlabhq', id: '1') end it_behaves_like "RESTful project resources" do @@ -127,23 +127,23 @@ end # edit_project_repository GET /:project_id/repository/edit(.:format) projects/repositories#edit describe Projects::RepositoriesController, "routing" do it "to #archive" do - get("/gitlabhq/repository/archive").should route_to('projects/repositories#archive', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/repository/archive").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq') end it "to #show" do - get("/gitlabhq/repository").should route_to('projects/repositories#show', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/repository").should route_to('projects/repositories#show', project_id: 'gitlab/gitlabhq') end end describe Projects::BranchesController, "routing" do it "to #branches" do - get("/gitlabhq/branches").should route_to('projects/branches#index', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/branches").should route_to('projects/branches#index', project_id: 'gitlab/gitlabhq') end end describe Projects::TagsController, "routing" do it "to #tags" do - get("/gitlabhq/tags").should route_to('projects/tags#index', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/tags").should route_to('projects/tags#index', project_id: 'gitlab/gitlabhq') end end @@ -176,16 +176,16 @@ end # logs_file_project_ref GET /:project_id/refs/:id/logs_tree/:path(.:format) refs#logs_tree describe Projects::RefsController, "routing" do it "to #switch" do - get("/gitlabhq/refs/switch").should route_to('projects/refs#switch', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/refs/switch").should route_to('projects/refs#switch', project_id: 'gitlab/gitlabhq') end it "to #logs_tree" do - get("/gitlabhq/refs/stable/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'stable') - get("/gitlabhq/refs/feature%2345/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45') - get("/gitlabhq/refs/feature%2B45/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45') - get("/gitlabhq/refs/stable/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - get("/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') - get("/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') + get("/gitlab/gitlabhq/refs/stable/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable') + get("/gitlab/gitlabhq/refs/feature%2345/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45') + get("/gitlab/gitlabhq/refs/feature%2B45/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45') + get("/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'foo/bar/baz') + get("/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45', path: 'foo/bar/baz') + get("/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45', path: 'foo/bar/baz') get("/gitlab/gitlabhq/refs/stable/logs_tree/files.scss").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'files.scss') end end @@ -204,28 +204,28 @@ end # DELETE /:project_id/merge_requests/:id(.:format) projects/merge_requests#destroy describe Projects::MergeRequestsController, "routing" do it "to #diffs" do - get("/gitlabhq/merge_requests/1/diffs").should route_to('projects/merge_requests#diffs', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/merge_requests/1/diffs").should route_to('projects/merge_requests#diffs', project_id: 'gitlab/gitlabhq', id: '1') end it "to #automerge" do - get("/gitlabhq/merge_requests/1/automerge").should route_to('projects/merge_requests#automerge', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/merge_requests/1/automerge").should route_to('projects/merge_requests#automerge', project_id: 'gitlab/gitlabhq', id: '1') end it "to #automerge_check" do - get("/gitlabhq/merge_requests/1/automerge_check").should route_to('projects/merge_requests#automerge_check', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/merge_requests/1/automerge_check").should route_to('projects/merge_requests#automerge_check', project_id: 'gitlab/gitlabhq', id: '1') end it "to #branch_from" do - get("/gitlabhq/merge_requests/branch_from").should route_to('projects/merge_requests#branch_from', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/merge_requests/branch_from").should route_to('projects/merge_requests#branch_from', project_id: 'gitlab/gitlabhq') end it "to #branch_to" do - get("/gitlabhq/merge_requests/branch_to").should route_to('projects/merge_requests#branch_to', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/merge_requests/branch_to").should route_to('projects/merge_requests#branch_to', project_id: 'gitlab/gitlabhq') end it "to #show" do - get("/gitlabhq/merge_requests/1.diff").should route_to('projects/merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'diff') - get("/gitlabhq/merge_requests/1.patch").should route_to('projects/merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'patch') + get("/gitlab/gitlabhq/merge_requests/1.diff").should route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'diff') + get("/gitlab/gitlabhq/merge_requests/1.patch").should route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'patch') end it_behaves_like "RESTful project resources" do @@ -244,35 +244,35 @@ end # DELETE /:project_id/snippets/:id(.:format) snippets#destroy describe SnippetsController, "routing" do it "to #raw" do - get("/gitlabhq/snippets/1/raw").should route_to('projects/snippets#raw', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/snippets/1/raw").should route_to('projects/snippets#raw', project_id: 'gitlab/gitlabhq', id: '1') end it "to #index" do - get("/gitlabhq/snippets").should route_to("projects/snippets#index", project_id: 'gitlabhq') + get("/gitlab/gitlabhq/snippets").should route_to("projects/snippets#index", project_id: 'gitlab/gitlabhq') end it "to #create" do - post("/gitlabhq/snippets").should route_to("projects/snippets#create", project_id: 'gitlabhq') + post("/gitlab/gitlabhq/snippets").should route_to("projects/snippets#create", project_id: 'gitlab/gitlabhq') end it "to #new" do - get("/gitlabhq/snippets/new").should route_to("projects/snippets#new", project_id: 'gitlabhq') + get("/gitlab/gitlabhq/snippets/new").should route_to("projects/snippets#new", project_id: 'gitlab/gitlabhq') end it "to #edit" do - get("/gitlabhq/snippets/1/edit").should route_to("projects/snippets#edit", project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/snippets/1/edit").should route_to("projects/snippets#edit", project_id: 'gitlab/gitlabhq', id: '1') end it "to #show" do - get("/gitlabhq/snippets/1").should route_to("projects/snippets#show", project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/snippets/1").should route_to("projects/snippets#show", project_id: 'gitlab/gitlabhq', id: '1') end it "to #update" do - put("/gitlabhq/snippets/1").should route_to("projects/snippets#update", project_id: 'gitlabhq', id: '1') + put("/gitlab/gitlabhq/snippets/1").should route_to("projects/snippets#update", project_id: 'gitlab/gitlabhq', id: '1') end it "to #destroy" do - delete("/gitlabhq/snippets/1").should route_to("projects/snippets#destroy", project_id: 'gitlabhq', id: '1') + delete("/gitlab/gitlabhq/snippets/1").should route_to("projects/snippets#destroy", project_id: 'gitlab/gitlabhq', id: '1') end end @@ -282,7 +282,7 @@ end # project_hook DELETE /:project_id/hooks/:id(.:format) hooks#destroy describe Projects::HooksController, "routing" do it "to #test" do - get("/gitlabhq/hooks/1/test").should route_to('projects/hooks#test', project_id: 'gitlabhq', id: '1') + get("/gitlab/gitlabhq/hooks/1/test").should route_to('projects/hooks#test', project_id: 'gitlab/gitlabhq', id: '1') end it_behaves_like "RESTful project resources" do @@ -294,10 +294,10 @@ end # project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /[[:alnum:]]{6,40}/, project_id: /[^\/]+/} describe Projects::CommitController, "routing" do it "to #show" do - get("/gitlabhq/commit/4246fb").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb') - get("/gitlabhq/commit/4246fb.diff").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'diff') - get("/gitlabhq/commit/4246fb.patch").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'patch') - get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') + get("/gitlab/gitlabhq/commit/4246fb").should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb') + get("/gitlab/gitlabhq/commit/4246fb.diff").should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'diff') + get("/gitlab/gitlabhq/commit/4246fb.patch").should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'patch') + get("/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') end end @@ -347,7 +347,7 @@ end # project_labels GET /:project_id/labels(.:format) labels#index describe Projects::LabelsController, "routing" do it "to #index" do - get("/gitlabhq/labels").should route_to('projects/labels#index', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/labels").should route_to('projects/labels#index', project_id: 'gitlab/gitlabhq') end end @@ -363,7 +363,7 @@ end # DELETE /:project_id/issues/:id(.:format) issues#destroy describe Projects::IssuesController, "routing" do it "to #bulk_update" do - post("/gitlabhq/issues/bulk_update").should route_to('projects/issues#bulk_update', project_id: 'gitlabhq') + post("/gitlab/gitlabhq/issues/bulk_update").should route_to('projects/issues#bulk_update', project_id: 'gitlab/gitlabhq') end it_behaves_like "RESTful project resources" do @@ -378,7 +378,7 @@ end # project_note DELETE /:project_id/notes/:id(.:format) notes#destroy describe Projects::NotesController, "routing" do it "to #preview" do - post("/gitlabhq/notes/preview").should route_to('projects/notes#preview', project_id: 'gitlabhq') + post("/gitlab/gitlabhq/notes/preview").should route_to('projects/notes#preview', project_id: 'gitlab/gitlabhq') end it_behaves_like "RESTful project resources" do @@ -390,7 +390,7 @@ end # project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/} describe Projects::BlameController, "routing" do it "to #show" do - get("/gitlabhq/blame/master/app/models/project.rb").should route_to('projects/blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + get("/gitlab/gitlabhq/blame/master/app/models/project.rb").should route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb') get("/gitlab/gitlabhq/blame/master/files.scss").should route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end @@ -398,8 +398,8 @@ end # project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/} describe Projects::BlobController, "routing" do it "to #show" do - get("/gitlabhq/blob/master/app/models/project.rb").should route_to('projects/blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - get("/gitlabhq/blob/master/app/models/compare.rb").should route_to('projects/blob#show', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') + get("/gitlab/gitlabhq/blob/master/app/models/project.rb").should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb') + get("/gitlab/gitlabhq/blob/master/app/models/compare.rb").should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/compare.rb') get("/gitlab/gitlabhq/blob/master/files.scss").should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end @@ -407,7 +407,7 @@ end # project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/} describe Projects::TreeController, "routing" do it "to #show" do - get("/gitlabhq/tree/master/app/models/project.rb").should route_to('projects/tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + get("/gitlab/gitlabhq/tree/master/app/models/project.rb").should route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb') get("/gitlab/gitlabhq/tree/master/files.scss").should route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end @@ -417,28 +417,28 @@ end # project_compare /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/} describe Projects::CompareController, "routing" do it "to #index" do - get("/gitlabhq/compare").should route_to('projects/compare#index', project_id: 'gitlabhq') + get("/gitlab/gitlabhq/compare").should route_to('projects/compare#index', project_id: 'gitlab/gitlabhq') end it "to #compare" do - post("/gitlabhq/compare").should route_to('projects/compare#create', project_id: 'gitlabhq') + post("/gitlab/gitlabhq/compare").should route_to('projects/compare#create', project_id: 'gitlab/gitlabhq') end it "to #show" do - get("/gitlabhq/compare/master...stable").should route_to('projects/compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') - get("/gitlabhq/compare/issue/1234...stable").should route_to('projects/compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') + get("/gitlab/gitlabhq/compare/master...stable").should route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'master', to: 'stable') + get("/gitlab/gitlabhq/compare/issue/1234...stable").should route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'issue/1234', to: 'stable') end end describe Projects::NetworkController, "routing" do it "to #show" do - get("/gitlabhq/network/master").should route_to('projects/network#show', project_id: 'gitlabhq', id: 'master') - get("/gitlabhq/network/master.json").should route_to('projects/network#show', project_id: 'gitlabhq', id: 'master', format: "json") + get("/gitlab/gitlabhq/network/master").should route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master') + get("/gitlab/gitlabhq/network/master.json").should route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master', format: "json") end end describe Projects::GraphsController, "routing" do it "to #show" do - get("/gitlabhq/graphs/master").should route_to('projects/graphs#show', project_id: 'gitlabhq', id: 'master') + get("/gitlab/gitlabhq/graphs/master").should route_to('projects/graphs#show', project_id: 'gitlab/gitlabhq', id: 'master') end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index cc2a141c454..946ef7c28cb 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -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 diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 1f6ee818a42..e3c25fa0469 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -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] }