-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ユーザーIDを3文字以上に限定する(n > 1) #6443
ユーザーIDを3文字以上に限定する(n > 1) #6443
Changes from all commits
f808096
403c438
805ba72
5d9a597
b2a26d7
5121bd7
d9407e9
0941cd4
a3706e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
.a-form-help | ||
p | ||
| 名前(ニックネーム)の読み方をカタカナで入力してください。 | ||
| ビデオチャットなど音声で名前を呼ばれる際は、 | ||
| こちらに登録した名前で呼ばれます。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeUserIdMore3Characters < ActiveRecord::Migration[6.1] | ||
def up | ||
User.where('LENGTH(login_name) < ?', 3).find_each do |user| | ||
user.login_name = user.login_name.ljust(3, '0') | ||
user.save!(validate: false) | ||
end | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
DataMigrate::Data.define(version: 20_230_114_032_018) | ||
DataMigrate::Data.define(version: 20_230_412_211_754) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,7 +170,7 @@ class UserTest < ActiveSupport::TestCase | |
assert user.save(context: :retire_reason_presence) | ||
end | ||
|
||
test 'is valid username' do | ||
test 'login_name' do | ||
user = users(:komagata) | ||
user.login_name = 'abcdABCD1234' | ||
assert user.valid? | ||
|
@@ -196,6 +196,8 @@ class UserTest < ActiveSupport::TestCase | |
assert user.invalid? | ||
user.login_name = '12345' | ||
assert user.invalid? | ||
user.login_name = 'xx' | ||
assert user.invalid? | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここのテストケース、 これもこのPRではスコープ外と思いますしこのままでいいと思いますが、駒形さんに相談して起票するとよいのですかね? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 確かに違和感のある名称ですね。 スコープ外の修正や改善案は基本的には駒形さん、町田さんに相談すると良いですね。 |
||
|
||
test 'twitter_account' do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo]
既存のユーザを更新するときには、
(validate: false)
をつけておく(すでにinvalidなユーザーデータがあるので)参考→#5959 (comment)