From 2418e1a825e59f22333a243edc66f3ab2aaa769f Mon Sep 17 00:00:00 2001 From: honda Date: Mon, 28 Feb 2022 15:35:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?model=E3=81=AEtwitter=E3=81=AEvalidates?= =?UTF-8?q?=E9=81=A9=E7=94=A8=E3=81=AE=E6=9D=A1=E4=BB=B6=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ea87f0380f5..f941cd5bb54 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,13 +130,6 @@ class User < ApplicationRecord validates :description, presence: true validates :nda, presence: true validates :password, length: { minimum: 4 }, confirmation: true, if: :password_required? - validates :twitter_account, - length: { maximum: 15 }, - format: { - allow_blank: true, - with: /\A\w+\z/, - message: 'は英文字と_(アンダースコア)のみが使用できます' - } validates :mail_notification, inclusion: { in: [true, false] } validates :github_id, uniqueness: true, allow_nil: true validates :times_url, @@ -187,6 +180,13 @@ class User < ApplicationRecord with: /\A[^\s\p{blank}].*[^\s\p{blank}]#\d{4}\z/, message: 'は「ユーザー名#4桁の数字」で入力してください' } + validates :twitter_account, + length: { maximum: 15 }, + format: { + allow_blank: true, + with: /\A\w+\z/, + message: 'は英文字と_(アンダースコア)のみが使用できます' + } end flag :retire_reasons, %i[ From f36c2a3a303a7bfecf3f29867bf39e21eb8f9f3c Mon Sep 17 00:00:00 2001 From: honda Date: Mon, 28 Feb 2022 22:19:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fixtures/talks.yml | 4 ++++ test/fixtures/users.yml | 21 +++++++++++++++++++++ test/system/retirement_test.rb | 15 +++++++++++++++ test/system/users_test.rb | 1 + 4 files changed, 41 insertions(+) diff --git a/test/fixtures/talks.yml b/test/fixtures/talks.yml index 7d6e547b763..cff285fb0bd 100644 --- a/test/fixtures/talks.yml +++ b/test/fixtures/talks.yml @@ -88,3 +88,7 @@ talk22: talk23: user: discordinvalid unreplied: false + +talk24: + user: twitterinvalid + unreplied: false diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index b8691a7943c..0f8dbc94f5e 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -380,6 +380,27 @@ discordinvalid: #Discord IDが不正なユーザー updated_at: "2014-01-01 00:00:12" created_at: "2014-01-01 00:00:12" +twitterinvalid: #Twitter IDが不正なユーザー + login_name: twitterinvalid + email: twitterinvalid@fjord.jp + crypted_password: $2a$10$n/xv4/1luueN6plzm2OyDezWlZFyGHjQEf4hwAW1r3k.lCm0frPK. # testtest + salt: zW3kQ9ubsxQQtzzzs4ap + name: ユーザーです Twitter IDが不正 + name_kana: ツイッター フセイ + discord_account: twitterinvalid#8888 + github_account: twitterinvalid + twitter_account: twit-ter + times_url: https://discord.com/channels/715806612824260640/123456789000000114 + facebook_url: http://www.facebook.com/twitterinvalid + blog_url: http://twitterinvalid.org + description: "Twitter IDが不正なユーザーです" + course: course1 + job: office_worker + experience: rails + unsubscribe_email_token: JgunX7Zejd-r1Vhqev401w + updated_at: "2020-01-01 00:00:12" + created_at: "2020-01-01 00:00:12" + jobseeker: #就活希望するユーザー login_name: jobseeker email: jobseeker@fjord.jp diff --git a/test/system/retirement_test.rb b/test/system/retirement_test.rb index 2e3dd2e1266..90a3a435dd1 100644 --- a/test/system/retirement_test.rb +++ b/test/system/retirement_test.rb @@ -46,6 +46,21 @@ class RetirementTest < ApplicationSystemTestCase assert_text 'ログインができません' end + test 'enables retirement regardless of validity of twitter id' do + user = users(:twitterinvalid) + visit_with_auth new_retirement_path, 'twitterinvalid' + choose 'とても悪い', visible: false + click_on '退会する' + page.accept_confirm + assert_text '退会処理が完了しました' + assert_equal Date.current, user.reload.retired_on + assert_equal 'twitterinvalidさんが退会しました。', users(:komagata).notifications.last.message + assert_equal 'twitterinvalidさんが退会しました。', users(:machida).notifications.last.message + + login_user 'twitterinvalid', 'testtest' + assert_text 'ログインができません' + end + test 'delete unchecked products when the user retired' do visit_with_auth "/products/new?practice_id=#{practices(:practice5).id}", 'muryou' within('form[name=product]') do diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 5348469d801..d56e74be6b4 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -117,6 +117,7 @@ class UsersTest < ApplicationSystemTestCase nippounashi with_hyphen discordinvalid + twitterinvalid ].each do |name| users(name).touch # rubocop:disable Rails/SkipsModelValidations end From a8982cc5da9736f338ddb2d0e4c1b790ac608237 Mon Sep 17 00:00:00 2001 From: honda Date: Thu, 10 Mar 2022 18:23:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E7=92=B0=E5=A2=83=E3=81=A7=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=ABdb=20/fix?= =?UTF-8?q?tures=E3=81=AB=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/fixtures/talks.yml | 4 ++++ db/fixtures/users.yml | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/db/fixtures/talks.yml b/db/fixtures/talks.yml index 00910895932..246e29ba3c6 100644 --- a/db/fixtures/talks.yml +++ b/db/fixtures/talks.yml @@ -175,3 +175,7 @@ marumarushain<%= i %>: # ページネーション確認のためのユーザー talk_discordinvalid: user: discordinvalid unreplied: false + +talk_twitterinvalid: + user: twitterinvalid + unreplied: false diff --git a/db/fixtures/users.yml b/db/fixtures/users.yml index 8881b0fc718..93424059da1 100644 --- a/db/fixtures/users.yml +++ b/db/fixtures/users.yml @@ -973,3 +973,24 @@ discordinvalid: #Discord IDが不正なユーザー unsubscribe_email_token: JgunX7Zejd-r1Vhqev401w updated_at: "2014-01-01 00:00:12" created_at: "2014-01-01 00:00:12" + +twitterinvalid: #Twitter IDが不正なユーザー + login_name: twitterinvalid + email: twitterinvalid@fjord.jp + crypted_password: $2a$10$n/xv4/1luueN6plzm2OyDezWlZFyGHjQEf4hwAW1r3k.lCm0frPK. # testtest + salt: zW3kQ9ubsxQQtzzzs4ap + name: ユーザーです Twitter IDが不正 + name_kana: ツイッター フセイ + discord_account: twitterinvalid#8888 + github_account: twitterinvalid + twitter_account: twit-ter + times_url: https://discord.com/channels/715806612824260640/123456789000000114 + facebook_url: http://www.facebook.com/twitterinvalid + blog_url: http://twitterinvalid.org + description: "Twitter IDが不正なユーザーです" + course: course1 + job: office_worker + experience: rails + unsubscribe_email_token: JgunX7Zejd-r1Vhqev401w + updated_at: "2020-01-01 00:00:12" + created_at: "2020-01-01 00:00:12"