validates uniqueness of username 😭
This commit is contained in:
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
|
|||||||
has_many :comments, -> { with_hidden }
|
has_many :comments, -> { with_hidden }
|
||||||
|
|
||||||
validates :username, presence: true, unless: :organization?
|
validates :username, presence: true, unless: :organization?
|
||||||
|
validates :username, uniqueness: true, unless: :organization?
|
||||||
validates :official_level, inclusion: {in: 0..5}
|
validates :official_level, inclusion: {in: 0..5}
|
||||||
validates_format_of :email, without: OMNIAUTH_EMAIL_REGEX, on: :update
|
validates_format_of :email, without: OMNIAUTH_EMAIL_REGEX, on: :update
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
username 'Manuela'
|
sequence(:username) { |n| "Manuela#{n}" }
|
||||||
sequence(:email) { |n| "manuela#{n}@madrid.es" }
|
sequence(:email) { |n| "manuela#{n}@madrid.es" }
|
||||||
password 'judgmentday'
|
password 'judgmentday'
|
||||||
confirmed_at { Time.now }
|
confirmed_at { Time.now }
|
||||||
|
|
||||||
trait :hidden do
|
trait :hidden do
|
||||||
hidden_at Time.now
|
hidden_at Time.now
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ feature 'Comments' do
|
|||||||
|
|
||||||
expect(page).to have_css('.comment', count: 3)
|
expect(page).to have_css('.comment', count: 3)
|
||||||
|
|
||||||
comment = Comment.first
|
comment = Comment.last
|
||||||
within first('.comment') do
|
within first('.comment') do
|
||||||
expect(page).to have_content comment.user.name
|
expect(page).to have_content comment.user.name
|
||||||
expect(page).to have_content time_ago_in_words(comment.created_at)
|
expect(page).to have_content time_ago_in_words(comment.created_at)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module CommonActions
|
|||||||
visit '/'
|
visit '/'
|
||||||
click_link 'Sign up'
|
click_link 'Sign up'
|
||||||
|
|
||||||
fill_in 'user_username', with: 'Manuela Carmena'
|
fill_in 'user_username', with: "Manuela Carmena #{rand(99999)}"
|
||||||
fill_in 'user_email', with: email
|
fill_in 'user_email', with: email
|
||||||
fill_in 'user_password', with: password
|
fill_in 'user_password', with: password
|
||||||
fill_in 'user_password_confirmation', with: password
|
fill_in 'user_password_confirmation', with: password
|
||||||
|
|||||||
Reference in New Issue
Block a user