mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
integration tests for forgot_password [fixes SCI-1576]
This commit is contained in:
parent
b036452d8c
commit
33ebe1f748
8 changed files with 28 additions and 69 deletions
|
@ -6,7 +6,7 @@
|
|||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||
|
||||
<% if not resource.errors.empty? %>
|
||||
<div class="alert alert-danger">
|
||||
<div class="alert alert-danger" id="alert-flash">
|
||||
<%= devise_error_messages! %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||
|
||||
<% if not resource.errors.empty? %>
|
||||
<div class="alert alert-danger">
|
||||
<div class="alert alert-danger" id="alert-flash">
|
||||
<%= devise_error_messages! %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -19,28 +19,31 @@ Rails.application.configure do
|
|||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.default_url_options = {
|
||||
host: Rails.application.secrets.mail_server_url
|
||||
host: Rails.application.secrets.mail_server_url,
|
||||
port: 3001
|
||||
}
|
||||
config.action_mailer.default_options = {
|
||||
from: Rails.application.secrets.mailer_from,
|
||||
reply_to: Rails.application.secrets.mailer_reply_to
|
||||
}
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
|
||||
if ENV['CUCUMBER'] == 'cucumber'
|
||||
config.action_mailer.delivery_method = :test
|
||||
else
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
end
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: Rails.application.secrets.mailer_address,
|
||||
port: Rails.application.secrets.mailer_port,
|
||||
domain: Rails.application.secrets.mailer_domain,
|
||||
authentication: "plain",
|
||||
authentication: 'plain',
|
||||
enable_starttls_auto: true,
|
||||
user_name: Rails.application.secrets.mailer_user_name,
|
||||
password: Rails.application.secrets.mailer_password
|
||||
}
|
||||
|
||||
#config.action_mailer.perform_deliveries = false
|
||||
config.action_mailer.perform_deliveries = true
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
|
|
@ -41,6 +41,8 @@ Rails.application.routes.draw do
|
|||
|
||||
# Settings
|
||||
resources :users, only: :index # needed for testing signup
|
||||
# needed for testing edit passowrd
|
||||
get '/users/password', to: 'devise_password#edit'
|
||||
|
||||
get 'users/settings/account/preferences',
|
||||
to: 'users/settings/account/preferences#index',
|
||||
|
|
|
@ -4,9 +4,11 @@ Feature: Forgot password
|
|||
So that I can use sciNote
|
||||
|
||||
Background:
|
||||
Given the "BioSistemika Process" team exists
|
||||
Given the following users are registered
|
||||
| email | password | password_confirmation |
|
||||
| nonadmin@myorg.com | mypassword1234 | mypassword1234 |
|
||||
And "nonadmin@myorg.com" is in "BioSistemika Process" team as a "admin"
|
||||
|
||||
@javascript
|
||||
Scenario: User forgot their password and requests for new password
|
||||
|
@ -22,20 +24,23 @@ Scenario: User forgot their password and enters non valid email
|
|||
And I click "Send me reset password instruction" button
|
||||
Then I should see "Email not found"
|
||||
|
||||
@worker
|
||||
Scenario: User has got Reset Your Password email and click to link
|
||||
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
|
||||
Then I should be on Change your password page
|
||||
|
||||
@javascript
|
||||
Scenario: User successfully Change password at Change your password page
|
||||
Given I am on Change your password page
|
||||
Then I fill in New password "mypassword1234" and I fill in Confirm new password "mypassword1234"
|
||||
And I click on "Change my password" button
|
||||
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
|
||||
Then I fill in "newpassword1234" in "user_password" input field
|
||||
And I fill in "newpassword1234" in "user_password_confirmation" input field
|
||||
And I click "Change my password" button
|
||||
Then I should see "BioSistemika Process"
|
||||
And I should see "Your password has been changed successfully. You are now logged in." flash message
|
||||
|
||||
@javascript
|
||||
Scenario: User unsuccessfully Change password at Change your password page
|
||||
Given I am on Change your password page
|
||||
Then I fill in New password "mypassword12344" and I fill in Confirm new password "mypassword1234"
|
||||
And I click on "Change my password" button
|
||||
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
|
||||
Then I fill in "newpassword1234" in "user_password" input field
|
||||
And I fill in "nosamepassword" in "user_password_confirmation" input field
|
||||
And I click "Change my password" button
|
||||
Then I should see "Password confirmation doesn't match Password" flash message
|
||||
|
|
|
@ -38,11 +38,11 @@ Given("I click on Reset Password link in the reset password email for user {stri
|
|||
visit new_user_password_path
|
||||
fill_in 'user_email', with: email
|
||||
click_button 'Send me reset password instruction'
|
||||
binding.pry
|
||||
Delayed::Worker.new.work_off
|
||||
open_email(email)
|
||||
current_email.click_link 'Change my password'
|
||||
end
|
||||
|
||||
Then("I should be on Change your password page") do
|
||||
expect(page).to have_current_path(edit_user_password_path)
|
||||
expect(page).to have_current_path(edit_user_password_path, only_path: true)
|
||||
end
|
||||
|
|
|
@ -44,12 +44,6 @@ Before do
|
|||
end
|
||||
end
|
||||
|
||||
# start background worker
|
||||
Before('@worker') do
|
||||
delayed_job_worker = ExternalWorker.new('bin/rake jobs:work')
|
||||
delayed_job_worker.start
|
||||
end
|
||||
|
||||
# Capybara defaults to CSS3 selectors rather than XPath.
|
||||
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
||||
# selectors in your step definitions to use the XPath syntax.
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
require "timeout"
|
||||
|
||||
class ExternalWorker
|
||||
attr_accessor :worker_pid, :start_command
|
||||
|
||||
def initialize(start_command)
|
||||
raise ArgumentError, 'start_command was expected' unless start_command
|
||||
self.start_command = start_command
|
||||
end
|
||||
|
||||
def start
|
||||
puts "Trying to start #{start_command}..."
|
||||
self.worker_pid = fork do
|
||||
start_child
|
||||
end
|
||||
|
||||
at_exit do
|
||||
stop_child
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def start_child
|
||||
exec({ 'RAILS_ENV' => Rails.env }, start_command)
|
||||
end
|
||||
|
||||
def stop_child
|
||||
puts "Trying to stop #{start_command}, pid: #{worker_pid}"
|
||||
|
||||
# send TERM and wait for exit
|
||||
Process.kill('TERM', worker_pid)
|
||||
|
||||
begin
|
||||
Timeout.timeout(10) do
|
||||
Process.waitpid(worker_pid)
|
||||
puts "Process #{start_command} stopped successfully"
|
||||
end
|
||||
rescue Timeout::Error
|
||||
# Kill process if could not exit in 10 seconds
|
||||
puts "Sending KILL signal to #{start_command}, pid: #{worker_pid}"
|
||||
Process.kill('KILL', worker_pid)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue