quo_vadis 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5f77cea22311c350e1a0671c147db092e3e6c46164a468bff88904eb5fdb742
4
- data.tar.gz: 03f0d04ea03e4e84b45d83fb494959a02f0483b5fd145ff550200fdbb6639ab6
3
+ metadata.gz: e38d43ca3eb42e7fe421725da06631c57c15308a0ee0fcb395043b3c8d922bde
4
+ data.tar.gz: 2e09223593c598cdfcad8cb5947dc4065b499e9a9dee06e8eec1a7cd6124003a
5
5
  SHA512:
6
- metadata.gz: b96e1e5398ded302e9efb69c6e268307606535fc63346acc4faf0443098eb500c97daa107be2ccced4151078c90aac9917a72e037023aeea7cf460a7c706dde8
7
- data.tar.gz: 6de70ddbe36d8c5334d1a6ab95da333ab59d28a98a0c1a57ca1c47e1375a156df5c689fbc66f90e70ea44d3e46e2a9af3ad4b4b8a7d8e86fd6ed27e2055ab5e4
6
+ metadata.gz: 69048fb28b48d94329ee3269cb706f583796893a2a8a6d7177adfb2b9b022f7fe84e4076044816d33d6e4a02b6529b3413c12b38f6dc6a3f3672095683a04610
7
+ data.tar.gz: fd2a1c93a899e07d1e9bb2a393a52eccbdb5f9256c894d03ca1eb34bc867f351dfe12149d45879ab5bc5960f9d393cdbbe7f5dc24ab43a46cc3cfa50a6454b44
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.2.3 (22 May 2024)
8
+
9
+ * Add login shortcut for speedier tests.
10
+
11
+
7
12
  ## 2.2.2 (30 April 2024)
8
13
 
9
14
  * Do not update last activity time for ActiveStorage (#23).
data/README.md CHANGED
@@ -12,6 +12,7 @@ Simple to integrate into your application. The main task is customising the exa
12
12
  ### General features
13
13
 
14
14
  - Works with any model, e.g. `User` or `Person`.
15
+ - Works with multiple models, e.g. `User` and `Admin`.
15
16
  - Works with any identifier, e.g. `:username` or `:email`.
16
17
  - Minimal footprint in your models and controllers.
17
18
  - Does not touch your existing database tables.
@@ -31,6 +32,10 @@ Simple to integrate into your application. The main task is customising the exa
31
32
  - Email-notifications of updates to authentication details.
32
33
  - Audit trail.
33
34
 
35
+ ### Testing
36
+
37
+ - Can shortcut logging in for speedier tests.
38
+
34
39
 
35
40
  ## Installation
36
41
 
@@ -384,6 +389,22 @@ They must be in `app/views/quo_vadis/mailer/NAME.{text,html}.erb`.
384
389
  You can revoke a user's access by calling `#revoke_authentication_credentials` on the model instance. This deletes the user's password, TOTP credential, recovery codes, and active sessions. Their authentication logs, or audit trail, are preserved.
385
390
 
386
391
 
392
+ ## Shortcut logging in for functional, integration, and system tests
393
+
394
+ Instead of going through your login page to log in before every test, you can tell QuoVadis which model to authenticate as when visiting the first URL in your test.
395
+
396
+ Use a `login` param pointing to your model's global ID. Note that the model must be able to log in normally, i.e. it must have a password (and therefore a `qv_account`).
397
+
398
+ For example:
399
+
400
+ ```ruby
401
+ @user = User.create(email: '...', password: '...')
402
+ visit dashboard_path(login: @user.to_global_id)
403
+ ```
404
+
405
+ This only works in the test environment.
406
+
407
+
387
408
  ## Configuration
388
409
 
389
410
  This is QuoVadis' [default configuration](https://github.com/airblade/quo_vadis/blob/master/lib/quo_vadis/defaults.rb):
@@ -4,6 +4,15 @@ module QuoVadis
4
4
  module Controller
5
5
 
6
6
  def self.included(base)
7
+ if Rails.env.test?
8
+ base.before_action {
9
+ if params[:login]
10
+ model = GlobalID::Locator.locate(params.delete(:login))
11
+ login model
12
+ end
13
+ }
14
+ end
15
+
7
16
  base.before_action { CurrentRequestDetails.request = request }
8
17
 
9
18
  base.helper_method :authenticated_model, :logged_in?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- VERSION = '2.2.2'
4
+ VERSION = '2.2.3'
5
5
  end
@@ -14,6 +14,14 @@ class ControllerTest < IntegrationTest
14
14
  end
15
15
 
16
16
 
17
+ test 'shortcut login' do
18
+ get secret_articles_path(login: User.first.to_global_id)
19
+
20
+ assert_response :success
21
+ assert_equal secret_articles_path, path
22
+ end
23
+
24
+
17
25
  test 'require_authentication when not logged in' do
18
26
  get secret_articles_path
19
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails