From 540254def4008db69562f5c04f07721bf2ec3f5d Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 5 Jun 2025 09:12:07 +0200 Subject: [PATCH] Fix tests after removing the index action The show action makes more sense in the controller. Also, the filter scoped was failing due to Rails raising on missing actions (because we have deleted the index action). Inlining the concern fixes it and clarifies where this action is implemented. --- app/controllers/concerns/user_timeline_scoped.rb | 12 ------------ app/controllers/users_controller.rb | 6 +++++- test/controllers/users_controller_test.rb | 8 -------- 3 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 app/controllers/concerns/user_timeline_scoped.rb diff --git a/app/controllers/concerns/user_timeline_scoped.rb b/app/controllers/concerns/user_timeline_scoped.rb deleted file mode 100644 index 6e46ce8d1..000000000 --- a/app/controllers/concerns/user_timeline_scoped.rb +++ /dev/null @@ -1,12 +0,0 @@ -module UserTimelineScoped - extend ActiveSupport::Concern - - included do - include FilterScoped - end - - def show - @filter = Current.user.filters.new(creator_ids: [ @user.id ]) - @day_timeline = Current.user.timeline_for(Time.current, filter: @filter) - end -end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 92839b3e5..82b46b9a3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,4 @@ class UsersController < ApplicationController - include UserTimelineScoped require_unauthenticated_access only: %i[ new create ] before_action :set_user, only: %i[ show edit update destroy ] @@ -19,6 +18,11 @@ class UsersController < ApplicationController def edit end + def show + @filter = Current.user.filters.new(creator_ids: [ @user.id ]) + @day_timeline = Current.user.timeline_for(Time.current, filter: @filter) + end + def update @user.update! user_params redirect_to @user diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index fad78128f..33a1fc096 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -1,14 +1,6 @@ require "test_helper" class UsersControllerTest < ActionDispatch::IntegrationTest - test "index" do - sign_in_as :kevin - - get users_path - assert_in_body users(:david).name - assert_in_body users(:kevin).name - end - test "new" do get new_user_path(params: { join_code: "bad" }) assert_response :forbidden