Commit c50ec72b52e9ed7270f7c81c2c71fd8e5a28eeb0
1 parent
ab9d0236
Exists in
master
and in
4 other branches
Deprecate code for Project. Use title and path
Showing
22 changed files
with
79 additions
and
83 deletions
Show diff stats
app/controllers/admin/projects_controller.rb
@@ -5,7 +5,7 @@ class Admin::ProjectsController < AdminController | @@ -5,7 +5,7 @@ class Admin::ProjectsController < AdminController | ||
5 | @projects = Project.scoped | 5 | @projects = Project.scoped |
6 | @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? | 6 | @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? |
7 | @projects = @projects.search(params[:name]) if params[:name].present? | 7 | @projects = @projects.search(params[:name]) if params[:name].present? |
8 | - @projects = @projects.includes(:namespace).order("namespaces.code, projects.name ASC").page(params[:page]).per(20) | 8 | + @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) |
9 | end | 9 | end |
10 | 10 | ||
11 | def show | 11 | def show |
app/controllers/application_controller.rb
@@ -66,7 +66,7 @@ class ApplicationController < ActionController::Base | @@ -66,7 +66,7 @@ class ApplicationController < ActionController::Base | ||
66 | id = params[:project_id] || params[:id] | 66 | id = params[:project_id] || params[:id] |
67 | id = id.split("/") if id.include?("/") | 67 | id = id.split("/") if id.include?("/") |
68 | 68 | ||
69 | - @project ||= current_user.projects.find_by_code(id) | 69 | + @project ||= current_user.projects.find_by_path(id) |
70 | @project || render_404 | 70 | @project || render_404 |
71 | end | 71 | end |
72 | 72 |
app/models/namespace.rb
1 | class Namespace < ActiveRecord::Base | 1 | class Namespace < ActiveRecord::Base |
2 | - attr_accessible :code, :name, :owner_id | 2 | + attr_accessible :name, :path |
3 | 3 | ||
4 | - has_many :projects | 4 | + has_many :projects, dependent: :destroy |
5 | belongs_to :owner, class_name: "User" | 5 | belongs_to :owner, class_name: "User" |
6 | 6 | ||
7 | validates :name, presence: true, uniqueness: true | 7 | validates :name, presence: true, uniqueness: true |
8 | - validates :code, presence: true, uniqueness: true | 8 | + validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, |
9 | + format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, | ||
10 | + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | ||
9 | validates :owner, presence: true | 11 | validates :owner, presence: true |
10 | 12 | ||
11 | delegate :name, to: :owner, allow_nil: true, prefix: true | 13 | delegate :name, to: :owner, allow_nil: true, prefix: true |
@@ -15,11 +17,11 @@ class Namespace < ActiveRecord::Base | @@ -15,11 +17,11 @@ class Namespace < ActiveRecord::Base | ||
15 | scope :root, where('type IS NULL') | 17 | scope :root, where('type IS NULL') |
16 | 18 | ||
17 | def self.search query | 19 | def self.search query |
18 | - where("name LIKE :query OR code LIKE :query", query: "%#{query}%") | 20 | + where("name LIKE :query OR path LIKE :query", query: "%#{query}%") |
19 | end | 21 | end |
20 | 22 | ||
21 | def to_param | 23 | def to_param |
22 | - code | 24 | + path |
23 | end | 25 | end |
24 | 26 | ||
25 | def human_name | 27 | def human_name |
@@ -27,7 +29,7 @@ class Namespace < ActiveRecord::Base | @@ -27,7 +29,7 @@ class Namespace < ActiveRecord::Base | ||
27 | end | 29 | end |
28 | 30 | ||
29 | def ensure_dir_exist | 31 | def ensure_dir_exist |
30 | - namespace_dir_path = File.join(Gitlab.config.git_base_path, code) | 32 | + namespace_dir_path = File.join(Gitlab.config.git_base_path, path) |
31 | Dir.mkdir(namespace_dir_path) unless File.exists?(namespace_dir_path) | 33 | Dir.mkdir(namespace_dir_path) unless File.exists?(namespace_dir_path) |
32 | end | 34 | end |
33 | end | 35 | end |
app/models/project.rb
@@ -27,7 +27,7 @@ class Project < ActiveRecord::Base | @@ -27,7 +27,7 @@ class Project < ActiveRecord::Base | ||
27 | include Authority | 27 | include Authority |
28 | include Team | 28 | include Team |
29 | 29 | ||
30 | - attr_accessible :name, :path, :description, :code, :default_branch, :issues_enabled, | 30 | + attr_accessible :name, :path, :description, :default_branch, :issues_enabled, |
31 | :wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin] | 31 | :wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin] |
32 | 32 | ||
33 | attr_accessible :namespace_id, as: :admin | 33 | attr_accessible :namespace_id, as: :admin |
@@ -58,16 +58,16 @@ class Project < ActiveRecord::Base | @@ -58,16 +58,16 @@ class Project < ActiveRecord::Base | ||
58 | # Validations | 58 | # Validations |
59 | validates :owner, presence: true | 59 | validates :owner, presence: true |
60 | validates :description, length: { within: 0..2000 } | 60 | validates :description, length: { within: 0..2000 } |
61 | - validates :name, uniqueness: true, presence: true, length: { within: 0..255 } | ||
62 | - validates :path, uniqueness: true, presence: true, length: { within: 0..255 }, | ||
63 | - format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, | ||
64 | - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | ||
65 | - validates :code, presence: true, uniqueness: true, length: { within: 1..255 }, | 61 | + validates :name, presence: true, length: { within: 0..255 } |
62 | + validates :path, presence: true, length: { within: 0..255 }, | ||
66 | format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, | 63 | format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, |
67 | message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | 64 | message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } |
68 | validates :issues_enabled, :wall_enabled, :merge_requests_enabled, | 65 | validates :issues_enabled, :wall_enabled, :merge_requests_enabled, |
69 | :wiki_enabled, inclusion: { in: [true, false] } | 66 | :wiki_enabled, inclusion: { in: [true, false] } |
70 | 67 | ||
68 | + validates_uniqueness_of :name, scope: :namespace_id | ||
69 | + validates_uniqueness_of :path, scope: :namespace_id | ||
70 | + | ||
71 | validate :check_limit, :repo_name | 71 | validate :check_limit, :repo_name |
72 | 72 | ||
73 | # Scopes | 73 | # Scopes |
@@ -81,20 +81,23 @@ class Project < ActiveRecord::Base | @@ -81,20 +81,23 @@ class Project < ActiveRecord::Base | ||
81 | end | 81 | end |
82 | 82 | ||
83 | def search query | 83 | def search query |
84 | - where("projects.name LIKE :query OR projects.code LIKE :query OR projects.path LIKE :query", query: "%#{query}%") | 84 | + where("projects.name LIKE :query OR projects.path LIKE :query", query: "%#{query}%") |
85 | end | 85 | end |
86 | 86 | ||
87 | def create_by_user(params, user) | 87 | def create_by_user(params, user) |
88 | - namespace_id = params.delete(:namespace_id) || namespace.try(:id) | 88 | + namespace_id = params.delete(:namespace_id) |
89 | + namespace_id ||= current_user.namespace_id | ||
89 | 90 | ||
90 | project = Project.new params | 91 | project = Project.new params |
91 | 92 | ||
92 | Project.transaction do | 93 | Project.transaction do |
93 | 94 | ||
94 | - # Build gitlab-hq code from GitLab HQ name | 95 | + # Parametrize path for project |
95 | # | 96 | # |
96 | - slug = project.name.dup.parameterize | ||
97 | - project.code = project.path = slug | 97 | + # Ex. |
98 | + # 'GitLab HQ'.parameterize => "gitlab-hq" | ||
99 | + # | ||
100 | + project.path = project.name.dup.parameterize | ||
98 | 101 | ||
99 | project.owner = user | 102 | project.owner = user |
100 | project.namespace_id = namespace_id | 103 | project.namespace_id = namespace_id |
@@ -149,14 +152,14 @@ class Project < ActiveRecord::Base | @@ -149,14 +152,14 @@ class Project < ActiveRecord::Base | ||
149 | 152 | ||
150 | def to_param | 153 | def to_param |
151 | if namespace | 154 | if namespace |
152 | - namespace.code + "/" + code | 155 | + namespace.path + "/" + path |
153 | else | 156 | else |
154 | - code | 157 | + path |
155 | end | 158 | end |
156 | end | 159 | end |
157 | 160 | ||
158 | def web_url | 161 | def web_url |
159 | - [Gitlab.config.url, code].join("/") | 162 | + [Gitlab.config.url, path].join("/") |
160 | end | 163 | end |
161 | 164 | ||
162 | def common_notes | 165 | def common_notes |
@@ -213,7 +216,7 @@ class Project < ActiveRecord::Base | @@ -213,7 +216,7 @@ class Project < ActiveRecord::Base | ||
213 | 216 | ||
214 | def path_with_namespace | 217 | def path_with_namespace |
215 | if namespace | 218 | if namespace |
216 | - namespace.code + '/' + path | 219 | + namespace.path + '/' + path |
217 | else | 220 | else |
218 | path | 221 | path |
219 | end | 222 | end |
app/models/user.rb
@@ -69,7 +69,8 @@ class User < ActiveRecord::Base | @@ -69,7 +69,8 @@ class User < ActiveRecord::Base | ||
69 | before_save :ensure_authentication_token | 69 | before_save :ensure_authentication_token |
70 | alias_attribute :private_token, :authentication_token | 70 | alias_attribute :private_token, :authentication_token |
71 | 71 | ||
72 | - delegate :code, to: :namespace, allow_nil: true, prefix: true | 72 | + delegate :path, to: :namespace, allow_nil: true, prefix: true |
73 | + delegate :id, to: :namespace, allow_nil: true, prefix: true | ||
73 | 74 | ||
74 | # Scopes | 75 | # Scopes |
75 | scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) } | 76 | scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) } |
@@ -121,7 +122,7 @@ class User < ActiveRecord::Base | @@ -121,7 +122,7 @@ class User < ActiveRecord::Base | ||
121 | 122 | ||
122 | def namespaces | 123 | def namespaces |
123 | namespaces = [] | 124 | namespaces = [] |
124 | - namespaces << self.namespace | 125 | + namespaces << self.namespace if self.namespace |
125 | namespaces = namespaces + Group.all if admin | 126 | namespaces = namespaces + Group.all if admin |
126 | namespaces | 127 | namespaces |
127 | end | 128 | end |
app/observers/project_observer.rb
1 | class ProjectObserver < ActiveRecord::Observer | 1 | class ProjectObserver < ActiveRecord::Observer |
2 | - def before_save(project) | 2 | + def after_save(project) |
3 | + project.update_repository | ||
4 | + | ||
3 | # Move repository if namespace changed | 5 | # Move repository if namespace changed |
4 | if project.namespace_id_changed? and not project.new_record? | 6 | if project.namespace_id_changed? and not project.new_record? |
5 | move_project(project) | 7 | move_project(project) |
6 | end | 8 | end |
7 | end | 9 | end |
8 | 10 | ||
9 | - def after_save(project) | ||
10 | - project.update_repository | ||
11 | - end | ||
12 | - | ||
13 | def after_destroy(project) | 11 | def after_destroy(project) |
14 | log_info("Project \"#{project.name}\" was removed") | 12 | log_info("Project \"#{project.name}\" was removed") |
15 | 13 | ||
@@ -27,8 +25,8 @@ class ProjectObserver < ActiveRecord::Observer | @@ -27,8 +25,8 @@ class ProjectObserver < ActiveRecord::Observer | ||
27 | end | 25 | end |
28 | 26 | ||
29 | def move_project(project) | 27 | def move_project(project) |
30 | - old_dir = Namespace.find_by_id(project.namespace_id_was).try(:code) || '' | ||
31 | - new_dir = Namespace.find_by_id(project.namespace_id).try(:code) || '' | 28 | + old_dir = Namespace.find_by_id(project.namespace_id_was).try(:path) || '' |
29 | + new_dir = Namespace.find_by_id(project.namespace_id).try(:path) || '' | ||
32 | 30 | ||
33 | # Create new dir if missing | 31 | # Create new dir if missing |
34 | new_dir_path = File.join(Gitlab.config.git_base_path, new_dir) | 32 | new_dir_path = File.join(Gitlab.config.git_base_path, new_dir) |
app/roles/push_observer.rb
@@ -114,7 +114,7 @@ module PushObserver | @@ -114,7 +114,7 @@ module PushObserver | ||
114 | id: commit.id, | 114 | id: commit.id, |
115 | message: commit.safe_message, | 115 | message: commit.safe_message, |
116 | timestamp: commit.date.xmlschema, | 116 | timestamp: commit.date.xmlschema, |
117 | - url: "#{Gitlab.config.url}/#{code}/commits/#{commit.id}", | 117 | + url: "#{Gitlab.config.url}/#{path}/commits/#{commit.id}", |
118 | author: { | 118 | author: { |
119 | name: commit.author_name, | 119 | name: commit.author_name, |
120 | email: commit.author_email | 120 | email: commit.author_email |
app/roles/repository.rb
@@ -87,7 +87,7 @@ module Repository | @@ -87,7 +87,7 @@ module Repository | ||
87 | end | 87 | end |
88 | 88 | ||
89 | def namespace_dir | 89 | def namespace_dir |
90 | - namespace.try(:code) || '' | 90 | + namespace.try(:path) || '' |
91 | end | 91 | end |
92 | 92 | ||
93 | def update_repository | 93 | def update_repository |
@@ -164,12 +164,12 @@ module Repository | @@ -164,12 +164,12 @@ module Repository | ||
164 | return nil unless commit | 164 | return nil unless commit |
165 | 165 | ||
166 | # Build file path | 166 | # Build file path |
167 | - file_name = self.code + "-" + commit.id.to_s + ".tar.gz" | ||
168 | - storage_path = Rails.root.join("tmp", "repositories", self.code) | 167 | + file_name = self.path + "-" + commit.id.to_s + ".tar.gz" |
168 | + storage_path = Rails.root.join("tmp", "repositories", self.path) | ||
169 | file_path = File.join(storage_path, file_name) | 169 | file_path = File.join(storage_path, file_name) |
170 | 170 | ||
171 | # Put files into a directory before archiving | 171 | # Put files into a directory before archiving |
172 | - prefix = self.code + "/" | 172 | + prefix = self.path + "/" |
173 | 173 | ||
174 | # Create file if not exists | 174 | # Create file if not exists |
175 | unless File.exists?(file_path) | 175 | unless File.exists?(file_path) |
app/views/admin/dashboard/index.html.haml
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | = link_to admin_projects_path do | 27 | = link_to admin_projects_path do |
28 | %h1= Project.count | 28 | %h1= Project.count |
29 | %hr | 29 | %hr |
30 | - = link_to 'New Project', new_admin_project_path, class: "btn small" | 30 | + = link_to 'New Project', new_project_path, class: "btn small" |
31 | .span4 | 31 | .span4 |
32 | .ui-box | 32 | .ui-box |
33 | %h5 Users | 33 | %h5 Users |
app/views/admin/groups/_form.html.haml
@@ -8,12 +8,12 @@ | @@ -8,12 +8,12 @@ | ||
8 | .input | 8 | .input |
9 | = f.text_field :name, placeholder: "Example Group", class: "xxlarge" | 9 | = f.text_field :name, placeholder: "Example Group", class: "xxlarge" |
10 | .clearfix | 10 | .clearfix |
11 | - = f.label :code do | 11 | + = f.label :path do |
12 | URL | 12 | URL |
13 | .input | 13 | .input |
14 | .input-prepend | 14 | .input-prepend |
15 | %span.add-on= web_app_url + 'groups/' | 15 | %span.add-on= web_app_url + 'groups/' |
16 | - = f.text_field :code, placeholder: "example" | 16 | + = f.text_field :path, placeholder: "example" |
17 | 17 | ||
18 | .form-actions | 18 | .form-actions |
19 | = f.submit 'Save group', class: "btn save-btn" | 19 | = f.submit 'Save group', class: "btn save-btn" |
app/views/admin/projects/_form.html.haml
@@ -18,13 +18,6 @@ | @@ -18,13 +18,6 @@ | ||
18 | Path | 18 | Path |
19 | .input | 19 | .input |
20 | = text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true | 20 | = text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true |
21 | - .clearfix | ||
22 | - = f.label :code do | ||
23 | - URL | ||
24 | - .input | ||
25 | - .input-prepend | ||
26 | - %span.add-on= web_app_url | ||
27 | - = f.text_field :code, placeholder: "example" | ||
28 | 21 | ||
29 | - unless project.new_record? | 22 | - unless project.new_record? |
30 | .clearfix | 23 | .clearfix |
app/views/projects/_form.html.haml
@@ -19,13 +19,6 @@ | @@ -19,13 +19,6 @@ | ||
19 | .input-prepend | 19 | .input-prepend |
20 | %strong | 20 | %strong |
21 | = text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true | 21 | = text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true |
22 | - .clearfix | ||
23 | - = f.label :code do | ||
24 | - URL | ||
25 | - .input | ||
26 | - .input-prepend | ||
27 | - %span.add-on= web_app_url | ||
28 | - = f.text_field :code, placeholder: "example" | ||
29 | 22 | ||
30 | - unless @project.new_record? || @project.heads.empty? | 23 | - unless @project.new_record? || @project.heads.empty? |
31 | .clearfix | 24 | .clearfix |
db/fixtures/development/001_admin.rb
1 | unless User.count > 0 | 1 | unless User.count > 0 |
2 | admin = User.create( | 2 | admin = User.create( |
3 | - :email => "admin@local.host", | ||
4 | - :name => "Administrator", | ||
5 | - :password => "5iveL!fe", | ||
6 | - :password_confirmation => "5iveL!fe" | 3 | + email: "admin@local.host", |
4 | + name: "Administrator", | ||
5 | + username: 'root', | ||
6 | + password: "5iveL!fe", | ||
7 | + password_confirmation: "5iveL!fe" | ||
7 | ) | 8 | ) |
8 | 9 | ||
9 | admin.projects_limit = 10000 | 10 | admin.projects_limit = 10000 |
db/fixtures/development/003_users.rb
1 | User.seed(:id, [ | 1 | User.seed(:id, [ |
2 | - { :id => 2, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
3 | - { :id => 3, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
4 | - { :id => 4, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
5 | - { :id => 5, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
6 | - { :id => 6, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
7 | - { :id => 7, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
8 | - { :id => 8, :name => Faker::Internet.user_name, :email => Faker::Internet.email}, | ||
9 | - { :id => 9, :name => Faker::Internet.user_name, :email => Faker::Internet.email} | 2 | + { id: 2, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, |
3 | + { id: 3, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
4 | + { id: 4, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
5 | + { id: 5, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
6 | + { id: 6, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
7 | + { id: 7, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
8 | + { id: 8, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, | ||
9 | + { id: 9, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email} | ||
10 | ]) | 10 | ]) |
11 | 11 |
db/fixtures/production/001_admin.rb
1 | admin = User.create( | 1 | admin = User.create( |
2 | - :email => "admin@local.host", | ||
3 | - :name => "Administrator", | ||
4 | - :password => "5iveL!fe", | ||
5 | - :password_confirmation => "5iveL!fe" | 2 | + email: "admin@local.host", |
3 | + name: "Administrator", | ||
4 | + username: 'root', | ||
5 | + password: "5iveL!fe", | ||
6 | + password_confirmation: "5iveL!fe" | ||
6 | ) | 7 | ) |
7 | 8 | ||
8 | admin.projects_limit = 10000 | 9 | admin.projects_limit = 10000 |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +class RenameCodeToPath < ActiveRecord::Migration | ||
2 | + def up | ||
3 | + remove_column :projects, :code | ||
4 | + rename_column :namespaces, :code, :path | ||
5 | + end | ||
6 | + | ||
7 | + def down | ||
8 | + add_column :projects, :code, :string | ||
9 | + rename_column :namespaces, :path, :code | ||
10 | + end | ||
11 | +end |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20121123104937) do | 14 | +ActiveRecord::Schema.define(:version => 20121123164910) do |
15 | 15 | ||
16 | create_table "events", :force => true do |t| | 16 | create_table "events", :force => true do |t| |
17 | t.string "target_type" | 17 | t.string "target_type" |
@@ -82,7 +82,7 @@ ActiveRecord::Schema.define(:version => 20121123104937) do | @@ -82,7 +82,7 @@ ActiveRecord::Schema.define(:version => 20121123104937) do | ||
82 | 82 | ||
83 | create_table "namespaces", :force => true do |t| | 83 | create_table "namespaces", :force => true do |t| |
84 | t.string "name", :null => false | 84 | t.string "name", :null => false |
85 | - t.string "code", :null => false | 85 | + t.string "path", :null => false |
86 | t.integer "owner_id", :null => false | 86 | t.integer "owner_id", :null => false |
87 | t.datetime "created_at", :null => false | 87 | t.datetime "created_at", :null => false |
88 | t.datetime "updated_at", :null => false | 88 | t.datetime "updated_at", :null => false |
@@ -111,7 +111,6 @@ ActiveRecord::Schema.define(:version => 20121123104937) do | @@ -111,7 +111,6 @@ ActiveRecord::Schema.define(:version => 20121123104937) do | ||
111 | t.datetime "created_at", :null => false | 111 | t.datetime "created_at", :null => false |
112 | t.datetime "updated_at", :null => false | 112 | t.datetime "updated_at", :null => false |
113 | t.boolean "private_flag", :default => true, :null => false | 113 | t.boolean "private_flag", :default => true, :null => false |
114 | - t.string "code" | ||
115 | t.integer "owner_id" | 114 | t.integer "owner_id" |
116 | t.string "default_branch" | 115 | t.string "default_branch" |
117 | t.boolean "issues_enabled", :default => true, :null => false | 116 | t.boolean "issues_enabled", :default => true, :null => false |
lib/api/helpers.rb
@@ -6,7 +6,7 @@ module Gitlab | @@ -6,7 +6,7 @@ module Gitlab | ||
6 | 6 | ||
7 | def user_project | 7 | def user_project |
8 | if @project ||= current_user.projects.find_by_id(params[:id]) || | 8 | if @project ||= current_user.projects.find_by_id(params[:id]) || |
9 | - current_user.projects.find_by_code(params[:id]) | 9 | + current_user.projects.find_by_path(params[:id]) |
10 | else | 10 | else |
11 | not_found! | 11 | not_found! |
12 | end | 12 | end |
lib/gitlab/auth.rb
@@ -34,6 +34,7 @@ module Gitlab | @@ -34,6 +34,7 @@ module Gitlab | ||
34 | extern_uid: uid, | 34 | extern_uid: uid, |
35 | provider: provider, | 35 | provider: provider, |
36 | name: name, | 36 | name: name, |
37 | + username: email.match(/^[^@]*/)[0], | ||
37 | email: email, | 38 | email: email, |
38 | password: password, | 39 | password: password, |
39 | password_confirmation: password, | 40 | password_confirmation: password, |
spec/factories.rb
@@ -12,6 +12,7 @@ FactoryGirl.define do | @@ -12,6 +12,7 @@ FactoryGirl.define do | ||
12 | factory :user, aliases: [:author, :assignee, :owner] do | 12 | factory :user, aliases: [:author, :assignee, :owner] do |
13 | email { Faker::Internet.email } | 13 | email { Faker::Internet.email } |
14 | name | 14 | name |
15 | + username 'john' | ||
15 | password "123456" | 16 | password "123456" |
16 | password_confirmation { password } | 17 | password_confirmation { password } |
17 | 18 |
spec/observers/user_observer_spec.rb
@@ -13,7 +13,7 @@ describe UserObserver do | @@ -13,7 +13,7 @@ describe UserObserver do | ||
13 | end | 13 | end |
14 | 14 | ||
15 | context 'when a new user is created' do | 15 | context 'when a new user is created' do |
16 | - let(:user) { double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local') } | 16 | + let(:user) { double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', username: 'root') } |
17 | let(:notification) { double :notification } | 17 | let(:notification) { double :notification } |
18 | 18 | ||
19 | it 'sends an email' do | 19 | it 'sends an email' do |
spec/routing/admin_routing_spec.rb
@@ -78,14 +78,6 @@ describe Admin::ProjectsController, "routing" do | @@ -78,14 +78,6 @@ describe Admin::ProjectsController, "routing" do | ||
78 | get("/admin/projects").should route_to('admin/projects#index') | 78 | get("/admin/projects").should route_to('admin/projects#index') |
79 | end | 79 | end |
80 | 80 | ||
81 | - it "to #create" do | ||
82 | - post("/admin/projects").should route_to('admin/projects#create') | ||
83 | - end | ||
84 | - | ||
85 | - it "to #new" do | ||
86 | - get("/admin/projects/new").should route_to('admin/projects#new') | ||
87 | - end | ||
88 | - | ||
89 | it "to #edit" do | 81 | it "to #edit" do |
90 | get("/admin/projects/gitlab/edit").should route_to('admin/projects#edit', id: 'gitlab') | 82 | get("/admin/projects/gitlab/edit").should route_to('admin/projects#edit', id: 'gitlab') |
91 | end | 83 | end |