logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 1d92b90be9f494d90a6f79f53be9cca68562867e
parent: da809f9eec45cdac0fa31ba89df91cd4ce4a5398
Author: Yamagishi Kazutoshi <ykzts@desire.sh>
Date:   Sun,  7 Jan 2018 23:19:23 +0900

Fix force_ssl conditional (#6201)


Diffstat:

Mapp/controllers/application_controller.rb2+-
Mspec/controllers/application_controller_spec.rb20++++++++------------
Mspec/rails_helper.rb2+-
3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb @@ -30,7 +30,7 @@ class ApplicationController < ActionController::Base private def https_enabled? - Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true' + Rails.env.production? end def store_current_location diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb @@ -47,22 +47,18 @@ describe ApplicationController, type: :controller do include_examples 'respond_with_error', 422 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' } - ClimateControl.modify LOCAL_HTTPS: '' do - allow(Rails.env).to receive(:production?).and_return(true) - get 'success' - expect(response).to have_http_status(:success) - end + allow(Rails.env).to receive(:production?).and_return(false) + get 'success' + expect(response).to have_http_status(:success) 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' } - ClimateControl.modify LOCAL_HTTPS: 'true' do - allow(Rails.env).to receive(:production?).and_return(true) - get 'success' - expect(response).to redirect_to('https://test.host/success') - end + allow(Rails.env).to receive(:production?).and_return(true) + get 'success' + expect(response).to redirect_to('https://test.host/success') end describe 'helper_method :current_account' do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb @@ -46,7 +46,7 @@ RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers 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')}" end