Skip to content

Commit

Permalink
Merge pull request #4321 from fjordllc/bug/enable-retirement-regardle…
Browse files Browse the repository at this point in the history
…ss-validity-of-twitter-id

Twitter IDが不正でも退会できるように修正
  • Loading branch information
komagata authored Mar 14, 2022
2 parents 6646bcd + a8982cc commit 287525a
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[
Expand Down
4 changes: 4 additions & 0 deletions db/fixtures/talks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ marumarushain<%= i %>: # ページネーション確認のためのユーザー
talk_discordinvalid:
user: discordinvalid
unreplied: false

talk_twitterinvalid:
user: twitterinvalid
unreplied: false
21 changes: 21 additions & 0 deletions db/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions test/fixtures/talks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ talk22:
talk23:
user: discordinvalid
unreplied: false

talk24:
user: twitterinvalid
unreplied: false
21 changes: 21 additions & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/system/retirement_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/system/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class UsersTest < ApplicationSystemTestCase
nippounashi
with_hyphen
discordinvalid
twitterinvalid
].each do |name|
users(name).touch # rubocop:disable Rails/SkipsModelValidations
end
Expand Down

0 comments on commit 287525a

Please sign in to comment.