From b55fa8f179828a393be0ce74ee5b3b5ae6f70539 Mon Sep 17 00:00:00 2001 From: kinoppyd Date: Sat, 21 Dec 2024 00:35:39 +0900 Subject: [PATCH] Obey rubocop --- app/controllers/plans_controller.rb | 2 +- config/routes.rb | 2 +- test/controllers/items_controller_test.rb | 24 +++++++++++++++-------- test/controllers/plans_controller_test.rb | 7 +++++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index c864287..4d12dff 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -60,7 +60,7 @@ def add_plan(id) end def check_user_owns_plan - render status: :bad_request, body: nil if @plan.nil? + render status: :bad_request, body: nil if @plan.nil? render status: :forbidden, body: nil unless @user.plans.include?(@plan) end diff --git a/config/routes.rb b/config/routes.rb index fd369bb..35b8da2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,7 @@ resources :items, only: %i[update destroy] end - resolve('PlanSchedule') { [:event, :item] } + resolve('PlanSchedule') { %i[event item] } resources :teams, except: :index do resources :members, only: %i[create update destroy] diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb index ce1dce5..106ff20 100644 --- a/test/controllers/items_controller_test.rb +++ b/test/controllers/items_controller_test.rb @@ -10,28 +10,32 @@ def setup test 'Add new item to plan' do assert_difference('PlanSchedule.count', 1) do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:six).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:six).id } end assert_redirected_to event_plan_path(plans(:one), event_name: events(:party).name) end test 'Add new item to plan with turbo frames' do assert_difference('PlanSchedule.count', 1) do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:six).id }, as: :turbo_stream + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:six).id }, as: :turbo_stream end assert_response :ok end test 'Reject add new item to plan when crossover item has exists' do assert_no_difference('PlanSchedule.count') do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:one_crossover).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:one_crossover).id } end assert_redirected_to event_plan_path(plans(:one), event_name: events(:party).name) end test 'Reject add new item to plan when crossover item has exists with turbo frames' do assert_no_difference('PlanSchedule.count') do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:one_crossover).id }, as: :turbo_stream + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:one_crossover).id }, as: :turbo_stream end assert_redirected_to event_plan_path(plans(:one), event_name: events(:party).name) end @@ -41,7 +45,8 @@ def setup plan.initial = true plan.save! - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:six).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:six).id } plan.reload assert_not plan.initial @@ -52,7 +57,8 @@ def setup plan.initial = true plan.save! - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:one_crossover).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:one_crossover).id } plan.reload assert plan.initial @@ -60,14 +66,16 @@ def setup test 'Reject add item to plan when item is not belongs to event' do assert_no_difference('PlanSchedule.count') do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), params: { schedule_id: schedules(:dojo_one).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:one).id), + params: { schedule_id: schedules(:dojo_one).id } end assert_response :not_found end test 'Reject add new item to plan that not owned' do assert_no_difference('PlanSchedule.count') do - post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:two).id), params: { schedule_id: schedules(:six).id } + post event_plan_items_url(event_name: events(:party).name, plan_id: plans(:two).id), + params: { schedule_id: schedules(:six).id } end assert_response :forbidden end diff --git a/test/controllers/plans_controller_test.rb b/test/controllers/plans_controller_test.rb index 19fdb36..3ed5917 100644 --- a/test/controllers/plans_controller_test.rb +++ b/test/controllers/plans_controller_test.rb @@ -20,7 +20,8 @@ def setup test 'Create plan' do assert_difference('Plan.count') do - post event_plans_path(event_name: events(:dojo).name), params: { plan: { title: 'test', description: 'test', public: true, initial: false } } + post event_plans_path(event_name: events(:dojo).name), + params: { plan: { title: 'test', description: 'test', public: true, initial: false } } end assert_redirected_to event_schedules_path(event_name: events(:dojo).name) @@ -28,7 +29,9 @@ def setup test 'Create plan with first item' do assert_difference('PlanSchedule.count') do - post event_plans_path(event_name: events(:dojo).name), params: { plan: { title: 'test', description: 'test', public: true, initial: false, add_schedule_id: schedules(:dojo_one).id }} + post event_plans_path(event_name: events(:dojo).name), + params: { plan: { title: 'test', description: 'test', public: true, initial: false, + add_schedule_id: schedules(:dojo_one).id } } end assert_redirected_to event_schedules_path(event_name: events(:dojo).name)