mirror of
https://github.com/iv-org/invidious.git
synced 2025-10-24 09:48:31 -05:00
35 lines
775 B
Crystal
35 lines
775 B
Crystal
require "./spec_helper"
|
|
|
|
class ContextWithPreferences < HTTP::Server::Context
|
|
property preferences : Preferences?
|
|
|
|
def get(key : String)
|
|
return preferences if key == "preferences"
|
|
|
|
super
|
|
end
|
|
|
|
def get?(key : String)
|
|
return preferences if key == "preferences"
|
|
|
|
super
|
|
end
|
|
|
|
def set(key : String, val : Preferences)
|
|
if key == "preferences"
|
|
self.preferences = val
|
|
else
|
|
super
|
|
end
|
|
end
|
|
end
|
|
|
|
def test_env(current_url : String, request_method : String = "GET", response : IO = String::Builder.new)
|
|
con = ContextWithPreferences.new(
|
|
HTTP::Request.new(request_method, current_url),
|
|
HTTP::Server::Response.new(response),
|
|
)
|
|
con.preferences = Preferences.new(CONFIG.default_user_preferences.to_tuple)
|
|
con
|
|
end
|