diff --git a/app/models/project.rb b/app/models/project.rb index 17b556c34718d91dad0fd41cceba6d084ca20f93..0d90af866bfba165850d378bc6e4cfc13dfd5184 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -16,6 +16,8 @@ class Project < ActiveRecord::Base validates :path, :uniqueness => true, :presence => true, + :format => { :with => /^[a-zA-Z0-9_\-]*$/, + :message => "only letters, digits & '_' '-' allowed" }, :length => { :within => 0..255 } validates :description, @@ -24,14 +26,15 @@ class Project < ActiveRecord::Base validates :code, :presence => true, :uniqueness => true, - :length => { :within => 3..12 } + :format => { :with => /^[a-zA-Z0-9_\-]*$/, + :message => "only letters, digits & '_' '-' allowed" }, + :length => { :within => 3..16 } validates :owner, :presence => true validate :check_limit - before_save :format_code after_destroy :destroy_gitosis_project after_save :update_gitosis_project @@ -47,10 +50,6 @@ class Project < ActiveRecord::Base notes.where(:noteable_type => ["", nil]) end - def format_code - read_attribute(:code).downcase.strip.gsub(' ', '') - end - def update_gitosis_project Gitosis.new.configure do |c| c.update_project(path, gitosis_writers) diff --git a/config/initializers/rails_footnotes.rb b/config/initializers/rails_footnotes.rb index da9d58e4acb3e90578ac3fdce3fc92fcb41bb3bd..2e578ec961f41b036f0ef05e2d0e392d94e7f87d 100644 --- a/config/initializers/rails_footnotes.rb +++ b/config/initializers/rails_footnotes.rb @@ -1,5 +1,5 @@ if defined?(Footnotes) && Rails.env.development? - Footnotes.run! # first of all + #Footnotes.run! # first of all # ... other init code end diff --git a/config/routes.rb b/config/routes.rb index 00106b119a67f50403dc841b54098af7b0d95351..cd8dc4ceef3464b19d57a1278a88dafcbc06ee31 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do get "tree/:commit_id/:path" => "projects#tree", :as => :tree_file, :constraints => { - :id => /[a-zA-Z0-9]+/, + :id => /[a-zA-Z0-9_\-]+/, :commit_id => /[a-zA-Z0-9]+/, :path => /.*/ } diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb index 8aa311e84427524a2aa28a13a28e32e3a49c7880..e36ee4411ff96871c326752da92164e730de2a5d 100644 --- a/spec/requests/admin/admin_projects_spec.rb +++ b/spec/requests/admin/admin_projects_spec.rb @@ -88,7 +88,7 @@ describe "Admin::Projects" do visit new_admin_project_path fill_in 'Name', :with => 'NewProject' fill_in 'Code', :with => 'NPR' - fill_in 'Path', :with => '/tmp/legit_test/legit' + fill_in 'Path', :with => 'legit_1' expect { click_button "Save" }.to change { Project.count }.by(1) @project = Project.last end diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index 329f0a504358bf9c18b207c82473ddf7ca4557a8..2825a6a979af975d28a4d587b28c36ec7e09d20e 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -39,7 +39,7 @@ describe "Projects" do visit new_project_path fill_in 'Name', :with => 'NewProject' fill_in 'Code', :with => 'NPR' - fill_in 'Path', :with => '/tmp/legit_test/legit' + fill_in 'Path', :with => 'newproject' expect { click_button "Create Project" }.to change { Project.count }.by(1) @project = Project.last end