mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-15 01:24:53 +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| %>
|
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||||
|
|
||||||
<% if not resource.errors.empty? %>
|
<% if not resource.errors.empty? %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger" id="alert-flash">
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||||
|
|
||||||
<% if not resource.errors.empty? %>
|
<% if not resource.errors.empty? %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger" id="alert-flash">
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -19,28 +19,31 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Don't care if the mailer can't send.
|
# Don't care if the mailer can't send.
|
||||||
config.action_mailer.default_url_options = {
|
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 = {
|
config.action_mailer.default_options = {
|
||||||
from: Rails.application.secrets.mailer_from,
|
from: Rails.application.secrets.mailer_from,
|
||||||
reply_to: Rails.application.secrets.mailer_reply_to
|
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.perform_caching = false
|
||||||
|
if ENV['CUCUMBER'] == 'cucumber'
|
||||||
config.action_mailer.delivery_method = :smtp
|
config.action_mailer.delivery_method = :test
|
||||||
|
else
|
||||||
|
config.action_mailer.delivery_method = :smtp
|
||||||
|
end
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.smtp_settings = {
|
||||||
address: Rails.application.secrets.mailer_address,
|
address: Rails.application.secrets.mailer_address,
|
||||||
port: Rails.application.secrets.mailer_port,
|
port: Rails.application.secrets.mailer_port,
|
||||||
domain: Rails.application.secrets.mailer_domain,
|
domain: Rails.application.secrets.mailer_domain,
|
||||||
authentication: "plain",
|
authentication: 'plain',
|
||||||
enable_starttls_auto: true,
|
enable_starttls_auto: true,
|
||||||
user_name: Rails.application.secrets.mailer_user_name,
|
user_name: Rails.application.secrets.mailer_user_name,
|
||||||
password: Rails.application.secrets.mailer_password
|
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.
|
# Print deprecation notices to the Rails logger.
|
||||||
config.active_support.deprecation = :log
|
config.active_support.deprecation = :log
|
||||||
|
|
|
@ -41,6 +41,8 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
resources :users, only: :index # needed for testing signup
|
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',
|
get 'users/settings/account/preferences',
|
||||||
to: 'users/settings/account/preferences#index',
|
to: 'users/settings/account/preferences#index',
|
||||||
|
|
|
@ -4,9 +4,11 @@ Feature: Forgot password
|
||||||
So that I can use sciNote
|
So that I can use sciNote
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
|
Given the "BioSistemika Process" team exists
|
||||||
Given the following users are registered
|
Given the following users are registered
|
||||||
| email | password | password_confirmation |
|
| email | password | password_confirmation |
|
||||||
| nonadmin@myorg.com | mypassword1234 | mypassword1234 |
|
| nonadmin@myorg.com | mypassword1234 | mypassword1234 |
|
||||||
|
And "nonadmin@myorg.com" is in "BioSistemika Process" team as a "admin"
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: User forgot their password and requests for new password
|
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
|
And I click "Send me reset password instruction" button
|
||||||
Then I should see "Email not found"
|
Then I should see "Email not found"
|
||||||
|
|
||||||
@worker
|
|
||||||
Scenario: User has got Reset Your Password email and click to link
|
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"
|
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
|
Then I should be on Change your password page
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: User successfully Change password at Change your password page
|
Scenario: User successfully Change password at Change your password page
|
||||||
Given I am on Change your password page
|
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
|
||||||
Then I fill in New password "mypassword1234" and I fill in Confirm new password "mypassword1234"
|
Then I fill in "newpassword1234" in "user_password" input field
|
||||||
And I click on "Change my password" button
|
And I fill in "newpassword1234" in "user_password_confirmation" input field
|
||||||
|
And I click "Change my password" button
|
||||||
Then I should see "BioSistemika Process"
|
Then I should see "BioSistemika Process"
|
||||||
And I should see "Your password has been changed successfully. You are now logged in." flash message
|
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
|
Scenario: User unsuccessfully Change password at Change your password page
|
||||||
Given I am on Change your password page
|
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
|
||||||
Then I fill in New password "mypassword12344" and I fill in Confirm new password "mypassword1234"
|
Then I fill in "newpassword1234" in "user_password" input field
|
||||||
And I click on "Change my password" button
|
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
|
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
|
visit new_user_password_path
|
||||||
fill_in 'user_email', with: email
|
fill_in 'user_email', with: email
|
||||||
click_button 'Send me reset password instruction'
|
click_button 'Send me reset password instruction'
|
||||||
binding.pry
|
Delayed::Worker.new.work_off
|
||||||
open_email(email)
|
open_email(email)
|
||||||
current_email.click_link 'Change my password'
|
current_email.click_link 'Change my password'
|
||||||
end
|
end
|
||||||
|
|
||||||
Then("I should be on Change your password page") do
|
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
|
end
|
||||||
|
|
|
@ -44,12 +44,6 @@ Before do
|
||||||
end
|
end
|
||||||
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.
|
# Capybara defaults to CSS3 selectors rather than XPath.
|
||||||
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
||||||
# selectors in your step definitions to use the XPath syntax.
|
# 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…
Add table
Reference in a new issue