diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da6a27de..87819d258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Users are now redirected back to the forum if signing in after visiting a forum page - **Gem Changes** + - Updated to devise 4.2.0 - Updated to simplecov 0.12.0 - Updated to colorize 0.8.1 diff --git a/Gemfile b/Gemfile index 3c5d5320b..356e0d1fe 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'rails', '4.2.6' gem 'pg', '0.18.4' # Gems used by project -gem 'devise', '~> 4.1.0' # Authentication +gem 'devise', '~> 4.2.0' # Authentication gem 'kaminari', '~> 0.17.0' # Pagination gem 'carrierwave', '~> 0.11.0' # File Uploads gem 'mini_magick' # Image Resizing diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index cb86b1db2..23d2dcd15 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -50,7 +50,11 @@ def accepts_terms_of_access end def accepts_update - (current_user.provider? or current_user.is_only_researcher?) ? current_user.accepts_terms_of_access! : current_user.accepts_consent! + if current_user.provider? || current_user.is_only_researcher? + current_user.accepts_terms_of_access! + else + current_user.accepts_consent! + end redirect_to (session[:return_to] || root_path) end @@ -61,7 +65,7 @@ def accepts_terms_and_conditions def revoke_consent current_user.revoke_consent! - redirect_to root_path, notice: "You have successfully left the research study portion of MyApnea.Org. If you ever change your mind, just visit your account settings to view the research consent and privacy policy again." + redirect_to root_path, notice: 'You have successfully left the research study portion of MyApnea.Org. If you ever change your mind, just visit your account settings to view the research consent and privacy policy again.' end ## Content for consent, privacy, and terms of access @@ -115,21 +119,21 @@ def update else respond_to do |format| format.js - format.all { redirect_to account_path, notice: "Your account settings have been successfully changed." } + format.all { redirect_to account_path, notice: 'Your account settings have been successfully changed.' } end end else - render "account" + render :account end end def change_password if current_user.update_with_password(user_password_params) # Sign in the user by passing validation in case the user's password changed - sign_in current_user, bypass: true - redirect_to account_path, notice: "Your password has been changed." + bypass_sign_in current_user + redirect_to account_path, notice: 'Your password has been changed.' else - render "account" + render :account end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 063bacceb..73bbabf15 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,6 +7,7 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +# Set up ActiveSupport tests class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all @@ -14,15 +15,17 @@ class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... end +# Set up ActionController tests class ActionController::TestCase - include Devise::TestHelpers + include Devise::Test::ControllerHelpers def login(resource) @request.env['devise.mapping'] = Devise.mappings[resource] - sign_in(resource.class.name.downcase.to_sym, resource) + sign_in(resource, scope: resource.class.name.downcase.to_sym) end end +# Set up ActionDispatch tests class ActionDispatch::IntegrationTest def sign_in_as(user, password) user.update password: password, password_confirmation: password @@ -33,6 +36,7 @@ def sign_in_as(user, password) module Rack module Test + # Allow files to be uploaded in tests class UploadedFile attr_reader :tempfile end