Skip to content

Commit

Permalink
Deprecate require_ssl config
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed May 21, 2020
1 parent 5a65080 commit 71770c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/alchemy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def show
def deprecated_configs
{
url_nesting: true,
require_ssl: nil,
}
end

Expand Down
4 changes: 3 additions & 1 deletion lib/alchemy/ssl_protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def ssl_required?

# Redirects current request to https.
def enforce_ssl
redirect_to url_for(request.params.merge(protocol: 'https'))
redirect_to url_for(request.params.merge(protocol: "https"))
end

deprecate :enforce_ssl, deprecator: Alchemy::Deprecation
end
end
11 changes: 3 additions & 8 deletions spec/libraries/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ module Alchemy

context "if config is deprecated" do
context "without a new default" do
before do
expect(described_class).to receive(:deprecated_configs).at_least(:once) do
{ url_nesting: nil }
end
end

it "warns" do
expect(Alchemy::Deprecation).to receive(:warn)
Config.get(:url_nesting)
expect(Alchemy::Deprecation).to \
receive(:warn).with("require_ssl configuration is deprecated and will be removed from Alchemy 5.0")
Config.get(:require_ssl)
end
end

Expand Down

0 comments on commit 71770c8

Please sign in to comment.