forked from fedi/mastodon
Fix force_ssl conditional (#6201)
This commit is contained in:
parent
da809f9eec
commit
1d92b90be9
|
@ -30,7 +30,7 @@ class ApplicationController < ActionController::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def https_enabled?
|
def https_enabled?
|
||||||
Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'
|
Rails.env.production?
|
||||||
end
|
end
|
||||||
|
|
||||||
def store_current_location
|
def store_current_location
|
||||||
|
|
|
@ -47,22 +47,18 @@ describe ApplicationController, type: :controller do
|
||||||
include_examples 'respond_with_error', 422
|
include_examples 'respond_with_error', 422
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not force ssl if LOCAL_HTTPS is not 'true'" do
|
it "does not force ssl if Rails.env.production? is not 'true'" do
|
||||||
routes.draw { get 'success' => 'anonymous#success' }
|
routes.draw { get 'success' => 'anonymous#success' }
|
||||||
ClimateControl.modify LOCAL_HTTPS: '' do
|
allow(Rails.env).to receive(:production?).and_return(false)
|
||||||
allow(Rails.env).to receive(:production?).and_return(true)
|
get 'success'
|
||||||
get 'success'
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to have_http_status(:success)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "forces ssl if LOCAL_HTTPS is 'true'" do
|
it "forces ssl if Rails.env.production? is 'true'" do
|
||||||
routes.draw { get 'success' => 'anonymous#success' }
|
routes.draw { get 'success' => 'anonymous#success' }
|
||||||
ClimateControl.modify LOCAL_HTTPS: 'true' do
|
allow(Rails.env).to receive(:production?).and_return(true)
|
||||||
allow(Rails.env).to receive(:production?).and_return(true)
|
get 'success'
|
||||||
get 'success'
|
expect(response).to redirect_to('https://test.host/success')
|
||||||
expect(response).to redirect_to('https://test.host/success')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'helper_method :current_account' do
|
describe 'helper_method :current_account' do
|
||||||
|
|
|
@ -46,7 +46,7 @@ RSpec.configure do |config|
|
||||||
config.include ActiveSupport::Testing::TimeHelpers
|
config.include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
config.before :each, type: :feature do
|
config.before :each, type: :feature do
|
||||||
https = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
|
https = ENV['LOCAL_HTTPS'] == 'true'
|
||||||
Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}"
|
Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue