summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-01-29 15:35:21 +0100
committerJames Lopez <james@jameslopez.es>2016-01-29 15:35:21 +0100
commiteb51a4ac1b7702873ecb9de7ddafdb989370437c (patch)
tree949174c813041ddf5382431eb50c97c777d0b0e6
parent7ca6779654ed2da5ba31ab9256406feb1b7fb8ee (diff)
downloadgitlab-ce-eb51a4ac1b7702873ecb9de7ddafdb989370437c.tar.gz
refactor previous test and add validation to project model
-rw-r--r--lib/gitlab/regex.rb4
-rw-r--r--spec/controllers/projects_controller_spec.rb9
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index 53ab2686b43..3331bd123b2 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -34,12 +34,12 @@ module Gitlab
def project_path_regex
- @project_path_regex ||= /\A[a-zA-Z0-9_.][a-zA-Z0-9_\-\.]*(?<!\.git)\z/.freeze
+ @project_path_regex ||= /\A[a-zA-Z0-9_.][a-zA-Z0-9_\-\.]*(?<!\.git|\.atom)\z/.freeze
end
def project_path_regex_message
"can contain only letters, digits, '_', '-' and '.'. " \
- "Cannot start with '-' or end in '.git'" \
+ "Cannot start with '-', end in '.git' or end in '.atom'" \
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index ad143c14c43..245cf96d644 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -88,13 +88,10 @@ describe ProjectsController do
end
context "when the url contains .atom" do
- let(:public_project_with_dot) { create(:project, :public, name: 'my.atom', path: 'my.atom') }
+ let(:public_project_with_dot_atom) { create(:project, :public, name: 'my.atom', path: 'my.atom') }
- it 'loads a project' do
- get :show, namespace_id: public_project_with_dot.namespace.path, id: public_project_with_dot.path
-
- expect(assigns(:project)).to eq(public_project_with_dot)
- expect(response.status).to eq(200)
+ it 'expect an error creating the project' do
+ expect { public_project_with_dot_atom }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end