Commit 9304d049de0493de457fdec02114d5a23d116f9b
1 parent
470aa767
Exists in
master
and in
4 other branches
Fixed some tests and snippet colorize
Showing
13 changed files
with
64 additions
and
68 deletions
Show diff stats
app/controllers/admin/groups_controller.rb
| @@ -74,6 +74,6 @@ class Admin::GroupsController < AdminController | @@ -74,6 +74,6 @@ class Admin::GroupsController < AdminController | ||
| 74 | private | 74 | private |
| 75 | 75 | ||
| 76 | def group | 76 | def group |
| 77 | - @group = Group.find_by_code(params[:id]) | 77 | + @group = Group.find_by_path(params[:id]) |
| 78 | end | 78 | end |
| 79 | end | 79 | end |
app/controllers/groups_controller.rb
| @@ -50,7 +50,7 @@ class GroupsController < ApplicationController | @@ -50,7 +50,7 @@ class GroupsController < ApplicationController | ||
| 50 | protected | 50 | protected |
| 51 | 51 | ||
| 52 | def group | 52 | def group |
| 53 | - @group ||= Group.find_by_code(params[:id]) | 53 | + @group ||= Group.find_by_path(params[:id]) |
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | def projects | 56 | def projects |
app/models/project.rb
| @@ -86,7 +86,7 @@ class Project < ActiveRecord::Base | @@ -86,7 +86,7 @@ class Project < ActiveRecord::Base | ||
| 86 | 86 | ||
| 87 | def create_by_user(params, user) | 87 | def create_by_user(params, user) |
| 88 | namespace_id = params.delete(:namespace_id) | 88 | namespace_id = params.delete(:namespace_id) |
| 89 | - namespace_id ||= user.namespace_id | 89 | + namespace_id ||= user.namespace.try(:id) |
| 90 | 90 | ||
| 91 | project = Project.new params | 91 | project = Project.new params |
| 92 | 92 | ||
| @@ -222,6 +222,8 @@ class Project < ActiveRecord::Base | @@ -222,6 +222,8 @@ class Project < ActiveRecord::Base | ||
| 222 | end | 222 | end |
| 223 | end | 223 | end |
| 224 | 224 | ||
| 225 | - def move_repo | 225 | + # For compatibility with old code |
| 226 | + def code | ||
| 227 | + path | ||
| 226 | end | 228 | end |
| 227 | end | 229 | end |
app/views/snippets/show.html.haml
| @@ -15,8 +15,12 @@ | @@ -15,8 +15,12 @@ | ||
| 15 | %span.options | 15 | %span.options |
| 16 | = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank" | 16 | = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank" |
| 17 | .file_content.code | 17 | .file_content.code |
| 18 | - %div{class: current_user.dark_scheme ? "black" : ""} | ||
| 19 | - = raw @snippet.colorize(options: { linenos: 'True'}) | 18 | + - unless @snippet.content.empty? |
| 19 | + %div{class: current_user.dark_scheme ? "black" : "white"} | ||
| 20 | + = preserve do | ||
| 21 | + = raw Pygments.highlight(@snippet.content, formatter: :gitlab) | ||
| 22 | + - else | ||
| 23 | + %h4.nothing_here_message Empty file | ||
| 20 | 24 | ||
| 21 | 25 | ||
| 22 | %div | 26 | %div |
features/steps/admin/admin_groups.rb
| @@ -9,7 +9,7 @@ class AdminGroups < Spinach::FeatureSteps | @@ -9,7 +9,7 @@ class AdminGroups < Spinach::FeatureSteps | ||
| 9 | 9 | ||
| 10 | And 'submit form with new group info' do | 10 | And 'submit form with new group info' do |
| 11 | fill_in 'group_name', :with => 'gitlab' | 11 | fill_in 'group_name', :with => 'gitlab' |
| 12 | - fill_in 'group_code', :with => 'gitlab' | 12 | + fill_in 'group_path', :with => 'gitlab' |
| 13 | click_button "Save group" | 13 | click_button "Save group" |
| 14 | end | 14 | end |
| 15 | 15 |
features/steps/project/create_project.rb
| @@ -4,8 +4,6 @@ class CreateProject < Spinach::FeatureSteps | @@ -4,8 +4,6 @@ class CreateProject < Spinach::FeatureSteps | ||
| 4 | 4 | ||
| 5 | And 'fill project form with valid data' do | 5 | And 'fill project form with valid data' do |
| 6 | fill_in 'project_name', :with => 'NewProject' | 6 | fill_in 'project_name', :with => 'NewProject' |
| 7 | - fill_in 'project_code', :with => 'NPR' | ||
| 8 | - fill_in 'project_path', :with => 'newproject' | ||
| 9 | click_button "Create project" | 7 | click_button "Create project" |
| 10 | end | 8 | end |
| 11 | 9 |
lib/api/projects.rb
| @@ -40,8 +40,7 @@ module Gitlab | @@ -40,8 +40,7 @@ module Gitlab | ||
| 40 | post do | 40 | post do |
| 41 | params[:code] ||= params[:name] | 41 | params[:code] ||= params[:name] |
| 42 | params[:path] ||= params[:name] | 42 | params[:path] ||= params[:name] |
| 43 | - attrs = attributes_for_keys [:code, | ||
| 44 | - :path, | 43 | + attrs = attributes_for_keys [:path, |
| 45 | :name, | 44 | :name, |
| 46 | :description, | 45 | :description, |
| 47 | :default_branch, | 46 | :default_branch, |
spec/requests/admin/admin_projects_spec.rb
| @@ -2,9 +2,7 @@ require 'spec_helper' | @@ -2,9 +2,7 @@ require 'spec_helper' | ||
| 2 | 2 | ||
| 3 | describe "Admin::Projects" do | 3 | describe "Admin::Projects" do |
| 4 | before do | 4 | before do |
| 5 | - @project = create(:project, | ||
| 6 | - name: "LeGiT", | ||
| 7 | - code: "LGT") | 5 | + @project = create(:project) |
| 8 | login_as :admin | 6 | login_as :admin |
| 9 | end | 7 | end |
| 10 | 8 | ||
| @@ -29,7 +27,7 @@ describe "Admin::Projects" do | @@ -29,7 +27,7 @@ describe "Admin::Projects" do | ||
| 29 | end | 27 | end |
| 30 | 28 | ||
| 31 | it "should have project info" do | 29 | it "should have project info" do |
| 32 | - page.should have_content(@project.code) | 30 | + page.should have_content(@project.path) |
| 33 | page.should have_content(@project.name) | 31 | page.should have_content(@project.name) |
| 34 | end | 32 | end |
| 35 | end | 33 | end |
| @@ -48,19 +46,16 @@ describe "Admin::Projects" do | @@ -48,19 +46,16 @@ describe "Admin::Projects" do | ||
| 48 | describe "Update project" do | 46 | describe "Update project" do |
| 49 | before do | 47 | before do |
| 50 | fill_in "project_name", with: "Big Bang" | 48 | fill_in "project_name", with: "Big Bang" |
| 51 | - fill_in "project_code", with: "BB1" | ||
| 52 | click_button "Save Project" | 49 | click_button "Save Project" |
| 53 | @project.reload | 50 | @project.reload |
| 54 | end | 51 | end |
| 55 | 52 | ||
| 56 | it "should show page with new data" do | 53 | it "should show page with new data" do |
| 57 | - page.should have_content("BB1") | ||
| 58 | page.should have_content("Big Bang") | 54 | page.should have_content("Big Bang") |
| 59 | end | 55 | end |
| 60 | 56 | ||
| 61 | it "should change project entry" do | 57 | it "should change project entry" do |
| 62 | @project.name.should == "Big Bang" | 58 | @project.name.should == "Big Bang" |
| 63 | - @project.code.should == "BB1" | ||
| 64 | end | 59 | end |
| 65 | end | 60 | end |
| 66 | end | 61 | end |
| @@ -77,8 +72,6 @@ describe "Admin::Projects" do | @@ -77,8 +72,6 @@ describe "Admin::Projects" do | ||
| 77 | 72 | ||
| 78 | it "should have labels for new project" do | 73 | it "should have labels for new project" do |
| 79 | page.should have_content("Project name is") | 74 | page.should have_content("Project name is") |
| 80 | - page.should have_content("Git Clone") | ||
| 81 | - page.should have_content("URL") | ||
| 82 | end | 75 | end |
| 83 | end | 76 | end |
| 84 | 77 | ||
| @@ -86,8 +79,6 @@ describe "Admin::Projects" do | @@ -86,8 +79,6 @@ describe "Admin::Projects" do | ||
| 86 | before do | 79 | before do |
| 87 | visit new_admin_project_path | 80 | visit new_admin_project_path |
| 88 | fill_in 'project_name', with: 'NewProject' | 81 | fill_in 'project_name', with: 'NewProject' |
| 89 | - fill_in 'project_code', with: 'NPR' | ||
| 90 | - fill_in 'project_path', with: 'gitlabhq_1' | ||
| 91 | expect { click_button "Create project" }.to change { Project.count }.by(1) | 82 | expect { click_button "Create project" }.to change { Project.count }.by(1) |
| 92 | @project = Project.last | 83 | @project = Project.last |
| 93 | end | 84 | end |
spec/requests/api/issues_spec.rb
| @@ -28,7 +28,7 @@ describe Gitlab::API do | @@ -28,7 +28,7 @@ describe Gitlab::API do | ||
| 28 | 28 | ||
| 29 | describe "GET /projects/:id/issues" do | 29 | describe "GET /projects/:id/issues" do |
| 30 | it "should return project issues" do | 30 | it "should return project issues" do |
| 31 | - get api("/projects/#{project.code}/issues", user) | 31 | + get api("/projects/#{project.path}/issues", user) |
| 32 | response.status.should == 200 | 32 | response.status.should == 200 |
| 33 | json_response.should be_an Array | 33 | json_response.should be_an Array |
| 34 | json_response.first['title'].should == issue.title | 34 | json_response.first['title'].should == issue.title |
| @@ -37,7 +37,7 @@ describe Gitlab::API do | @@ -37,7 +37,7 @@ describe Gitlab::API do | ||
| 37 | 37 | ||
| 38 | describe "GET /projects/:id/issues/:issue_id" do | 38 | describe "GET /projects/:id/issues/:issue_id" do |
| 39 | it "should return a project issue by id" do | 39 | it "should return a project issue by id" do |
| 40 | - get api("/projects/#{project.code}/issues/#{issue.id}", user) | 40 | + get api("/projects/#{project.path}/issues/#{issue.id}", user) |
| 41 | response.status.should == 200 | 41 | response.status.should == 200 |
| 42 | json_response['title'].should == issue.title | 42 | json_response['title'].should == issue.title |
| 43 | end | 43 | end |
| @@ -45,7 +45,7 @@ describe Gitlab::API do | @@ -45,7 +45,7 @@ describe Gitlab::API do | ||
| 45 | 45 | ||
| 46 | describe "POST /projects/:id/issues" do | 46 | describe "POST /projects/:id/issues" do |
| 47 | it "should create a new project issue" do | 47 | it "should create a new project issue" do |
| 48 | - post api("/projects/#{project.code}/issues", user), | 48 | + post api("/projects/#{project.path}/issues", user), |
| 49 | title: 'new issue', labels: 'label, label2' | 49 | title: 'new issue', labels: 'label, label2' |
| 50 | response.status.should == 201 | 50 | response.status.should == 201 |
| 51 | json_response['title'].should == 'new issue' | 51 | json_response['title'].should == 'new issue' |
| @@ -56,7 +56,7 @@ describe Gitlab::API do | @@ -56,7 +56,7 @@ describe Gitlab::API do | ||
| 56 | 56 | ||
| 57 | describe "PUT /projects/:id/issues/:issue_id" do | 57 | describe "PUT /projects/:id/issues/:issue_id" do |
| 58 | it "should update a project issue" do | 58 | it "should update a project issue" do |
| 59 | - put api("/projects/#{project.code}/issues/#{issue.id}", user), | 59 | + put api("/projects/#{project.path}/issues/#{issue.id}", user), |
| 60 | title: 'updated title', labels: 'label2', closed: 1 | 60 | title: 'updated title', labels: 'label2', closed: 1 |
| 61 | response.status.should == 200 | 61 | response.status.should == 200 |
| 62 | json_response['title'].should == 'updated title' | 62 | json_response['title'].should == 'updated title' |
| @@ -67,7 +67,7 @@ describe Gitlab::API do | @@ -67,7 +67,7 @@ describe Gitlab::API do | ||
| 67 | 67 | ||
| 68 | describe "DELETE /projects/:id/issues/:issue_id" do | 68 | describe "DELETE /projects/:id/issues/:issue_id" do |
| 69 | it "should delete a project issue" do | 69 | it "should delete a project issue" do |
| 70 | - delete api("/projects/#{project.code}/issues/#{issue.id}", user) | 70 | + delete api("/projects/#{project.path}/issues/#{issue.id}", user) |
| 71 | response.status.should == 405 | 71 | response.status.should == 405 |
| 72 | end | 72 | end |
| 73 | end | 73 | end |
spec/requests/api/merge_requests_spec.rb
| @@ -11,14 +11,14 @@ describe Gitlab::API do | @@ -11,14 +11,14 @@ describe Gitlab::API do | ||
| 11 | describe "GET /projects/:id/merge_requests" do | 11 | describe "GET /projects/:id/merge_requests" do |
| 12 | context "when unauthenticated" do | 12 | context "when unauthenticated" do |
| 13 | it "should return authentication error" do | 13 | it "should return authentication error" do |
| 14 | - get api("/projects/#{project.code}/merge_requests") | 14 | + get api("/projects/#{project.path}/merge_requests") |
| 15 | response.status.should == 401 | 15 | response.status.should == 401 |
| 16 | end | 16 | end |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | context "when authenticated" do | 19 | context "when authenticated" do |
| 20 | it "should return an array of merge_requests" do | 20 | it "should return an array of merge_requests" do |
| 21 | - get api("/projects/#{project.code}/merge_requests", user) | 21 | + get api("/projects/#{project.path}/merge_requests", user) |
| 22 | response.status.should == 200 | 22 | response.status.should == 200 |
| 23 | json_response.should be_an Array | 23 | json_response.should be_an Array |
| 24 | json_response.first['title'].should == merge_request.title | 24 | json_response.first['title'].should == merge_request.title |
| @@ -28,7 +28,7 @@ describe Gitlab::API do | @@ -28,7 +28,7 @@ describe Gitlab::API do | ||
| 28 | 28 | ||
| 29 | describe "GET /projects/:id/merge_request/:merge_request_id" do | 29 | describe "GET /projects/:id/merge_request/:merge_request_id" do |
| 30 | it "should return merge_request" do | 30 | it "should return merge_request" do |
| 31 | - get api("/projects/#{project.code}/merge_request/#{merge_request.id}", user) | 31 | + get api("/projects/#{project.path}/merge_request/#{merge_request.id}", user) |
| 32 | response.status.should == 200 | 32 | response.status.should == 200 |
| 33 | json_response['title'].should == merge_request.title | 33 | json_response['title'].should == merge_request.title |
| 34 | end | 34 | end |
| @@ -36,7 +36,7 @@ describe Gitlab::API do | @@ -36,7 +36,7 @@ describe Gitlab::API do | ||
| 36 | 36 | ||
| 37 | describe "POST /projects/:id/merge_requests" do | 37 | describe "POST /projects/:id/merge_requests" do |
| 38 | it "should return merge_request" do | 38 | it "should return merge_request" do |
| 39 | - post api("/projects/#{project.code}/merge_requests", user), | 39 | + post api("/projects/#{project.path}/merge_requests", user), |
| 40 | title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user | 40 | title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user |
| 41 | response.status.should == 201 | 41 | response.status.should == 201 |
| 42 | json_response['title'].should == 'Test merge_request' | 42 | json_response['title'].should == 'Test merge_request' |
| @@ -45,7 +45,7 @@ describe Gitlab::API do | @@ -45,7 +45,7 @@ describe Gitlab::API do | ||
| 45 | 45 | ||
| 46 | describe "PUT /projects/:id/merge_request/:merge_request_id" do | 46 | describe "PUT /projects/:id/merge_request/:merge_request_id" do |
| 47 | it "should return merge_request" do | 47 | it "should return merge_request" do |
| 48 | - put api("/projects/#{project.code}/merge_request/#{merge_request.id}", user), title: "New title" | 48 | + put api("/projects/#{project.path}/merge_request/#{merge_request.id}", user), title: "New title" |
| 49 | response.status.should == 200 | 49 | response.status.should == 200 |
| 50 | json_response['title'].should == 'New title' | 50 | json_response['title'].should == 'New title' |
| 51 | end | 51 | end |
| @@ -53,7 +53,7 @@ describe Gitlab::API do | @@ -53,7 +53,7 @@ describe Gitlab::API do | ||
| 53 | 53 | ||
| 54 | describe "POST /projects/:id/merge_request/:merge_request_id/comments" do | 54 | describe "POST /projects/:id/merge_request/:merge_request_id/comments" do |
| 55 | it "should return comment" do | 55 | it "should return comment" do |
| 56 | - post api("/projects/#{project.code}/merge_request/#{merge_request.id}/comments", user), note: "My comment" | 56 | + post api("/projects/#{project.path}/merge_request/#{merge_request.id}/comments", user), note: "My comment" |
| 57 | response.status.should == 201 | 57 | response.status.should == 201 |
| 58 | json_response['note'].should == 'My comment' | 58 | json_response['note'].should == 'My comment' |
| 59 | end | 59 | end |
spec/requests/api/projects_spec.rb
| @@ -33,7 +33,7 @@ describe Gitlab::API do | @@ -33,7 +33,7 @@ describe Gitlab::API do | ||
| 33 | end | 33 | end |
| 34 | 34 | ||
| 35 | describe "POST /projects" do | 35 | describe "POST /projects" do |
| 36 | - it "should create new project without code and path" do | 36 | + it "should create new project without path" do |
| 37 | expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1) | 37 | expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1) |
| 38 | end | 38 | end |
| 39 | 39 | ||
| @@ -53,8 +53,7 @@ describe Gitlab::API do | @@ -53,8 +53,7 @@ describe Gitlab::API do | ||
| 53 | 53 | ||
| 54 | it "should assign attributes to project" do | 54 | it "should assign attributes to project" do |
| 55 | project = attributes_for(:project, { | 55 | project = attributes_for(:project, { |
| 56 | - path: 'path', | ||
| 57 | - code: 'code', | 56 | + path: project.name.parameterize, |
| 58 | description: Faker::Lorem.sentence, | 57 | description: Faker::Lorem.sentence, |
| 59 | default_branch: 'stable', | 58 | default_branch: 'stable', |
| 60 | issues_enabled: false, | 59 | issues_enabled: false, |
| @@ -79,8 +78,8 @@ describe Gitlab::API do | @@ -79,8 +78,8 @@ describe Gitlab::API do | ||
| 79 | json_response['owner']['email'].should == user.email | 78 | json_response['owner']['email'].should == user.email |
| 80 | end | 79 | end |
| 81 | 80 | ||
| 82 | - it "should return a project by code name" do | ||
| 83 | - get api("/projects/#{project.code}", user) | 81 | + it "should return a project by path name" do |
| 82 | + get api("/projects/#{project.path}", user) | ||
| 84 | response.status.should == 200 | 83 | response.status.should == 200 |
| 85 | json_response['name'].should == project.name | 84 | json_response['name'].should == project.name |
| 86 | end | 85 | end |
| @@ -94,7 +93,7 @@ describe Gitlab::API do | @@ -94,7 +93,7 @@ describe Gitlab::API do | ||
| 94 | 93 | ||
| 95 | describe "GET /projects/:id/repository/branches" do | 94 | describe "GET /projects/:id/repository/branches" do |
| 96 | it "should return an array of project branches" do | 95 | it "should return an array of project branches" do |
| 97 | - get api("/projects/#{project.code}/repository/branches", user) | 96 | + get api("/projects/#{project.path}/repository/branches", user) |
| 98 | response.status.should == 200 | 97 | response.status.should == 200 |
| 99 | json_response.should be_an Array | 98 | json_response.should be_an Array |
| 100 | json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name | 99 | json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name |
| @@ -103,7 +102,7 @@ describe Gitlab::API do | @@ -103,7 +102,7 @@ describe Gitlab::API do | ||
| 103 | 102 | ||
| 104 | describe "GET /projects/:id/repository/branches/:branch" do | 103 | describe "GET /projects/:id/repository/branches/:branch" do |
| 105 | it "should return the branch information for a single branch" do | 104 | it "should return the branch information for a single branch" do |
| 106 | - get api("/projects/#{project.code}/repository/branches/new_design", user) | 105 | + get api("/projects/#{project.path}/repository/branches/new_design", user) |
| 107 | response.status.should == 200 | 106 | response.status.should == 200 |
| 108 | 107 | ||
| 109 | json_response['name'].should == 'new_design' | 108 | json_response['name'].should == 'new_design' |
| @@ -113,7 +112,7 @@ describe Gitlab::API do | @@ -113,7 +112,7 @@ describe Gitlab::API do | ||
| 113 | 112 | ||
| 114 | describe "GET /projects/:id/members" do | 113 | describe "GET /projects/:id/members" do |
| 115 | it "should return project team members" do | 114 | it "should return project team members" do |
| 116 | - get api("/projects/#{project.code}/members", user) | 115 | + get api("/projects/#{project.path}/members", user) |
| 117 | response.status.should == 200 | 116 | response.status.should == 200 |
| 118 | json_response.should be_an Array | 117 | json_response.should be_an Array |
| 119 | json_response.count.should == 2 | 118 | json_response.count.should == 2 |
| @@ -123,7 +122,7 @@ describe Gitlab::API do | @@ -123,7 +122,7 @@ describe Gitlab::API do | ||
| 123 | 122 | ||
| 124 | describe "GET /projects/:id/members/:user_id" do | 123 | describe "GET /projects/:id/members/:user_id" do |
| 125 | it "should return project team member" do | 124 | it "should return project team member" do |
| 126 | - get api("/projects/#{project.code}/members/#{user.id}", user) | 125 | + get api("/projects/#{project.path}/members/#{user.id}", user) |
| 127 | response.status.should == 200 | 126 | response.status.should == 200 |
| 128 | json_response['email'].should == user.email | 127 | json_response['email'].should == user.email |
| 129 | json_response['access_level'].should == UsersProject::MASTER | 128 | json_response['access_level'].should == UsersProject::MASTER |
| @@ -133,7 +132,7 @@ describe Gitlab::API do | @@ -133,7 +132,7 @@ describe Gitlab::API do | ||
| 133 | describe "POST /projects/:id/members" do | 132 | describe "POST /projects/:id/members" do |
| 134 | it "should add user to project team" do | 133 | it "should add user to project team" do |
| 135 | expect { | 134 | expect { |
| 136 | - post api("/projects/#{project.code}/members", user), user_id: user2.id, | 135 | + post api("/projects/#{project.path}/members", user), user_id: user2.id, |
| 137 | access_level: UsersProject::DEVELOPER | 136 | access_level: UsersProject::DEVELOPER |
| 138 | }.to change { UsersProject.count }.by(1) | 137 | }.to change { UsersProject.count }.by(1) |
| 139 | 138 | ||
| @@ -145,7 +144,7 @@ describe Gitlab::API do | @@ -145,7 +144,7 @@ describe Gitlab::API do | ||
| 145 | 144 | ||
| 146 | describe "PUT /projects/:id/members/:user_id" do | 145 | describe "PUT /projects/:id/members/:user_id" do |
| 147 | it "should update project team member" do | 146 | it "should update project team member" do |
| 148 | - put api("/projects/#{project.code}/members/#{user3.id}", user), access_level: UsersProject::MASTER | 147 | + put api("/projects/#{project.path}/members/#{user3.id}", user), access_level: UsersProject::MASTER |
| 149 | response.status.should == 200 | 148 | response.status.should == 200 |
| 150 | json_response['email'].should == user3.email | 149 | json_response['email'].should == user3.email |
| 151 | json_response['access_level'].should == UsersProject::MASTER | 150 | json_response['access_level'].should == UsersProject::MASTER |
| @@ -155,14 +154,14 @@ describe Gitlab::API do | @@ -155,14 +154,14 @@ describe Gitlab::API do | ||
| 155 | describe "DELETE /projects/:id/members/:user_id" do | 154 | describe "DELETE /projects/:id/members/:user_id" do |
| 156 | it "should remove user from project team" do | 155 | it "should remove user from project team" do |
| 157 | expect { | 156 | expect { |
| 158 | - delete api("/projects/#{project.code}/members/#{user3.id}", user) | 157 | + delete api("/projects/#{project.path}/members/#{user3.id}", user) |
| 159 | }.to change { UsersProject.count }.by(-1) | 158 | }.to change { UsersProject.count }.by(-1) |
| 160 | end | 159 | end |
| 161 | end | 160 | end |
| 162 | 161 | ||
| 163 | describe "GET /projects/:id/hooks" do | 162 | describe "GET /projects/:id/hooks" do |
| 164 | it "should return project hooks" do | 163 | it "should return project hooks" do |
| 165 | - get api("/projects/#{project.code}/hooks", user) | 164 | + get api("/projects/#{project.path}/hooks", user) |
| 166 | 165 | ||
| 167 | response.status.should == 200 | 166 | response.status.should == 200 |
| 168 | 167 | ||
| @@ -174,7 +173,7 @@ describe Gitlab::API do | @@ -174,7 +173,7 @@ describe Gitlab::API do | ||
| 174 | 173 | ||
| 175 | describe "GET /projects/:id/hooks/:hook_id" do | 174 | describe "GET /projects/:id/hooks/:hook_id" do |
| 176 | it "should return a project hook" do | 175 | it "should return a project hook" do |
| 177 | - get api("/projects/#{project.code}/hooks/#{hook.id}", user) | 176 | + get api("/projects/#{project.path}/hooks/#{hook.id}", user) |
| 178 | response.status.should == 200 | 177 | response.status.should == 200 |
| 179 | json_response['url'].should == hook.url | 178 | json_response['url'].should == hook.url |
| 180 | end | 179 | end |
| @@ -183,7 +182,7 @@ describe Gitlab::API do | @@ -183,7 +182,7 @@ describe Gitlab::API do | ||
| 183 | describe "POST /projects/:id/hooks" do | 182 | describe "POST /projects/:id/hooks" do |
| 184 | it "should add hook to project" do | 183 | it "should add hook to project" do |
| 185 | expect { | 184 | expect { |
| 186 | - post api("/projects/#{project.code}/hooks", user), | 185 | + post api("/projects/#{project.path}/hooks", user), |
| 187 | "url" => "http://example.com" | 186 | "url" => "http://example.com" |
| 188 | }.to change {project.hooks.count}.by(1) | 187 | }.to change {project.hooks.count}.by(1) |
| 189 | end | 188 | end |
| @@ -191,7 +190,7 @@ describe Gitlab::API do | @@ -191,7 +190,7 @@ describe Gitlab::API do | ||
| 191 | 190 | ||
| 192 | describe "PUT /projects/:id/hooks/:hook_id" do | 191 | describe "PUT /projects/:id/hooks/:hook_id" do |
| 193 | it "should update an existing project hook" do | 192 | it "should update an existing project hook" do |
| 194 | - put api("/projects/#{project.code}/hooks/#{hook.id}", user), | 193 | + put api("/projects/#{project.path}/hooks/#{hook.id}", user), |
| 195 | url: 'http://example.org' | 194 | url: 'http://example.org' |
| 196 | response.status.should == 200 | 195 | response.status.should == 200 |
| 197 | json_response['url'].should == 'http://example.org' | 196 | json_response['url'].should == 'http://example.org' |
| @@ -202,7 +201,7 @@ describe Gitlab::API do | @@ -202,7 +201,7 @@ describe Gitlab::API do | ||
| 202 | describe "DELETE /projects/:id/hooks" do | 201 | describe "DELETE /projects/:id/hooks" do |
| 203 | it "should delete hook from project" do | 202 | it "should delete hook from project" do |
| 204 | expect { | 203 | expect { |
| 205 | - delete api("/projects/#{project.code}/hooks", user), | 204 | + delete api("/projects/#{project.path}/hooks", user), |
| 206 | hook_id: hook.id | 205 | hook_id: hook.id |
| 207 | }.to change {project.hooks.count}.by(-1) | 206 | }.to change {project.hooks.count}.by(-1) |
| 208 | end | 207 | end |
| @@ -210,7 +209,7 @@ describe Gitlab::API do | @@ -210,7 +209,7 @@ describe Gitlab::API do | ||
| 210 | 209 | ||
| 211 | describe "GET /projects/:id/repository/tags" do | 210 | describe "GET /projects/:id/repository/tags" do |
| 212 | it "should return an array of project tags" do | 211 | it "should return an array of project tags" do |
| 213 | - get api("/projects/#{project.code}/repository/tags", user) | 212 | + get api("/projects/#{project.path}/repository/tags", user) |
| 214 | response.status.should == 200 | 213 | response.status.should == 200 |
| 215 | json_response.should be_an Array | 214 | json_response.should be_an Array |
| 216 | json_response.first['name'].should == project.repo.tags.sort_by(&:name).reverse.first.name | 215 | json_response.first['name'].should == project.repo.tags.sort_by(&:name).reverse.first.name |
| @@ -222,7 +221,7 @@ describe Gitlab::API do | @@ -222,7 +221,7 @@ describe Gitlab::API do | ||
| 222 | before { project.add_access(user2, :read) } | 221 | before { project.add_access(user2, :read) } |
| 223 | 222 | ||
| 224 | it "should return project commits" do | 223 | it "should return project commits" do |
| 225 | - get api("/projects/#{project.code}/repository/commits", user) | 224 | + get api("/projects/#{project.path}/repository/commits", user) |
| 226 | response.status.should == 200 | 225 | response.status.should == 200 |
| 227 | 226 | ||
| 228 | json_response.should be_an Array | 227 | json_response.should be_an Array |
| @@ -232,7 +231,7 @@ describe Gitlab::API do | @@ -232,7 +231,7 @@ describe Gitlab::API do | ||
| 232 | 231 | ||
| 233 | context "unauthorized user" do | 232 | context "unauthorized user" do |
| 234 | it "should not return project commits" do | 233 | it "should not return project commits" do |
| 235 | - get api("/projects/#{project.code}/repository/commits") | 234 | + get api("/projects/#{project.path}/repository/commits") |
| 236 | response.status.should == 401 | 235 | response.status.should == 401 |
| 237 | end | 236 | end |
| 238 | end | 237 | end |
| @@ -240,7 +239,7 @@ describe Gitlab::API do | @@ -240,7 +239,7 @@ describe Gitlab::API do | ||
| 240 | 239 | ||
| 241 | describe "GET /projects/:id/snippets" do | 240 | describe "GET /projects/:id/snippets" do |
| 242 | it "should return an array of project snippets" do | 241 | it "should return an array of project snippets" do |
| 243 | - get api("/projects/#{project.code}/snippets", user) | 242 | + get api("/projects/#{project.path}/snippets", user) |
| 244 | response.status.should == 200 | 243 | response.status.should == 200 |
| 245 | json_response.should be_an Array | 244 | json_response.should be_an Array |
| 246 | json_response.first['title'].should == snippet.title | 245 | json_response.first['title'].should == snippet.title |
| @@ -249,7 +248,7 @@ describe Gitlab::API do | @@ -249,7 +248,7 @@ describe Gitlab::API do | ||
| 249 | 248 | ||
| 250 | describe "GET /projects/:id/snippets/:snippet_id" do | 249 | describe "GET /projects/:id/snippets/:snippet_id" do |
| 251 | it "should return a project snippet" do | 250 | it "should return a project snippet" do |
| 252 | - get api("/projects/#{project.code}/snippets/#{snippet.id}", user) | 251 | + get api("/projects/#{project.path}/snippets/#{snippet.id}", user) |
| 253 | response.status.should == 200 | 252 | response.status.should == 200 |
| 254 | json_response['title'].should == snippet.title | 253 | json_response['title'].should == snippet.title |
| 255 | end | 254 | end |
| @@ -257,8 +256,8 @@ describe Gitlab::API do | @@ -257,8 +256,8 @@ describe Gitlab::API do | ||
| 257 | 256 | ||
| 258 | describe "POST /projects/:id/snippets" do | 257 | describe "POST /projects/:id/snippets" do |
| 259 | it "should create a new project snippet" do | 258 | it "should create a new project snippet" do |
| 260 | - post api("/projects/#{project.code}/snippets", user), | ||
| 261 | - title: 'api test', file_name: 'sample.rb', code: 'test' | 259 | + post api("/projects/#{project.path}/snippets", user), |
| 260 | + title: 'api test', file_name: 'sample.rb', path: 'test' | ||
| 262 | response.status.should == 201 | 261 | response.status.should == 201 |
| 263 | json_response['title'].should == 'api test' | 262 | json_response['title'].should == 'api test' |
| 264 | end | 263 | end |
| @@ -266,42 +265,42 @@ describe Gitlab::API do | @@ -266,42 +265,42 @@ describe Gitlab::API do | ||
| 266 | 265 | ||
| 267 | describe "PUT /projects/:id/snippets/:shippet_id" do | 266 | describe "PUT /projects/:id/snippets/:shippet_id" do |
| 268 | it "should update an existing project snippet" do | 267 | it "should update an existing project snippet" do |
| 269 | - put api("/projects/#{project.code}/snippets/#{snippet.id}", user), | ||
| 270 | - code: 'updated code' | 268 | + put api("/projects/#{project.path}/snippets/#{snippet.id}", user), |
| 269 | + path: 'updated path' | ||
| 271 | response.status.should == 200 | 270 | response.status.should == 200 |
| 272 | json_response['title'].should == 'example' | 271 | json_response['title'].should == 'example' |
| 273 | - snippet.reload.content.should == 'updated code' | 272 | + snippet.reload.content.should == 'updated path' |
| 274 | end | 273 | end |
| 275 | end | 274 | end |
| 276 | 275 | ||
| 277 | describe "DELETE /projects/:id/snippets/:snippet_id" do | 276 | describe "DELETE /projects/:id/snippets/:snippet_id" do |
| 278 | it "should delete existing project snippet" do | 277 | it "should delete existing project snippet" do |
| 279 | expect { | 278 | expect { |
| 280 | - delete api("/projects/#{project.code}/snippets/#{snippet.id}", user) | 279 | + delete api("/projects/#{project.path}/snippets/#{snippet.id}", user) |
| 281 | }.to change { Snippet.count }.by(-1) | 280 | }.to change { Snippet.count }.by(-1) |
| 282 | end | 281 | end |
| 283 | end | 282 | end |
| 284 | 283 | ||
| 285 | describe "GET /projects/:id/snippets/:snippet_id/raw" do | 284 | describe "GET /projects/:id/snippets/:snippet_id/raw" do |
| 286 | it "should get a raw project snippet" do | 285 | it "should get a raw project snippet" do |
| 287 | - get api("/projects/#{project.code}/snippets/#{snippet.id}/raw", user) | 286 | + get api("/projects/#{project.path}/snippets/#{snippet.id}/raw", user) |
| 288 | response.status.should == 200 | 287 | response.status.should == 200 |
| 289 | end | 288 | end |
| 290 | end | 289 | end |
| 291 | 290 | ||
| 292 | describe "GET /projects/:id/:sha/blob" do | 291 | describe "GET /projects/:id/:sha/blob" do |
| 293 | it "should get the raw file contents" do | 292 | it "should get the raw file contents" do |
| 294 | - get api("/projects/#{project.code}/repository/commits/master/blob?filepath=README.md", user) | 293 | + get api("/projects/#{project.path}/repository/commits/master/blob?filepath=README.md", user) |
| 295 | response.status.should == 200 | 294 | response.status.should == 200 |
| 296 | end | 295 | end |
| 297 | 296 | ||
| 298 | it "should return 404 for invalid branch_name" do | 297 | it "should return 404 for invalid branch_name" do |
| 299 | - get api("/projects/#{project.code}/repository/commits/invalid_branch_name/blob?filepath=README.md", user) | 298 | + get api("/projects/#{project.path}/repository/commits/invalid_branch_name/blob?filepath=README.md", user) |
| 300 | response.status.should == 404 | 299 | response.status.should == 404 |
| 301 | end | 300 | end |
| 302 | 301 | ||
| 303 | it "should return 404 for invalid file" do | 302 | it "should return 404 for invalid file" do |
| 304 | - get api("/projects/#{project.code}/repository/commits/master/blob?filepath=README.invalid", user) | 303 | + get api("/projects/#{project.path}/repository/commits/master/blob?filepath=README.invalid", user) |
| 305 | response.status.should == 404 | 304 | response.status.should == 404 |
| 306 | end | 305 | end |
| 307 | end | 306 | end |
spec/requests/projects_spec.rb
| @@ -8,8 +8,6 @@ describe "Projects" do | @@ -8,8 +8,6 @@ describe "Projects" do | ||
| 8 | visit new_project_path | 8 | visit new_project_path |
| 9 | 9 | ||
| 10 | fill_in 'project_name', with: 'Awesome' | 10 | fill_in 'project_name', with: 'Awesome' |
| 11 | - find("#project_path").value.should == 'awesome' | ||
| 12 | - find("#project_code").value.should == 'awesome' | ||
| 13 | end | 11 | end |
| 14 | end | 12 | end |
| 15 | 13 | ||
| @@ -53,7 +51,6 @@ describe "Projects" do | @@ -53,7 +51,6 @@ describe "Projects" do | ||
| 53 | visit edit_project_path(@project) | 51 | visit edit_project_path(@project) |
| 54 | 52 | ||
| 55 | fill_in 'project_name', with: 'Awesome' | 53 | fill_in 'project_name', with: 'Awesome' |
| 56 | - fill_in 'project_code', with: 'gitlabhq' | ||
| 57 | click_button "Save" | 54 | click_button "Save" |
| 58 | @project = @project.reload | 55 | @project = @project.reload |
| 59 | end | 56 | end |
spec/support/stubbed_repository.rb