Files
fizzy/test/controllers/users/avatars_controller_test.rb
T
Stanko K.R. fe909d6dc5 Disable stale while revalidate for own avatar
Locally, having stale_while_revalidate works great, but in production when we are behind CloudFlare, this results in an old image being shown after you upload a new one

See: https://app.fizzy.do/5986089/cards/2978
2025-11-21 19:26:38 +01:00

31 lines
815 B
Ruby

require "test_helper"
class Users::AvatarsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :david
end
test "show self without caching" do
get user_avatar_path(users(:david))
assert_match "image/svg+xml", @response.content_type
assert @response.cache_control[:private]
assert_equal "0", @response.cache_control[:max_age]
end
test "show other with caching" do
get user_avatar_path(users(:kevin))
assert_match "image/svg+xml", @response.content_type
assert_equal 30.minutes.to_s, @response.cache_control[:max_age]
end
test "delete self" do
delete user_avatar_path(users(:david))
assert_redirected_to users(:david)
end
test "unable to delete other" do
delete user_avatar_path(users(:kevin))
assert_response :forbidden
end
end