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.
This commit is contained in:
Jorge Manrubia
2025-06-05 09:12:07 +02:00
parent de87f4ed6c
commit 540254def4
3 changed files with 5 additions and 21 deletions
@@ -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
+5 -1
View File
@@ -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
@@ -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