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