diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1fcb8ecb50f..bd2e968c469 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -33,13 +33,3 @@ Style/HashSyntax: - 'test/models/category_test.rb' - 'test/models/discord/times_channel_test.rb' - 'test/models/event_test.rb' - - 'test/models/product_test.rb' - - 'test/models/question_test.rb' - - 'test/models/regular_event/participants_creator.rb' - - 'test/models/regular_event/participants_watcher_test.rb' - - 'test/models/regular_event_test.rb' - - 'test/models/user_test.rb' - - 'test/notifiers/discord_notifier_test.rb' - - 'test/supports/api_helper.rb' - - 'test/supports/tag_helper.rb' - - 'test/system/announcements_test.rb' diff --git a/test/models/product_test.rb b/test/models/product_test.rb index a528a59324e..462da78928a 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -6,7 +6,7 @@ class ProductTest < ActiveSupport::TestCase test 'delete associated notification' do user = users(:kimura) practice = practices(:practice5) - product = Product.create!(practice: practice, user: user, body: 'test') + product = Product.create!(practice:, user:, body: 'test') product.destroy assert_not Notification.where(link: "/products/#{product.id}").exists? end @@ -18,7 +18,7 @@ class ProductTest < ActiveSupport::TestCase product = Product.new( body: 'test', user: trainee, - practice: practice + practice: ) product.save! assert_not_nil Watch.find_by(user: adviser, watchable: product) @@ -31,7 +31,7 @@ class ProductTest < ActiveSupport::TestCase product = Product.new( body: 'test', user: trainee, - practice: practice, + practice:, wip: true ) product.save! @@ -49,13 +49,13 @@ class ProductTest < ActiveSupport::TestCase practice = practices(:practice5) product = Product.create!( body: 'test', - user: user, - practice: practice + user:, + practice: ) status = :complete product.change_learning_status(status) - assert Learning.find_by(user: user, practice: practice, status: :complete) + assert Learning.find_by(user:, practice:, status: :complete) end test '#category' do diff --git a/test/models/question_test.rb b/test/models/question_test.rb index 280b649f6e9..5bcbe73065c 100644 --- a/test/models/question_test.rb +++ b/test/models/question_test.rb @@ -17,7 +17,7 @@ class QuestionTest < ActiveSupport::TestCase first_answer = Answer.create!( description: '最初の回答', user: answerer, - question: question, + question:, created_at: '2022-11-01', updated_at: '2022-11-01' ) @@ -25,7 +25,7 @@ class QuestionTest < ActiveSupport::TestCase last_answer = Answer.create!( description: '最後の回答', user: answerer, - question: question, + question:, created_at: '2022-11-02', updated_at: '2022-11-02' ) diff --git a/test/models/regular_event/participants_creator.rb b/test/models/regular_event/participants_creator.rb index b2ac90769ea..8301785932b 100644 --- a/test/models/regular_event/participants_creator.rb +++ b/test/models/regular_event/participants_creator.rb @@ -6,7 +6,7 @@ class ParticipantsCreatorTest < ActiveSupport::TestCase test '.call' do regular_event = regular_events(:regular_event3) target = User.students_and_trainees.ids - RegularEvent::ParticipantsCreator.call(regular_event: regular_event, target: target) + RegularEvent::ParticipantsCreator.call(regular_event:, target:) assert_equal regular_event.regular_event_participations.count, target.count end @@ -15,7 +15,7 @@ class ParticipantsCreatorTest < ActiveSupport::TestCase regular_event = regular_events(:regular_event3) target = User.students_and_trainees.ids date_time = Time.current.end_of_day.floor - RegularEvent::ParticipantsCreator.call(regular_event: regular_event, target: target, date_time: date_time) + RegularEvent::ParticipantsCreator.call(regular_event:, target:, date_time:) assert_equal regular_event.regular_event_participations.count, target.count assert_equal regular_event.regular_event_participations.first.created_at, date_time diff --git a/test/models/regular_event/participants_watcher_test.rb b/test/models/regular_event/participants_watcher_test.rb index b65e3452c96..7e7ee5aba28 100644 --- a/test/models/regular_event/participants_watcher_test.rb +++ b/test/models/regular_event/participants_watcher_test.rb @@ -6,7 +6,7 @@ class ParticipantsWatcherTest < ActiveSupport::TestCase test '.call' do regular_event = regular_events(:regular_event3) target = User.students_and_trainees.ids - regular_event.watches.pluck(:user_id) - RegularEvent::ParticipantsWatcher.call(regular_event: regular_event, target: target) + RegularEvent::ParticipantsWatcher.call(regular_event:, target:) assert_equal regular_event.watches.count, target.count end @@ -15,7 +15,7 @@ class ParticipantsWatcherTest < ActiveSupport::TestCase regular_event = regular_events(:regular_event3) target = User.students_and_trainees.ids - regular_event.watches.pluck(:user_id) date_time = Time.current.end_of_day.floor - RegularEvent::ParticipantsWatcher.call(regular_event: regular_event, target: target, date_time: date_time) + RegularEvent::ParticipantsWatcher.call(regular_event:, target:, date_time:) assert_equal regular_event.watches.count, target.count assert_equal regular_event.watches.first.created_at, date_time diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index e48b0d28a50..e2282ce99e0 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -118,7 +118,7 @@ class RegularEventTest < ActiveSupport::TestCase user = users(:kimura) assert_not regular_event.watched_by?(user) - watch = Watch.new(user: user, watchable: regular_event) + watch = Watch.new(user:, watchable: regular_event) watch.save assert regular_event.watched_by?(user) end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 59f4e766029..2dab74ac546 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -385,7 +385,7 @@ class UserTest < ActiveSupport::TestCase today = Time.zone.today Learning.create!( - user: user, + user:, practice: practice1, status: :complete, created_at: (today - 2.weeks).to_formatted_s(:db), @@ -393,7 +393,7 @@ class UserTest < ActiveSupport::TestCase ) Learning.create!( - user: user, + user:, practice: practice2, status: :complete, created_at: (today - (2.weeks + 1.day)).to_formatted_s(:db), @@ -411,7 +411,7 @@ class UserTest < ActiveSupport::TestCase today = Time.zone.today Learning.create!( - user: user, + user:, practice: Practice.first, status: :complete, created_at: (today - (2.weeks - 1.day)).to_formatted_s(:db), @@ -429,7 +429,7 @@ class UserTest < ActiveSupport::TestCase today = Time.zone.today Learning.create!( - user: user, + user:, practice: practice1, status: :complete, created_at: (today - 2.weeks).to_formatted_s(:db), @@ -680,26 +680,26 @@ class UserTest < ActiveSupport::TestCase allowed_targets = %w[student_and_trainee mentor graduate adviser trainee year_end_party] # target引数とdefault_target引数に関して、targetとscope名が一致しているケースと一致していないケースを順にテストする - assert_equal User.mentor, User.users_role('mentor', allowed_targets: allowed_targets, default_target: 'student_and_trainee') - assert_equal User.graduated, User.users_role('graduate', allowed_targets: allowed_targets, default_target: 'student_and_trainee') + assert_equal User.mentor, User.users_role('mentor', allowed_targets:, default_target: 'student_and_trainee') + assert_equal User.graduated, User.users_role('graduate', allowed_targets:, default_target: 'student_and_trainee') - assert_equal User.year_end_party, User.users_role('', allowed_targets: allowed_targets, default_target: 'year_end_party') - assert_equal User.students_and_trainees, User.users_role('', allowed_targets: allowed_targets, default_target: 'student_and_trainee') + assert_equal User.year_end_party, User.users_role('', allowed_targets:, default_target: 'year_end_party') + assert_equal User.students_and_trainees, User.users_role('', allowed_targets:, default_target: 'student_and_trainee') end test '.users_role returns default_target when invalid target is passed' do allowed_targets = %w[student_and_trainee mentor graduate adviser trainee year_end_party] not_allowed_target = 'retired' - assert_equal User.students_and_trainees, User.users_role(not_allowed_target, allowed_targets: allowed_targets, default_target: 'student_and_trainee') + assert_equal User.students_and_trainees, User.users_role(not_allowed_target, allowed_targets:, default_target: 'student_and_trainee') not_scope_name = 'destroy_all' - assert_equal User.students_and_trainees, User.users_role(not_scope_name, allowed_targets: allowed_targets, default_target: 'student_and_trainee') - assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) + assert_equal User.students_and_trainees, User.users_role(not_scope_name, allowed_targets:, default_target: 'student_and_trainee') + assert_empty User.users_role(not_scope_name, allowed_targets:) end test '#delete_and_assign_new_organizer' do user = users(:hajime) - assert_changes -> { Organizer.where(user: user).exists? }, from: true, to: false do + assert_changes -> { Organizer.where(user:).exists? }, from: true, to: false do user.delete_and_assign_new_organizer end end diff --git a/test/notifiers/discord_notifier_test.rb b/test/notifiers/discord_notifier_test.rb index 1985ee2438d..4f8c03edba5 100644 --- a/test/notifiers/discord_notifier_test.rb +++ b/test/notifiers/discord_notifier_test.rb @@ -164,13 +164,13 @@ class DiscordNotifierTest < ActiveSupport::TestCase TEXT params = { - comment: comment, - body: body, + comment:, + body:, webhook_url: 'https://discord.com/api/webhooks/0123456789/xxxxxxxx' } expected = { - body: body, + body:, name: 'ピヨルド', webhook_url: 'https://discord.com/api/webhooks/0123456789/xxxxxxxx' } @@ -225,7 +225,7 @@ class DiscordNotifierTest < ActiveSupport::TestCase URL: http://localhost:3000/reports/819157022 TEXT expected = { - body: body, + body:, name: 'ピヨルド', webhook_url: 'https://discord.com/api/webhooks/0123456789/xxxxxxxx' } diff --git a/test/supports/api_helper.rb b/test/supports/api_helper.rb index 1f5be576110..8c2710f0e4d 100644 --- a/test/supports/api_helper.rb +++ b/test/supports/api_helper.rb @@ -2,7 +2,7 @@ module APIHelper def create_token(login_name, password) - post api_session_url, params: { login_name: login_name, password: password } + post api_session_url, params: { login_name:, password: } JSON.parse(body)['token'] end end diff --git a/test/supports/tag_helper.rb b/test/supports/tag_helper.rb index 00c65b0dfdb..2291994d72e 100644 --- a/test/supports/tag_helper.rb +++ b/test/supports/tag_helper.rb @@ -27,6 +27,6 @@ def find_tags(taggable_name) WHERE taggings.taggable_type = :taggable_name SQL - ActsAsTaggableOn::Tag.find_by_sql([sql, { taggable_name: taggable_name }]).pluck(:name).sort + ActsAsTaggableOn::Tag.find_by_sql([sql, { taggable_name: }]).pluck(:name).sort end end diff --git a/test/system/announcements_test.rb b/test/system/announcements_test.rb index df60a1f6ede..68efefb6d92 100644 --- a/test/system/announcements_test.rb +++ b/test/system/announcements_test.rb @@ -26,7 +26,7 @@ class AnnouncementsTest < ApplicationSystemTestCase user = users(:komagata) Announcement.delete_all 26.times do - Announcement.create(title: 'test', description: 'test', user: user) + Announcement.create(title: 'test', description: 'test', user:) end visit_with_auth '/announcements', 'kimura' assert_selector 'nav.pagination', count: 2 @@ -34,7 +34,7 @@ class AnnouncementsTest < ApplicationSystemTestCase test 'show WIP message' do user = users(:komagata) - Announcement.create(title: 'test', description: 'test', user: user, wip: true) + Announcement.create(title: 'test', description: 'test', user:, wip: true) visit_with_auth '/announcements', 'kimura' assert_selector '.a-list-item-badge' assert_text 'お知らせ作成中'