Commit 470aa7675e07724ff48f159ee12da40409949222

Authored by Dmitriy Zaporozhets
1 parent c50ec72b

Fix project.code-related functionality

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 ||= current_user.namespace_id 89 + namespace_id ||= user.namespace_id
90 90
91 project = Project.new params 91 project = Project.new params
92 92
app/views/admin/groups/index.html.haml
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 %table 14 %table
15 %thead 15 %thead
16 %th Name 16 %th Name
17 - %th Code 17 + %th Path
18 %th Projects 18 %th Projects
19 %th Edit 19 %th Edit
20 %th.cred Danger Zone! 20 %th.cred Danger Zone!
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 - @groups.each do |group| 22 - @groups.each do |group|
23 %tr 23 %tr
24 %td= link_to group.name, [:admin, group] 24 %td= link_to group.name, [:admin, group]
25 - %td= group.code 25 + %td= group.path
26 %td= group.projects.count 26 %td= group.projects.count
27 %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small" 27 %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small"
28 %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger" 28 %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger"
app/views/admin/groups/show.html.haml
@@ -20,9 +20,9 @@ @@ -20,9 +20,9 @@
20 %tr 20 %tr
21 %td 21 %td
22 %b 22 %b
23 - Code: 23 + Path:
24 %td 24 %td
25 - = @group.code 25 + = @group.path
26 %tr 26 %tr
27 %td 27 %td
28 %b 28 %b
app/views/admin/projects/show.html.haml
@@ -29,12 +29,6 @@ @@ -29,12 +29,6 @@
29 %tr 29 %tr
30 %td 30 %td
31 %b 31 %b
32 - Code:  
33 - %td  
34 - = @project.code  
35 - %tr  
36 - %td  
37 - %b  
38 Path: 32 Path:
39 %td 33 %td
40 %code= @project.path_to_repo 34 %code= @project.path_to_repo
app/views/dashboard/_groups.html.haml
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 %ul.unstyled 11 %ul.unstyled
12 - groups.each do |group| 12 - groups.each do |group|
13 %li.wll 13 %li.wll
14 - = link_to group_path(id: group.code), class: dom_class(group) do 14 + = link_to group_path(id: group.path), class: dom_class(group) do
15 %strong.group_name= truncate(group.name, length: 25) 15 %strong.group_name= truncate(group.name, length: 25)
16 %span.arrow 16 %span.arrow
17 → 17 →
app/views/layouts/_init_auto_complete.html.haml
1 :javascript 1 :javascript
2 $(function() { 2 $(function() {
3 - GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.code}/members" if @project }"; 3 + GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.path}/members" if @project }";
4 GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}"; 4 GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}";
5 5
6 GitLab.GfmAutoComplete.Emoji.data = #{raw emoji_autocomplete_source}; 6 GitLab.GfmAutoComplete.Emoji.data = #{raw emoji_autocomplete_source};
app/views/layouts/project_resource.html.haml
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 .container 7 .container
8 %ul.main_menu 8 %ul.main_menu
9 = nav_link(html_options: {class: "home #{project_tab_class}"}) do 9 = nav_link(html_options: {class: "home #{project_tab_class}"}) do
10 - = link_to @project.code, project_path(@project), title: "Project" 10 + = link_to @project.path, project_path(@project), title: "Project"
11 11
12 - if @project.repo_exists? 12 - if @project.repo_exists?
13 - if can? current_user, :download_code, @project 13 - if can? current_user, :download_code, @project
spec/factories.rb
@@ -26,13 +26,12 @@ FactoryGirl.define do @@ -26,13 +26,12 @@ FactoryGirl.define do
26 factory :project do 26 factory :project do
27 sequence(:name) { |n| "project#{n}" } 27 sequence(:name) { |n| "project#{n}" }
28 path { name.downcase.gsub(/\s/, '_') } 28 path { name.downcase.gsub(/\s/, '_') }
29 - code { name.downcase.gsub(/\s/, '_') }  
30 owner 29 owner
31 end 30 end
32 31
33 factory :namespace do 32 factory :namespace do
34 sequence(:name) { |n| "group#{n}" } 33 sequence(:name) { |n| "group#{n}" }
35 - code { name.downcase.gsub(/\s/, '_') } 34 + path { name.downcase.gsub(/\s/, '_') }
36 owner 35 owner
37 36
38 factory :group do 37 factory :group do