diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-06-01 00:09:17 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-31 17:09:17 +0200 |
commit | 41fa53253c09f70f4830e10b86d51d5dfb0b5fa9 (patch) | |
tree | b294335ce2c883d05f5dd79234270b1b5fe83acd | |
parent | c00ead8a72dd738013b8a132eff7de4959e59670 (diff) |
Keep ENV['LOCAL_HTTPS'] with ApplicationControllerSpec (fix random fail) (#3479)
* Keep ENV['LOCAL_HTTPS'] with ApplicationControllerSpec (fix random fail)
* use climate_control
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 1 | ||||
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/features/log_in_spec.rb | 9 |
4 files changed, 18 insertions, 11 deletions
@@ -70,6 +70,7 @@ end group :test do gem 'capybara', '~> 2.14' + gem 'climate_control', '~> 0.2' gem 'faker', '~> 1.7' gem 'microformats2', '~> 3.0' gem 'rails-controller-testing', '~> 1.0' diff --git a/Gemfile.lock b/Gemfile.lock index eeb7a4a8d4f..23b99895fcd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -487,6 +487,7 @@ DEPENDENCIES capistrano-yarn (~> 2.0) capybara (~> 2.14) cld3 (~> 3.1) + climate_control (~> 0.2) devise (~> 4.2) devise-two-factor (~> 3.0) doorkeeper (~> 4.2) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1b209feb50e..83ec02401d9 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -39,18 +39,20 @@ describe ApplicationController, type: :controller do it "does not force ssl if LOCAL_HTTPS is not 'true'" do routes.draw { get 'success' => 'anonymous#success' } - ENV['LOCAL_HTTPS'] = '' - allow(Rails.env).to receive(:production?).and_return(true) - get 'success' - expect(response).to have_http_status(: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 end it "forces ssl if LOCAL_HTTPS is 'true'" do routes.draw { get 'success' => 'anonymous#success' } - ENV['LOCAL_HTTPS'] = 'true' - allow(Rails.env).to receive(:production?).and_return(true) - get 'success' - expect(response).to redirect_to('https://test.host/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 end describe 'helper_method :current_account' do diff --git a/spec/features/log_in_spec.rb b/spec/features/log_in_spec.rb index f9c222b60ec..6dc3cd2f4ea 100644 --- a/spec/features/log_in_spec.rb +++ b/spec/features/log_in_spec.rb @@ -1,11 +1,14 @@ require "rails_helper" feature "Log in" do - scenario "A valid email and password user is able to log in" do - email = "test@example.com" - password = "password" + given(:email) { "test@examle.com" } + given(:password) { "password" } + + background do Fabricate(:user, email: email, password: password) + end + scenario "A valid email and password user is able to log in" do visit new_user_session_path fill_in "user_email", with: email fill_in "user_password", with: password |