Update reserved words (#1035)
* Update reserved words and add test * Update user_spec * Remove unreliable spec
This commit is contained in:
parent
b5446e18f3
commit
e1fd5b38ba
3 changed files with 254 additions and 253 deletions
|
|
@ -59,8 +59,7 @@ class User < ApplicationRecord
|
|||
uniqueness: { case_sensitive: false },
|
||||
format: { with: /\A[a-zA-Z0-9_]+\Z/ },
|
||||
length: { in: 2..30 },
|
||||
exclusion: { in: ReservedWords.all,
|
||||
message: "%{value} is reserved." }
|
||||
exclusion: { in: ReservedWords.all, message: "username is reserved" }
|
||||
validates :twitter_username, uniqueness: { allow_blank: true }
|
||||
validates :github_username, uniqueness: { allow_blank: true }
|
||||
validates :text_color_hex, format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_blank: true
|
||||
|
|
|
|||
|
|
@ -1,233 +1,233 @@
|
|||
class ReservedWords
|
||||
BASE_WORDS = [
|
||||
"enter",
|
||||
"internal",
|
||||
"signout_confirm",
|
||||
"notifications",
|
||||
"search",
|
||||
"feedback_messages",
|
||||
"api",
|
||||
"delayed_job_admin",
|
||||
"users",
|
||||
"settings",
|
||||
"about",
|
||||
"additional_content_boxes",
|
||||
"features",
|
||||
"reports",
|
||||
"privacy",
|
||||
"terms",
|
||||
"readinglist",
|
||||
"videos",
|
||||
"video_states",
|
||||
"twilio_tokens",
|
||||
"latest",
|
||||
"contact",
|
||||
"merch",
|
||||
"onboarding_update",
|
||||
"rlygenerator",
|
||||
"orlygenerator",
|
||||
"rlyslack",
|
||||
"rlyweb",
|
||||
"rly",
|
||||
"pusher",
|
||||
"connect",
|
||||
"chat_channels",
|
||||
"email_subscriptions",
|
||||
"social_previews",
|
||||
"code-of-conduct",
|
||||
"report-abuse",
|
||||
"infiniteloop",
|
||||
"faq",
|
||||
"chat",
|
||||
"one-of-us",
|
||||
"swagnets",
|
||||
"security",
|
||||
"phishing",
|
||||
"blocks",
|
||||
"buffered_articles",
|
||||
"tags",
|
||||
"analytics",
|
||||
"reactions",
|
||||
"follows",
|
||||
"csv_exports",
|
||||
"live_articles",
|
||||
"new",
|
||||
"dashboard",
|
||||
"feed",
|
||||
"sedaily",
|
||||
"404",
|
||||
"500",
|
||||
"byte",
|
||||
"bit",
|
||||
"articles",
|
||||
"podcasts",
|
||||
"medium",
|
||||
"bytes",
|
||||
"flip",
|
||||
"membership",
|
||||
"track",
|
||||
"tag",
|
||||
"bits",
|
||||
"binary",
|
||||
"infiniteloop",
|
||||
"loop",
|
||||
"infinite",
|
||||
"forloop",
|
||||
"programming",
|
||||
"dev",
|
||||
"developer",
|
||||
"job",
|
||||
"jobs",
|
||||
"tv",
|
||||
"amp",
|
||||
"live",
|
||||
"online",
|
||||
"jokes",
|
||||
"funny",
|
||||
"funnies",
|
||||
"developertea",
|
||||
"tea",
|
||||
"coffee",
|
||||
"javascript",
|
||||
"java",
|
||||
"ruby",
|
||||
"python",
|
||||
"haskell",
|
||||
"dev",
|
||||
"day",
|
||||
"night",
|
||||
"ons",
|
||||
"daily",
|
||||
"nightly",
|
||||
"changelog",
|
||||
"design",
|
||||
"jobs",
|
||||
"designer",
|
||||
"programming",
|
||||
"programmer",
|
||||
"links",
|
||||
"top",
|
||||
"gigs",
|
||||
"start",
|
||||
"startups",
|
||||
"shoutouts",
|
||||
"about",
|
||||
"merch",
|
||||
"merchandise",
|
||||
"tos",
|
||||
"help",
|
||||
"terms",
|
||||
"privacy",
|
||||
"robots",
|
||||
"ki",
|
||||
"kilo",
|
||||
"kilobyte",
|
||||
"megabyte",
|
||||
"mega",
|
||||
"settings",
|
||||
"account",
|
||||
"dashboard",
|
||||
"dash",
|
||||
"me",
|
||||
"user",
|
||||
"ads",
|
||||
"analytics",
|
||||
"analysis",
|
||||
"advertising",
|
||||
"contact",
|
||||
"legal",
|
||||
"hack",
|
||||
"started",
|
||||
"push_notification_subscriptions",
|
||||
"getting-started",
|
||||
"hackers",
|
||||
"podcast",
|
||||
"pod",
|
||||
"following",
|
||||
"followers",
|
||||
"cast",
|
||||
"pc",
|
||||
"mac",
|
||||
"linux",
|
||||
"github",
|
||||
"opensource",
|
||||
"oss",
|
||||
"software",
|
||||
"live",
|
||||
"articles",
|
||||
"article",
|
||||
"computer",
|
||||
"journal",
|
||||
"joke",
|
||||
"jokes",
|
||||
"gags",
|
||||
"funny",
|
||||
"fun",
|
||||
"gag",
|
||||
"drole",
|
||||
"job_listings",
|
||||
"comment",
|
||||
"comments",
|
||||
"pulse",
|
||||
"pulses",
|
||||
"repos",
|
||||
"repo",
|
||||
"app",
|
||||
"job_applications",
|
||||
"job_application",
|
||||
"kis",
|
||||
"rly",
|
||||
"orly",
|
||||
"orlybooks",
|
||||
"oreilly",
|
||||
"leaders",
|
||||
"leaderboard",
|
||||
"leader",
|
||||
"latest",
|
||||
"things",
|
||||
"iot",
|
||||
"yes",
|
||||
"social",
|
||||
"rails",
|
||||
"angular",
|
||||
"script",
|
||||
"work",
|
||||
"1024",
|
||||
"binary",
|
||||
"retro",
|
||||
"mag",
|
||||
"magazine",
|
||||
"new",
|
||||
"news",
|
||||
"edit",
|
||||
"delete",
|
||||
"update",
|
||||
"destroy",
|
||||
"admin",
|
||||
"administrate",
|
||||
"deep",
|
||||
"machinelearning",
|
||||
"code",
|
||||
"tech",
|
||||
"opensource",
|
||||
"library",
|
||||
"libraries",
|
||||
"anal",
|
||||
"org",
|
||||
"orgs",
|
||||
"organizations",
|
||||
"questions",
|
||||
"answers",
|
||||
"rss",
|
||||
"feed",
|
||||
"sounds",
|
||||
"listen",
|
||||
"ops",
|
||||
"opps",
|
||||
"el",
|
||||
"butt",
|
||||
"fuck",
|
||||
].freeze
|
||||
BASE_WORDS = %w(
|
||||
enter
|
||||
internal
|
||||
signout_confirm
|
||||
notifications
|
||||
search
|
||||
feedback_messages
|
||||
api
|
||||
delayed_job_admin
|
||||
users
|
||||
settings
|
||||
about
|
||||
additional_content_boxes
|
||||
features
|
||||
reports
|
||||
privacy
|
||||
terms
|
||||
readinglist
|
||||
videos
|
||||
video_states
|
||||
twilio_tokens
|
||||
latest
|
||||
contact
|
||||
merch
|
||||
onboarding_update
|
||||
rlygenerator
|
||||
orlygenerator
|
||||
rlyslack
|
||||
rlyweb
|
||||
rly
|
||||
connect
|
||||
chat_channels
|
||||
email_subscriptions
|
||||
social_previews
|
||||
code-of-conduct
|
||||
report-abuse
|
||||
infiniteloop
|
||||
faq
|
||||
chat
|
||||
one-of-us
|
||||
swagnets
|
||||
security
|
||||
phishing
|
||||
blocks
|
||||
buffered_articles
|
||||
tags
|
||||
analytics
|
||||
reactions
|
||||
follows
|
||||
csv_exports
|
||||
live_articles
|
||||
new
|
||||
dashboard
|
||||
feed
|
||||
sedaily
|
||||
404
|
||||
500
|
||||
byte
|
||||
bit
|
||||
articles
|
||||
podcasts
|
||||
medium
|
||||
bytes
|
||||
flip
|
||||
membership
|
||||
track
|
||||
tag
|
||||
bits
|
||||
binary
|
||||
infiniteloop
|
||||
loop
|
||||
infinite
|
||||
forloop
|
||||
programming
|
||||
dev
|
||||
developer
|
||||
job
|
||||
jobs
|
||||
tv
|
||||
amp
|
||||
live
|
||||
online
|
||||
jokes
|
||||
funny
|
||||
funnies
|
||||
developertea
|
||||
tea
|
||||
coffee
|
||||
javascript
|
||||
java
|
||||
ruby
|
||||
python
|
||||
haskell
|
||||
dev
|
||||
day
|
||||
night
|
||||
ons
|
||||
daily
|
||||
nightly
|
||||
changelog
|
||||
design
|
||||
jobs
|
||||
designer
|
||||
programming
|
||||
programmer
|
||||
links
|
||||
top
|
||||
gigs
|
||||
start
|
||||
startups
|
||||
shoutouts
|
||||
about
|
||||
merch
|
||||
merchandise
|
||||
tos
|
||||
help
|
||||
terms
|
||||
privacy
|
||||
robots
|
||||
ki
|
||||
kilo
|
||||
kilobyte
|
||||
megabyte
|
||||
mega
|
||||
settings
|
||||
account
|
||||
dashboard
|
||||
dash
|
||||
me
|
||||
user
|
||||
ads
|
||||
analytics
|
||||
analysis
|
||||
advertising
|
||||
contact
|
||||
legal
|
||||
hack
|
||||
started
|
||||
push_notification_subscriptions
|
||||
getting-started
|
||||
hackers
|
||||
podcast
|
||||
pod
|
||||
following
|
||||
followers
|
||||
cast
|
||||
pc
|
||||
mac
|
||||
linux
|
||||
github
|
||||
opensource
|
||||
oss
|
||||
software
|
||||
live
|
||||
articles
|
||||
article
|
||||
computer
|
||||
journal
|
||||
joke
|
||||
jokes
|
||||
gags
|
||||
funny
|
||||
fun
|
||||
gag
|
||||
drole
|
||||
job_listings
|
||||
comment
|
||||
comments
|
||||
pulse
|
||||
pulses
|
||||
repos
|
||||
repo
|
||||
app
|
||||
job_applications
|
||||
job_application
|
||||
kis
|
||||
rly
|
||||
orly
|
||||
orlybooks
|
||||
oreilly
|
||||
leaders
|
||||
leaderboard
|
||||
leader
|
||||
latest
|
||||
things
|
||||
iot
|
||||
yes
|
||||
social
|
||||
rails
|
||||
angular
|
||||
script
|
||||
work
|
||||
1024
|
||||
binary
|
||||
retro
|
||||
mag
|
||||
magazine
|
||||
new
|
||||
news
|
||||
edit
|
||||
delete
|
||||
update
|
||||
destroy
|
||||
admin
|
||||
administrate
|
||||
deep
|
||||
machinelearning
|
||||
code
|
||||
tech
|
||||
opensource
|
||||
library
|
||||
libraries
|
||||
anal
|
||||
org
|
||||
orgs
|
||||
organizations
|
||||
questions
|
||||
answers
|
||||
rss
|
||||
feed
|
||||
sounds
|
||||
listen
|
||||
ops
|
||||
opps
|
||||
el
|
||||
butt
|
||||
fuck
|
||||
welcome
|
||||
).freeze
|
||||
|
||||
class << self
|
||||
def all
|
||||
|
|
|
|||
|
|
@ -12,28 +12,30 @@ RSpec.describe User, type: :model do
|
|||
|
||||
before { mock_auth_hash }
|
||||
|
||||
it { is_expected.to have_many(:articles) }
|
||||
it { is_expected.to have_many(:badge_achievements).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:badges).through(:badge_achievements) }
|
||||
it { is_expected.to have_many(:collections).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:comments) }
|
||||
it { is_expected.to have_many(:email_messages).class_name("Ahoy::Message") }
|
||||
it { is_expected.to have_many(:identities).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:mentions).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:notes) }
|
||||
it { is_expected.to have_many(:notifications).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:reactions).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:tweets).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:github_repos).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:chat_channel_memberships).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:chat_channels).through(:chat_channel_memberships) }
|
||||
it { is_expected.to have_many(:push_notification_subscriptions).dependent(:destroy) }
|
||||
it { is_expected.to validate_uniqueness_of(:username).case_insensitive }
|
||||
it { is_expected.to validate_uniqueness_of(:github_username).allow_blank }
|
||||
it { is_expected.to validate_uniqueness_of(:twitter_username).allow_blank }
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
it { is_expected.to validate_length_of(:username).is_at_most(30).is_at_least(2) }
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(100) }
|
||||
describe "validations" do
|
||||
it { is_expected.to have_many(:articles) }
|
||||
it { is_expected.to have_many(:badge_achievements).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:badges).through(:badge_achievements) }
|
||||
it { is_expected.to have_many(:collections).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:comments) }
|
||||
it { is_expected.to have_many(:email_messages).class_name("Ahoy::Message") }
|
||||
it { is_expected.to have_many(:identities).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:mentions).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:notes) }
|
||||
it { is_expected.to have_many(:notifications).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:reactions).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:tweets).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:github_repos).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:chat_channel_memberships).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:chat_channels).through(:chat_channel_memberships) }
|
||||
it { is_expected.to have_many(:push_notification_subscriptions).dependent(:destroy) }
|
||||
it { is_expected.to validate_uniqueness_of(:username).case_insensitive }
|
||||
it { is_expected.to validate_uniqueness_of(:github_username).allow_blank }
|
||||
it { is_expected.to validate_uniqueness_of(:twitter_username).allow_blank }
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
it { is_expected.to validate_length_of(:username).is_at_most(30).is_at_least(2) }
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(100) }
|
||||
end
|
||||
|
||||
# the followings are failing
|
||||
# it { is_expected.to have_many(:keys) }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue