Commit fb470e8e2aff80a16b56f9c5422c04e74dcb213c
1 parent
a0bd09ab
Exists in
master
and in
4 other branches
Validate username uniq in scope of namespace
Showing
4 changed files
with
18 additions
and
12 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -67,6 +67,8 @@ class User < ActiveRecord::Base |
67 | 67 | message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } |
68 | 68 | |
69 | 69 | |
70 | + validate :namespace_uniq, if: ->(user) { user.username_changed? } | |
71 | + | |
70 | 72 | before_validation :generate_password, on: :create |
71 | 73 | before_save :ensure_authentication_token |
72 | 74 | alias_attribute :private_token, :authentication_token |
... | ... | @@ -135,6 +137,12 @@ class User < ActiveRecord::Base |
135 | 137 | end |
136 | 138 | end |
137 | 139 | |
140 | + def namespace_uniq | |
141 | + namespace_name = self.username | |
142 | + if Namespace.find_by_path(namespace_name) | |
143 | + self.errors.add :username, "already exist" | |
144 | + end | |
145 | + end | |
138 | 146 | |
139 | 147 | # Namespaces user has access to |
140 | 148 | def namespaces | ... | ... |
app/views/profiles/account.html.haml
features/steps/project/project_milestones.rb
... | ... | @@ -50,12 +50,12 @@ class ProjectMilestones < Spinach::FeatureSteps |
50 | 50 | end |
51 | 51 | |
52 | 52 | Then "I should see 3 issues" do |
53 | - page.should have_selector('.milestone-issue-filter li', count: 4) | |
54 | - page.should have_selector('.milestone-issue-filter li.hide', count: 1) | |
53 | + page.should have_selector('.milestone-issue-filter .well-list li', count: 4) | |
54 | + page.should have_selector('.milestone-issue-filter .well-list li.hide', count: 1) | |
55 | 55 | end |
56 | 56 | |
57 | 57 | Then "I should see 4 issues" do |
58 | - page.should have_selector('.milestone-issue-filter li', count: 4) | |
59 | - page.should_not have_selector('.milestone-issue-filter li.hide') | |
58 | + page.should have_selector('.milestone-issue-filter .well-list li', count: 4) | |
59 | + page.should_not have_selector('.milestone-issue-filter .well-list li.hide') | |
60 | 60 | end |
61 | 61 | end | ... | ... |
lib/tasks/travis.rake
1 | -task :travis do | |
2 | - ["rake spinach", "rake spec"].each do |cmd| | |
3 | - puts "Starting to run #{cmd}..." | |
4 | - system("export DISPLAY=:99.0 && bundle exec #{cmd}") | |
5 | - raise "#{cmd} failed!" unless $?.exitstatus == 0 | |
6 | - end | |
7 | -end | |
1 | +desc "Travis run tests" | |
2 | +task :travis => [ | |
3 | + :spinach, | |
4 | + :spec | |
5 | +] | ... | ... |