Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix force_ssl conditional #6201

Merged
merged 1 commit into from
Jan 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def raise_not_found
private

def https_enabled?
Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'
Rails.env.production?
end

def store_current_location
Expand Down
20 changes: 8 additions & 12 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,18 @@ def invalid_authenticity_token
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
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def sign_in(resource, _deprecated = nil, scope: nil)
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

Expand Down