Commit 57baa49bc3c71cc8084d925415e44ad1b8ad73a9
1 parent
29158ea3
Exists in
master
and in
4 other branches
project path & code regexp validation
Showing
5 changed files
with
9 additions
and
10 deletions
Show diff stats
app/models/project.rb
... | ... | @@ -16,6 +16,8 @@ class Project < ActiveRecord::Base |
16 | 16 | validates :path, |
17 | 17 | :uniqueness => true, |
18 | 18 | :presence => true, |
19 | + :format => { :with => /^[a-zA-Z0-9_\-]*$/, | |
20 | + :message => "only letters, digits & '_' '-' allowed" }, | |
19 | 21 | :length => { :within => 0..255 } |
20 | 22 | |
21 | 23 | validates :description, |
... | ... | @@ -24,14 +26,15 @@ class Project < ActiveRecord::Base |
24 | 26 | validates :code, |
25 | 27 | :presence => true, |
26 | 28 | :uniqueness => true, |
27 | - :length => { :within => 3..12 } | |
29 | + :format => { :with => /^[a-zA-Z0-9_\-]*$/, | |
30 | + :message => "only letters, digits & '_' '-' allowed" }, | |
31 | + :length => { :within => 3..16 } | |
28 | 32 | |
29 | 33 | validates :owner, |
30 | 34 | :presence => true |
31 | 35 | |
32 | 36 | validate :check_limit |
33 | 37 | |
34 | - before_save :format_code | |
35 | 38 | after_destroy :destroy_gitosis_project |
36 | 39 | after_save :update_gitosis_project |
37 | 40 | |
... | ... | @@ -47,10 +50,6 @@ class Project < ActiveRecord::Base |
47 | 50 | notes.where(:noteable_type => ["", nil]) |
48 | 51 | end |
49 | 52 | |
50 | - def format_code | |
51 | - read_attribute(:code).downcase.strip.gsub(' ', '') | |
52 | - end | |
53 | - | |
54 | 53 | def update_gitosis_project |
55 | 54 | Gitosis.new.configure do |c| |
56 | 55 | c.update_project(path, gitosis_writers) | ... | ... |
config/initializers/rails_footnotes.rb
config/routes.rb
spec/requests/admin/admin_projects_spec.rb
... | ... | @@ -88,7 +88,7 @@ describe "Admin::Projects" do |
88 | 88 | visit new_admin_project_path |
89 | 89 | fill_in 'Name', :with => 'NewProject' |
90 | 90 | fill_in 'Code', :with => 'NPR' |
91 | - fill_in 'Path', :with => '/tmp/legit_test/legit' | |
91 | + fill_in 'Path', :with => 'legit_1' | |
92 | 92 | expect { click_button "Save" }.to change { Project.count }.by(1) |
93 | 93 | @project = Project.last |
94 | 94 | end | ... | ... |
spec/requests/projects_spec.rb
... | ... | @@ -39,7 +39,7 @@ describe "Projects" do |
39 | 39 | visit new_project_path |
40 | 40 | fill_in 'Name', :with => 'NewProject' |
41 | 41 | fill_in 'Code', :with => 'NPR' |
42 | - fill_in 'Path', :with => '/tmp/legit_test/legit' | |
42 | + fill_in 'Path', :with => 'newproject' | |
43 | 43 | expect { click_button "Create Project" }.to change { Project.count }.by(1) |
44 | 44 | @project = Project.last |
45 | 45 | end | ... | ... |