Skip to content

Commit

Permalink
Updated to devise 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remomueller committed Jul 26, 2016
1 parent 8cd87eb commit 8c15e75
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
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

# 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
Expand All @@ -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
Expand Down

0 comments on commit 8c15e75

Please sign in to comment.