Remove config.cookies settings (#1086)

These have been moved to `config.actions.cookies`
This commit is contained in:
Tim Riley 2020-11-22 21:03:59 +11:00 committed by GitHub
parent b5e4625f0e
commit 4376237be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 61 deletions

View File

@ -13,7 +13,6 @@ module Hanami
#
# rubocop:disable Metrics/ClassLength
class Configuration
require_relative "configuration/cookies"
require_relative "configuration/middleware"
require_relative "configuration/router"
require_relative "configuration/sessions"
@ -39,7 +38,6 @@ module Hanami
self.logger = DEFAULT_LOGGER.clone
self.rack_logger_filter_params = DEFAULT_RACK_LOGGER_FILTER_PARAMS.clone
self.cookies = DEFAULT_COOKIES
self.sessions = DEFAULT_SESSIONS
self.router = Router.new(base_url)
@ -182,14 +180,6 @@ module Hanami
settings.fetch(:router)
end
def cookies=(options)
settings[:cookies] = Cookies.new(options)
end
def cookies
settings.fetch(:cookies)
end
def sessions=(*args)
settings[:sessions] = Sessions.new(args)
end
@ -257,9 +247,6 @@ module Hanami
DEFAULT_SETTINGS_PATH = File.join("config", "settings")
private_constant :DEFAULT_SETTINGS_PATH
DEFAULT_COOKIES = Cookies.null
private_constant :DEFAULT_COOKIES
DEFAULT_SESSIONS = Sessions.null
private_constant :DEFAULT_SESSIONS

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
module Hanami
class Configuration
# Hanami configuration for HTTP cookies
#
# @since 2.0.0
class Cookies
def self.null
{ null: true }
end
attr_reader :options
def initialize(options)
@options = options
end
def enabled?
options != self.class.null
end
end
end
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
RSpec.describe Hanami::Application do
describe ".config.cookies" do
it "returns default" do
app = Class.new(described_class)
subject = app.config.cookies
expect(subject).to be_kind_of(Hanami::Configuration::Cookies)
expect(subject.enabled?).to be(false)
end
it "returns set value" do
app = Class.new(described_class) do
config.cookies = { max_age: 300 }
end
subject = app.config.cookies
expect(subject).to be_kind_of(Hanami::Configuration::Cookies)
expect(subject.enabled?).to be(true)
expect(subject.options).to eq(max_age: 300)
end
end
end