summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-07 17:36:24 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-07 17:36:24 +0200
commitfb470e8e2aff80a16b56f9c5422c04e74dcb213c (patch)
tree017618080e17d3f3e5da8b360c0b6c7390a252c8
parenta0bd09ab830899237ada52f02437164d7eaaf1ed (diff)
downloadgitlab-ce-fb470e8e2aff80a16b56f9c5422c04e74dcb213c.tar.gz
Validate username uniq in scope of namespace
-rw-r--r--app/models/user.rb8
-rw-r--r--app/views/profiles/account.html.haml2
-rw-r--r--features/steps/project/project_milestones.rb8
-rw-r--r--lib/tasks/travis.rake12
4 files changed, 18 insertions, 12 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 341b96a0d91..55d75892fc4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -67,6 +67,8 @@ class User < ActiveRecord::Base
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
+ validate :namespace_uniq, if: ->(user) { user.username_changed? }
+
before_validation :generate_password, on: :create
before_save :ensure_authentication_token
alias_attribute :private_token, :authentication_token
@@ -135,6 +137,12 @@ class User < ActiveRecord::Base
end
end
+ def namespace_uniq
+ namespace_name = self.username
+ if Namespace.find_by_path(namespace_name)
+ self.errors.add :username, "already exist"
+ end
+ end
# Namespaces user has access to
def namespaces
diff --git a/app/views/profiles/account.html.haml b/app/views/profiles/account.html.haml
index 3c290948d6c..522e45e637a 100644
--- a/app/views/profiles/account.html.haml
+++ b/app/views/profiles/account.html.haml
@@ -69,7 +69,7 @@
%i.icon-ok
Saved
%span.update-failed.cred.hide
- %i.icon-ok
+ %i.icon-remove
Failed
%ul.cred
%li It will change web url for personal projects.
diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/project_milestones.rb
index a68934dbb63..1350938ee9a 100644
--- a/features/steps/project/project_milestones.rb
+++ b/features/steps/project/project_milestones.rb
@@ -50,12 +50,12 @@ class ProjectMilestones < Spinach::FeatureSteps
end
Then "I should see 3 issues" do
- page.should have_selector('.milestone-issue-filter li', count: 4)
- page.should have_selector('.milestone-issue-filter li.hide', count: 1)
+ page.should have_selector('.milestone-issue-filter .well-list li', count: 4)
+ page.should have_selector('.milestone-issue-filter .well-list li.hide', count: 1)
end
Then "I should see 4 issues" do
- page.should have_selector('.milestone-issue-filter li', count: 4)
- page.should_not have_selector('.milestone-issue-filter li.hide')
+ page.should have_selector('.milestone-issue-filter .well-list li', count: 4)
+ page.should_not have_selector('.milestone-issue-filter .well-list li.hide')
end
end
diff --git a/lib/tasks/travis.rake b/lib/tasks/travis.rake
index e04bfbaf1c0..6b434830803 100644
--- a/lib/tasks/travis.rake
+++ b/lib/tasks/travis.rake
@@ -1,7 +1,5 @@
-task :travis do
- ["rake spinach", "rake spec"].each do |cmd|
- puts "Starting to run #{cmd}..."
- system("export DISPLAY=:99.0 && bundle exec #{cmd}")
- raise "#{cmd} failed!" unless $?.exitstatus == 0
- end
-end
+desc "Travis run tests"
+task :travis => [
+ :spinach,
+ :spec
+]