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,6 +67,8 @@ class User < ActiveRecord::Base | ||
| 67 | message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | 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 | before_validation :generate_password, on: :create | 72 | before_validation :generate_password, on: :create |
| 71 | before_save :ensure_authentication_token | 73 | before_save :ensure_authentication_token |
| 72 | alias_attribute :private_token, :authentication_token | 74 | alias_attribute :private_token, :authentication_token |
| @@ -135,6 +137,12 @@ class User < ActiveRecord::Base | @@ -135,6 +137,12 @@ class User < ActiveRecord::Base | ||
| 135 | end | 137 | end |
| 136 | end | 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 | # Namespaces user has access to | 147 | # Namespaces user has access to |
| 140 | def namespaces | 148 | def namespaces |
app/views/profiles/account.html.haml
| @@ -69,7 +69,7 @@ | @@ -69,7 +69,7 @@ | ||
| 69 | %i.icon-ok | 69 | %i.icon-ok |
| 70 | Saved | 70 | Saved |
| 71 | %span.update-failed.cred.hide | 71 | %span.update-failed.cred.hide |
| 72 | - %i.icon-ok | 72 | + %i.icon-remove |
| 73 | Failed | 73 | Failed |
| 74 | %ul.cred | 74 | %ul.cred |
| 75 | %li It will change web url for personal projects. | 75 | %li It will change web url for personal projects. |
features/steps/project/project_milestones.rb
| @@ -50,12 +50,12 @@ class ProjectMilestones < Spinach::FeatureSteps | @@ -50,12 +50,12 @@ class ProjectMilestones < Spinach::FeatureSteps | ||
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | Then "I should see 3 issues" do | 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 | end | 55 | end |
| 56 | 56 | ||
| 57 | Then "I should see 4 issues" do | 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 | end | 60 | end |
| 61 | end | 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 | +] |