mongo_session_store 3.2.0 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +100 -0
  3. data/.github/workflows/danger-comment.yml +11 -0
  4. data/.github/workflows/danger.yml +45 -0
  5. data/.rubocop.yml +4 -4
  6. data/CHANGELOG.md +9 -2
  7. data/Dangerfile +5 -1
  8. data/Gemfile +2 -0
  9. data/Gemfile.danger +5 -0
  10. data/README.md +30 -7
  11. data/RELEASING.md +37 -0
  12. data/Rakefile +4 -4
  13. data/docker-compose.yml +5 -0
  14. data/gemfiles/rails-5.1-mongoid.gemfile +1 -1
  15. data/gemfiles/rails-6.0-mongo.gemfile +12 -0
  16. data/gemfiles/rails-6.0-mongoid.gemfile +12 -0
  17. data/gemfiles/rails-8.1-mongo.gemfile +14 -0
  18. data/gemfiles/rails-8.1-mongoid.gemfile +14 -0
  19. data/lib/mongo_session_store/mongo_store_base.rb +2 -1
  20. data/lib/mongo_session_store/mongoid_store.rb +1 -0
  21. data/lib/mongo_session_store/version.rb +1 -1
  22. data/mongo_session_store.gemspec +4 -7
  23. data/script/test +20 -0
  24. data/script/test_inner +19 -0
  25. data/script/testenv +6 -0
  26. data/spec/integrations/devise_spec.rb +2 -2
  27. data/spec/integrations/rack_spec.rb +19 -0
  28. data/spec/rails_helper.rb +3 -0
  29. data/spec/spec_helper.rb +4 -2
  30. data/spec/support/apps/rails_5.0_app/config/routes.rb +1 -0
  31. data/spec/support/apps/rails_5.1_app/config/routes.rb +1 -0
  32. data/spec/support/apps/rails_5.2_app/config/routes.rb +1 -0
  33. data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/Rakefile +2 -2
  34. data/spec/support/apps/rails_6.0_app/app/controllers/application_controller.rb +3 -0
  35. data/spec/support/apps/rails_6.0_app/app/models/application_record.rb +3 -0
  36. data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/app/models/user.rb +2 -2
  37. data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/app/views/layouts/application.html.erb +1 -1
  38. data/spec/support/apps/rails_6.0_app/bin/rails +4 -0
  39. data/spec/support/apps/rails_6.0_app/bin/setup +33 -0
  40. data/spec/support/apps/rails_6.0_app/config/application.rb +17 -0
  41. data/spec/support/apps/rails_6.0_app/config/boot.rb +3 -0
  42. data/spec/support/apps/rails_6.0_app/config/credentials.yml.enc +1 -0
  43. data/spec/support/apps/rails_6.0_app/config/database.yml +31 -0
  44. data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/config/environment.rb +1 -1
  45. data/spec/support/apps/rails_6.0_app/config/environments/development.rb +47 -0
  46. data/spec/support/apps/rails_6.0_app/config/environments/test.rb +38 -0
  47. data/spec/support/apps/rails_6.0_app/config/initializers/cookies_serializer.rb +5 -0
  48. data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/config/initializers/devise.rb +79 -34
  49. data/spec/support/apps/rails_6.0_app/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/spec/support/apps/rails_6.0_app/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/config/locales/devise.en.yml +22 -16
  52. data/spec/support/apps/{rails_4.1_app → rails_6.0_app}/config/locales/en.yml +11 -1
  53. data/spec/support/apps/rails_6.0_app/config/master.key +1 -0
  54. data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/config/routes.rb +1 -0
  55. data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/config.ru +2 -1
  56. data/spec/support/apps/{rails_4.2_app/db/migrate/20140301171212_add_devise_users.rb → rails_6.0_app/db/migrate/20200427115501_add_devise_users.rb} +1 -1
  57. data/spec/support/apps/rails_6.0_app/db/schema.rb +23 -0
  58. data/spec/support/apps/rails_6.0_app/db/seeds.rb +7 -0
  59. data/spec/support/rack_app.rb +16 -0
  60. metadata +107 -235
  61. data/.travis.yml +0 -95
  62. data/gemfiles/rails-4.0-mongo.gemfile +0 -9
  63. data/gemfiles/rails-4.0-mongoid.gemfile +0 -9
  64. data/gemfiles/rails-4.1-mongo.gemfile +0 -9
  65. data/gemfiles/rails-4.1-mongoid.gemfile +0 -9
  66. data/gemfiles/rails-4.2-mongo.gemfile +0 -9
  67. data/gemfiles/rails-4.2-mongoid.gemfile +0 -9
  68. data/spec/support/apps/rails_4.0_app/app/controllers/application_controller.rb +0 -5
  69. data/spec/support/apps/rails_4.0_app/app/models/user.rb +0 -5
  70. data/spec/support/apps/rails_4.0_app/app/views/layouts/application.html.erb +0 -17
  71. data/spec/support/apps/rails_4.0_app/bin/bundle +0 -3
  72. data/spec/support/apps/rails_4.0_app/bin/rails +0 -4
  73. data/spec/support/apps/rails_4.0_app/bin/rake +0 -4
  74. data/spec/support/apps/rails_4.0_app/config/application.rb +0 -11
  75. data/spec/support/apps/rails_4.0_app/config/boot.rb +0 -4
  76. data/spec/support/apps/rails_4.0_app/config/database.yml +0 -11
  77. data/spec/support/apps/rails_4.0_app/config/environment.rb +0 -5
  78. data/spec/support/apps/rails_4.0_app/config/environments/development.rb +0 -12
  79. data/spec/support/apps/rails_4.0_app/config/environments/test.rb +0 -19
  80. data/spec/support/apps/rails_4.0_app/config/initializers/secret_token.rb +0 -12
  81. data/spec/support/apps/rails_4.0_app/config/initializers/session_store.rb +0 -1
  82. data/spec/support/apps/rails_4.0_app/config/locales/en.yml +0 -23
  83. data/spec/support/apps/rails_4.0_app/config/mongo.yml +0 -11
  84. data/spec/support/apps/rails_4.0_app/config/mongoid.yml +0 -13
  85. data/spec/support/apps/rails_4.0_app/config/routes.rb +0 -4
  86. data/spec/support/apps/rails_4.0_app/config.ru +0 -4
  87. data/spec/support/apps/rails_4.0_app/db/migrate/20140301171212_add_devise_users.rb +0 -11
  88. data/spec/support/apps/rails_4.0_app/db/schema.rb +0 -25
  89. data/spec/support/apps/rails_4.1_app/Rakefile +0 -3
  90. data/spec/support/apps/rails_4.1_app/app/controllers/application_controller.rb +0 -5
  91. data/spec/support/apps/rails_4.1_app/app/controllers/home_controller.rb +0 -2
  92. data/spec/support/apps/rails_4.1_app/app/models/user.rb +0 -5
  93. data/spec/support/apps/rails_4.1_app/app/views/home/index.html.erb +0 -9
  94. data/spec/support/apps/rails_4.1_app/app/views/layouts/application.html.erb +0 -17
  95. data/spec/support/apps/rails_4.1_app/bin/bundle +0 -3
  96. data/spec/support/apps/rails_4.1_app/bin/rails +0 -4
  97. data/spec/support/apps/rails_4.1_app/bin/rake +0 -4
  98. data/spec/support/apps/rails_4.1_app/config/application.rb +0 -11
  99. data/spec/support/apps/rails_4.1_app/config/boot.rb +0 -4
  100. data/spec/support/apps/rails_4.1_app/config/database.yml +0 -11
  101. data/spec/support/apps/rails_4.1_app/config/environment.rb +0 -5
  102. data/spec/support/apps/rails_4.1_app/config/environments/development.rb +0 -12
  103. data/spec/support/apps/rails_4.1_app/config/environments/test.rb +0 -19
  104. data/spec/support/apps/rails_4.1_app/config/initializers/devise.rb +0 -254
  105. data/spec/support/apps/rails_4.1_app/config/locales/devise.en.yml +0 -59
  106. data/spec/support/apps/rails_4.1_app/config/mongo.yml +0 -11
  107. data/spec/support/apps/rails_4.1_app/config/mongoid.yml +0 -13
  108. data/spec/support/apps/rails_4.1_app/config/routes.rb +0 -4
  109. data/spec/support/apps/rails_4.1_app/config/secrets.yml +0 -22
  110. data/spec/support/apps/rails_4.1_app/config.ru +0 -2
  111. data/spec/support/apps/rails_4.1_app/db/migrate/20140301171212_add_devise_users.rb +0 -11
  112. data/spec/support/apps/rails_4.1_app/db/schema.rb +0 -25
  113. data/spec/support/apps/rails_4.1_app/lib/assets/.keep +0 -0
  114. data/spec/support/apps/rails_4.1_app/lib/tasks/.keep +0 -0
  115. data/spec/support/apps/rails_4.1_app/log/.keep +0 -0
  116. data/spec/support/apps/rails_4.2_app/Rakefile +0 -2
  117. data/spec/support/apps/rails_4.2_app/app/controllers/application_controller.rb +0 -5
  118. data/spec/support/apps/rails_4.2_app/app/controllers/home_controller.rb +0 -2
  119. data/spec/support/apps/rails_4.2_app/app/views/home/index.html.erb +0 -9
  120. data/spec/support/apps/rails_4.2_app/bin/bundle +0 -3
  121. data/spec/support/apps/rails_4.2_app/bin/rails +0 -8
  122. data/spec/support/apps/rails_4.2_app/config/application.rb +0 -11
  123. data/spec/support/apps/rails_4.2_app/config/boot.rb +0 -3
  124. data/spec/support/apps/rails_4.2_app/config/database.yml +0 -11
  125. data/spec/support/apps/rails_4.2_app/config/environments/development.rb +0 -12
  126. data/spec/support/apps/rails_4.2_app/config/environments/test.rb +0 -19
  127. data/spec/support/apps/rails_4.2_app/config/initializers/devise.rb +0 -254
  128. data/spec/support/apps/rails_4.2_app/config/initializers/session_store.rb +0 -1
  129. data/spec/support/apps/rails_4.2_app/config/locales/en.yml +0 -23
  130. data/spec/support/apps/rails_4.2_app/config/secrets.yml +0 -22
  131. data/spec/support/apps/rails_4.2_app/db/schema.rb +0 -25
  132. /data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/app/controllers/home_controller.rb +0 -0
  133. /data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/app/views/home/index.html.erb +0 -0
  134. /data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/bin/rake +0 -0
  135. /data/spec/support/apps/{rails_4.1_app → rails_6.0_app}/config/initializers/session_store.rb +0 -0
  136. /data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/config/mongo.yml +0 -0
  137. /data/spec/support/apps/{rails_4.2_app → rails_6.0_app}/config/mongoid.yml +0 -0
  138. /data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/lib/assets/.keep +0 -0
  139. /data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/lib/tasks/.keep +0 -0
  140. /data/spec/support/apps/{rails_4.0_app → rails_6.0_app}/log/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98a3bc915313a9b027a2c7483dec78a95f193838e48405319d54dcb24938a979
4
- data.tar.gz: 1236cd6f4cdf7ca4b997a05bd12a749b3ad57ffac50688ddc38935fe959f7dd9
3
+ metadata.gz: d43ac777d775e4cb749414668819d70cf193f0e2ba5095671efecb49217d3988
4
+ data.tar.gz: 2b7adfc073d06d392a28f8c9625ea53b1a80c083bdc23c59c2726fb57032984d
5
5
  SHA512:
6
- metadata.gz: 6cabedbc5554f3e0f7b6531191cd2db03a4b9ef45e1d5cc6b4bf49519a93e82618101c1945e089738310480c58fb6e910bf219416b053164751c7da8d8be7e41
7
- data.tar.gz: f428bfafdea80679efe71b464233b18b32096ab22de94484c0ab1b8625f27f6f127170144c42fe4f9d8fe68c0173c6a6bc762725c08b7f00a63e5c4b5ebb4484
6
+ metadata.gz: 3190b6a8071c1c141c5ce81f7e362ea6350790ff8338769bcc0730dbc12bc277d80b5be37c5cf4bd6680042353fb0fd483785feb200f37e9f6dcd6dec4478763
7
+ data.tar.gz: 2d194275cc082008d673860b7c3b750e1224922e84ff0a641255959f5e290baedf904dfd619c0adb3b70c441ae9d3ce203e29d3dfabfd8d42a17767cd2e5380d
@@ -0,0 +1,100 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - reopened
11
+ - synchronize
12
+
13
+ concurrency:
14
+ group: "${{ github.workflow }}-${{ github.ref }}"
15
+ cancel-in-progress: "${{ !contains(github.ref, 'main')}}"
16
+
17
+ jobs:
18
+ test:
19
+ name: "Run tests"
20
+ runs-on: ubuntu-latest
21
+
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ ruby:
26
+ - "3.4"
27
+ - "3.3"
28
+ gemfile:
29
+ - gemfiles/rails-6.0-mongo.gemfile
30
+ - gemfiles/rails-6.0-mongoid.gemfile
31
+ include:
32
+ - gemfile: gemfiles/rails-8.1-mongo.gemfile
33
+ ruby: "3.4"
34
+ mongodb: "8.0"
35
+ - gemfile: gemfiles/rails-8.1-mongoid.gemfile
36
+ ruby: "3.4"
37
+ mongodb: "8.0"
38
+ - gemfile: gemfiles/rails-8.1-mongo.gemfile
39
+ ruby: "4.0"
40
+ mongodb: "8.0"
41
+ - gemfile: gemfiles/rails-8.1-mongoid.gemfile
42
+ ruby: "4.0"
43
+ mongodb: "8.0"
44
+ - gemfile: gemfiles/rails-5.2-mongo.gemfile
45
+ ruby: "2.7"
46
+ - gemfile: gemfiles/rails-5.2-mongoid.gemfile
47
+ ruby: "2.7"
48
+ - gemfile: gemfiles/rails-5.1-mongo.gemfile
49
+ ruby: "2.6"
50
+ - gemfile: gemfiles/rails-5.1-mongoid.gemfile
51
+ ruby: "2.6"
52
+ - gemfile: gemfiles/rails-5.0-mongo.gemfile
53
+ ruby: "2.6"
54
+ - gemfile: gemfiles/rails-5.0-mongoid.gemfile
55
+ ruby: "2.6"
56
+
57
+ services:
58
+ mongodb:
59
+ image: mongo:${{ matrix.mongodb || '4.4' }}
60
+ ports:
61
+ - 27017:27017
62
+ options: >-
63
+ --health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
64
+ --health-interval 10s
65
+ --health-timeout 5s
66
+ --health-retries 10
67
+
68
+ env:
69
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
70
+
71
+ steps:
72
+ - name: Checkout project
73
+ uses: actions/checkout@v7
74
+
75
+ - name: Set up Ruby
76
+ uses: ruby/setup-ruby@v1
77
+ with:
78
+ ruby-version: ${{ matrix.ruby }}
79
+ bundler-cache: true
80
+
81
+ - name: Run tests
82
+ run: bundle exec rake test
83
+
84
+ rubocop:
85
+ name: "RuboCop"
86
+ runs-on: ubuntu-latest
87
+
88
+ steps:
89
+ - name: Checkout project
90
+ uses: actions/checkout@v7
91
+
92
+ - name: Set up Ruby
93
+ uses: ruby/setup-ruby@v1
94
+ with:
95
+ ruby-version: "3.3"
96
+ gemfile: gemfiles/rails-6.0-mongo.gemfile
97
+ bundler-cache: true
98
+
99
+ - name: Run RuboCop
100
+ run: bundle exec rubocop
@@ -0,0 +1,11 @@
1
+ name: Danger Comment
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: [Danger]
6
+ types: [completed]
7
+
8
+ jobs:
9
+ comment:
10
+ uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
11
+ secrets: inherit
@@ -0,0 +1,45 @@
1
+ name: Danger
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, reopened, edited, synchronize]
6
+
7
+ jobs:
8
+ danger:
9
+ runs-on: ubuntu-latest
10
+
11
+ env:
12
+ BUNDLE_GEMFILE: Gemfile.danger
13
+
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '3.4'
24
+ bundler-cache: true
25
+
26
+ - name: Run Danger
27
+ id: danger
28
+ continue-on-error: true
29
+ env:
30
+ DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
31
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
32
+ DANGER_REPORT_PATH: ${{ runner.temp }}/danger-report.json
33
+ run: bundle exec danger dry_run
34
+
35
+ - name: Upload Danger report
36
+ if: ${{ always() }}
37
+ uses: actions/upload-artifact@v4
38
+ with:
39
+ name: danger-report
40
+ path: ${{ runner.temp }}/danger-report.json
41
+ if-no-files-found: error
42
+
43
+ - name: Fail if Danger failed
44
+ if: ${{ steps.danger.outcome == 'failure' }}
45
+ run: exit 1
data/.rubocop.yml CHANGED
@@ -21,19 +21,19 @@ Style/StringLiterals:
21
21
  Style/StringLiteralsInInterpolation:
22
22
  EnforcedStyle: double_quotes
23
23
 
24
- Style/AlignParameters:
24
+ Layout/ParameterAlignment:
25
25
  EnforcedStyle: with_fixed_indentation
26
26
 
27
- Style/MultilineOperationIndentation:
27
+ Layout/MultilineOperationIndentation:
28
28
  EnforcedStyle: indented
29
29
 
30
- Style/AlignHash:
30
+ Layout/HashAlignment:
31
31
  EnforcedLastArgumentHashStyle: ignore_implicit
32
32
 
33
33
  Style/HashSyntax:
34
34
  EnforcedStyle: hash_rockets
35
35
 
36
- Style/IndentArray:
36
+ Layout/FirstArrayElementIndentation:
37
37
  EnforcedStyle: consistent
38
38
 
39
39
  Style/FormatString:
data/CHANGELOG.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## (unreleased)
3
+ ## 3.2.2 (2026/10/14)
4
4
 
5
- * Your contribution here.
5
+ * [#51](https://github.com/mongoid/mongo_session_store/pull/51): Modernize CI through Ruby 4.0, Rails 8.1, Mongoid 9 and MongoDB 8 while retaining legacy Rails combinations - [@dblock](https://github.com/dblock).
6
+ * [#51](https://github.com/mongoid/mongo_session_store/pull/51): Explicitly load ActionDispatch before defining the session store.
7
+ * [#48](https://github.com/mongoid/mongo_session_store/pull/48): Migrate Danger to danger-pr-comment - [@dblock](https://github.com/dblock).
8
+
9
+ ## 3.2.1
10
+
11
+ * [#45](https://github.com/mongoid/mongo_session_store/pull/45): Add Rails 6.0 to test setup - [@tombruijn](https://github.com/tombruijn).
12
+ * [#46](https://github.com/mongoid/mongo_session_store/pull/46): Fix Rack::Session::Cookie middleware bug - [@streetlogics](https://github.com/streetlogics) & [@tombruijn](https://github.com/tombruijn).
6
13
 
7
14
  ## 3.2.0
8
15
 
data/Dangerfile CHANGED
@@ -1 +1,5 @@
1
- danger.import_dangerfile(gem: "mongoid-danger")
1
+ # frozen_string_literal: true
2
+
3
+ danger.import_dangerfile(gem: 'danger-pr-comment')
4
+
5
+ changelog.check!
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "rubocop", "1.84.1"
data/Gemfile.danger ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "danger"
4
+ gem "danger-changelog"
5
+ gem "danger-pr-comment"
data/README.md CHANGED
@@ -11,7 +11,7 @@ MongoSessionStore is a [Rails][rails]-compatible session store for
11
11
  Driver][mongo]. It also allows for custom Mongo session store that works with
12
12
  any (or no!) Mongo ODM.
13
13
 
14
- MongoSessionStore version 3 is compatible with Rails 4.0 through 5.2. For Rails
14
+ MongoSessionStore version 3 is compatible with Rails 5.0+. For Rails
15
15
  3 support please check out issue [#17][issue-rails3] for options and let us
16
16
  know if you need support.
17
17
 
@@ -70,11 +70,21 @@ MongoStore::Session.where("updated_at" => { "$gt" => 2.days.ago })
70
70
 
71
71
  ## Development
72
72
 
73
+ ### Test environment
74
+
75
+ Start MongoDB with this script:
76
+
77
+ ```
78
+ script/testenv
79
+ ```
80
+
73
81
  ### Testing
74
82
 
75
83
  To run the tests for a specific store. You must first set a `BUNDLE_GEMFILE` in
76
84
  the environment.
77
85
 
86
+ You can also use Docker, see the section below this one.
87
+
78
88
  ```sh
79
89
  bundle exec rake
80
90
  ```
@@ -82,18 +92,28 @@ bundle exec rake
82
92
  Examples:
83
93
 
84
94
  ```sh
85
- BUNDLE_GEMFILE=gemfiles/rails-4.0-mongo.gemfile bundle exec rake
86
- BUNDLE_GEMFILE=gemfiles/rails-4.0-mongoid.gemfile bundle exec rake
87
- BUNDLE_GEMFILE=gemfiles/rails-4.1-mongo.gemfile bundle exec rake
88
- BUNDLE_GEMFILE=gemfiles/rails-4.1-mongoid.gemfile bundle exec rake
89
- BUNDLE_GEMFILE=gemfiles/rails-4.2-mongo.gemfile bundle exec rake
90
- BUNDLE_GEMFILE=gemfiles/rails-4.2-mongoid.gemfile bundle exec rake
91
95
  BUNDLE_GEMFILE=gemfiles/rails-5.0-mongo.gemfile bundle exec rake
92
96
  BUNDLE_GEMFILE=gemfiles/rails-5.0-mongoid.gemfile bundle exec rake
93
97
  BUNDLE_GEMFILE=gemfiles/rails-5.1-mongo.gemfile bundle exec rake
94
98
  BUNDLE_GEMFILE=gemfiles/rails-5.1-mongoid.gemfile bundle exec rake
95
99
  BUNDLE_GEMFILE=gemfiles/rails-5.2-mongo.gemfile bundle exec rake
96
100
  BUNDLE_GEMFILE=gemfiles/rails-5.2-mongoid.gemfile bundle exec rake
101
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile bundle exec rake
102
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongoid.gemfile bundle exec rake
103
+ ```
104
+
105
+ #### Docker testing
106
+
107
+ To run tests in a Docker container with a specific Ruby version and gemfile:
108
+
109
+ ```sh
110
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
111
+ ```
112
+
113
+ The `BUNDLE_GEMFILE` environment variable is required. Ruby version defaults to 3.4 but can be customized:
114
+
115
+ ```sh
116
+ RUBY_VERSION=2.7 BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
97
117
  ```
98
118
 
99
119
  ### Performance benchmark
@@ -141,3 +161,6 @@ Released under the MIT license. See the [LICENSE](LICENSE) file.
141
161
  [rails]: http://rubyonrails.org/
142
162
 
143
163
  [issue-rails3]: https://github.com/mongoid/mongo_session_store/issues/17
164
+ ## CI compatibility
165
+
166
+ CI retains the Rails 5.0–6.0 dependency files and exercises both Mongo and Mongoid session stores with Rails 8.1, Mongoid 9, Ruby 3.4/4.0 and MongoDB 8.0; use `BUNDLE_GEMFILE=gemfiles/rails-8.1-mongoid.gemfile bundle exec rake test` for the modern Mongoid suite, which shares the minimal Rails 6 integration app.
data/RELEASING.md ADDED
@@ -0,0 +1,37 @@
1
+ # Releasing
2
+
3
+ Release from a clean local checkout of the upstream repository, not a fork. You need push access, RubyGems ownership with MFA, and an authenticated GitHub CLI.
4
+
5
+ ## Prepare
6
+
7
+ 1. Run `git switch main`, `git pull --ff-only`, and confirm that `origin` points to `mongoid/mongo_session_store`.
8
+ 2. Choose the next semantic version, update `lib/mongo_session_store/version.rb`, and replace the unreleased changelog heading with the version and release date. Remove the contribution placeholder.
9
+ 3. With MongoDB running, install dependencies and run `bundle exec rake test` using each supported adapter's `BUNDLE_GEMFILE`, for example `gemfiles/rails-6.0-mongo.gemfile` and `gemfiles/rails-6.0-mongoid.gemfile`. Run `bundle exec rubocop` with the default Gemfile.
10
+ 4. Commit the preparation, push `main`, and wait for the complete GitHub Actions matrix to pass for that commit.
11
+
12
+ ## Publish
13
+
14
+ Do not use the legacy `rake release` task: it assumes `master` and performs interactive edits. Build and publish the prepared version explicitly:
15
+
16
+ ```sh
17
+ version=3.2.2 # Replace with the version being released.
18
+ gem build mongo_session_store.gemspec
19
+ git tag "v$version"
20
+ git push origin "v$version"
21
+ gem push "mongo_session_store-$version.gem"
22
+ ```
23
+
24
+ Enter a fresh RubyGems MFA code when prompted. Create a GitHub release from the same tag, using the matching changelog section as the release notes:
25
+
26
+ ```sh
27
+ gh release create "v$version" --repo mongoid/mongo_session_store \
28
+ --verify-tag --title "$version" --notes-file /path/to/release-notes.md --latest
29
+ ```
30
+
31
+ Verify the exact version at `https://rubygems.org/gems/mongo_session_store/versions/VERSION` and inspect `gh release view "v$version" --repo mongoid/mongo_session_store` to confirm a published, non-draft release.
32
+
33
+ If publication is interrupted, check the remote tag, RubyGems version, and GitHub release first. Resume only the missing step; never move a published tag or rebuild an already published version. If the gem push needs a new code, retry that command with `--otp CODE`.
34
+
35
+ ## Next development version
36
+
37
+ Increment the patch version in `lib/mongo_session_store/version.rb`, add a new `## (unreleased)` section with a contribution placeholder, and commit and push the changes to `main`. Remove the local built gem after successful publication.
data/Rakefile CHANGED
@@ -39,10 +39,10 @@ task :release do
39
39
  raise "$EDITOR should be set" unless ENV["EDITOR"]
40
40
 
41
41
  def build_and_push_gem
42
- puts '# Building gem'
43
- puts `gem build #{GEMSPEC_NAME}.gemspec`
44
- puts '# Publishing Gem'
45
- puts `gem push #{GEM_NAME}-#{gem_version}.gem`
42
+ puts "# Building gem"
43
+ system "gem build #{GEMSPEC_NAME}.gemspec"
44
+ puts "# Publishing Gem"
45
+ system "gem push #{GEM_NAME}-#{gem_version}.gem"
46
46
  end
47
47
 
48
48
  def update_repo
@@ -0,0 +1,5 @@
1
+ services:
2
+ mongodb:
3
+ image: mongo:3.6
4
+ ports:
5
+ - "27017:27017"
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "mongoid"
3
+ gem "mongoid", "~> 7.0"
4
4
 
5
5
  gem "rails", "~> 5.1.0"
6
6
  gem "devise", ">= 4.2"
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongo"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+ gem "devise", "~> 4.7.0"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "bigdecimal"
9
+ gem "mutex_m"
10
+ gem "drb"
11
+
12
+ gemspec :path => "../"
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongoid"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+ gem "devise", "~> 4.7.0"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "bigdecimal"
9
+ gem "mutex_m"
10
+ gem "drb"
11
+
12
+ gemspec :path => "../"
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongo", "~> 2.0"
4
+ gem "rails", "~> 8.1.0"
5
+ gem "devise", "~> 5.0"
6
+ gem "sqlite3", "~> 2.0"
7
+ gem "bigdecimal"
8
+ gem "mutex_m"
9
+ gem "drb"
10
+ gem "base64"
11
+ gem "benchmark"
12
+ gem "ostruct"
13
+
14
+ gemspec :path => "../"
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongoid", "~> 9.0"
4
+ gem "rails", "~> 8.1.0"
5
+ gem "devise", "~> 5.0"
6
+ gem "sqlite3", "~> 2.0"
7
+ gem "bigdecimal"
8
+ gem "mutex_m"
9
+ gem "drb"
10
+ gem "base64"
11
+ gem "benchmark"
12
+ gem "ostruct"
13
+
14
+ gemspec :path => "../"
@@ -1,3 +1,4 @@
1
+ require "action_dispatch"
1
2
  require "action_dispatch/middleware/session/abstract_store"
2
3
 
3
4
  module ActionDispatch
@@ -46,7 +47,7 @@ module ActionDispatch
46
47
  end
47
48
 
48
49
  def find_or_initialize_session(id)
49
- existing_session = (id && session_class.where(:_id => id).first)
50
+ existing_session = (id && session_class.where(:_id => id.to_s).first)
50
51
  session = existing_session if existing_session
51
52
  session ||= session_class.new(:_id => generate_sid)
52
53
  [session._id, session]
@@ -38,6 +38,7 @@ module ActionDispatch
38
38
 
39
39
  def unpack(packed)
40
40
  return unless packed
41
+
41
42
  if packed.respond_to? :data
42
43
  Marshal.load(packed.data)
43
44
  else
@@ -1,3 +1,3 @@
1
1
  module MongoSessionStore
2
- VERSION = "3.2.0".freeze
2
+ VERSION = "3.2.2".freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path("../lib/mongo_session_store/version", __FILE__)
1
+ require File.expand_path("lib/mongo_session_store/version", __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mongo_session_store"
@@ -17,10 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "actionpack", ">= 4.0"
18
18
  s.add_dependency "mongo", "~> 2.0"
19
19
 
20
- s.add_development_dependency "rspec-rails", "~> 3.6"
21
- s.add_development_dependency "capybara", "~> 2.15.0"
22
- s.add_development_dependency "pry", "~> 0.10"
23
- s.add_development_dependency "rake", "~> 11"
24
- s.add_development_dependency "rubocop", "0.45.0"
25
- s.add_development_dependency "mongoid-danger", "~> 0.1.0"
20
+ s.add_development_dependency "capybara", ">= 2.15"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "rspec-rails", ">= 4.0"
26
23
  end
data/script/test ADDED
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ if [ -z "${BUNDLE_GEMFILE:-}" ]; then
6
+ echo "Error: BUNDLE_GEMFILE environment variable is required"
7
+ echo "Example: BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test"
8
+ exit 1
9
+ fi
10
+
11
+ RUBY_VERSION=${RUBY_VERSION:-3.4}
12
+
13
+ docker run --rm -it \
14
+ --network mongo_session_store_default \
15
+ -e MONGODB_HOST=mongodb \
16
+ -e BUNDLE_GEMFILE="${BUNDLE_GEMFILE}" \
17
+ -v "$(pwd):/app" \
18
+ -w /app \
19
+ "ruby:${RUBY_VERSION}" \
20
+ /app/script/test_inner
data/script/test_inner ADDED
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ export BUNDLE_GEMFILE
6
+ export BUNDLE_PATH="/app/tmp/bundler/$RUBY_VERSION/$BUNDLE_GEMFILE"
7
+
8
+ ruby_version=$(ruby -e 'puts RUBY_VERSION')
9
+ major=$(echo "$ruby_version" | cut -d. -f1)
10
+ minor=$(echo "$ruby_version" | cut -d. -f2)
11
+
12
+ if [ "$major" -lt 2 ] || ([ "$major" -eq 2 ] && [ "$minor" -le 7 ]); then
13
+ gem install bundler -v 1.17.3
14
+ else
15
+ gem install bundler
16
+ fi
17
+
18
+ bundle install
19
+ bundle exec rspec
data/script/testenv ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ echo "Starting test environment..."
6
+ docker compose up
@@ -15,7 +15,7 @@ describe Devise::SessionsController, :type => :request do
15
15
  end
16
16
 
17
17
  def create_user
18
- post "/users", prepare_request_params(
18
+ post "/users", **prepare_request_params(
19
19
  "user[email]" => "person@example.com",
20
20
  "user[password]" => "secret",
21
21
  "user[password_confirmation]" => "secret"
@@ -23,7 +23,7 @@ describe Devise::SessionsController, :type => :request do
23
23
  end
24
24
 
25
25
  def sign_in
26
- post "/users/sign_in", prepare_request_params(
26
+ post "/users/sign_in", **prepare_request_params(
27
27
  "user[email]" => "person@example.com",
28
28
  "user[password]" => "secret",
29
29
  "user[password_confirmation]" => "secret"
@@ -0,0 +1,19 @@
1
+ require "rails_helper"
2
+
3
+ describe "Rack app", :type => :request do
4
+ it "works with a mounted Rack app using Rack::Session" do
5
+ if Gem.loaded_specs["rack"].version < Gem::Version.new("2.0.0")
6
+ # Fails on trying to stringify the Rack::Session::Id object. Unrelated to
7
+ # this gem's code.
8
+ #
9
+ # NoMethodError:
10
+ # undefined method `each' for #<ActionDispatch::Request::Session:...>
11
+ #
12
+ # Skip spec setup for older Rack versions.
13
+ skip "Incompatible Rack version"
14
+ end
15
+
16
+ get "/rack_test"
17
+ expect(response.body.squish).to eql("Hello Rack app!")
18
+ end
19
+ end
data/spec/rails_helper.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
  rails_version = Gem.loaded_specs["rails"].version.to_s[/^\d\.\d/]
3
+ # Modern Rails uses the same minimal integration app as Rails 6.
4
+ rails_version = "6.0" if Gem.loaded_specs["rails"].version >= Gem::Version.new("7.0")
3
5
  if Gem.loaded_specs["rails"].version >= Gem::Version.new("5.2")
4
6
  require "active_support/message_encryptor"
5
7
  end
6
8
  require "spec_helper"
7
9
  require "rails"
10
+ require "support/rack_app"
8
11
  require "support/apps/rails_#{rails_version}_app/config/environment"
9
12
  require "rspec/rails"
10
13
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "logger"
1
2
  require "mongo"
2
3
  require "mongoid" if Gem.loaded_specs["mongoid"]
3
4
  require "mongo_session_store"
@@ -27,6 +28,7 @@ RSpec.configure do |config|
27
28
  config.before :suite do
28
29
  Mongo::Logger.logger.level = ::Logger::INFO
29
30
 
31
+ mongodb_host = ENV["MONGODB_HOST"] || "127.0.0.1"
30
32
  if mongo_orm == "mongoid"
31
33
  Mongoid.logger.level = Logger::INFO
32
34
  Mongoid.configure do |c|
@@ -34,14 +36,14 @@ RSpec.configure do |config|
34
36
  "clients" => {
35
37
  "default" => {
36
38
  "database" => TestDatabaseHelper.test_database_name,
37
- "hosts" => ["127.0.0.1:27017"]
39
+ "hosts" => ["#{mongodb_host}:27017"]
38
40
  }
39
41
  }
40
42
  )
41
43
  end
42
44
  else
43
45
  MongoStore::Session.database = Mongo::Client.new(
44
- ["127.0.0.1:27017"],
46
+ ["#{mongodb_host}:27017"],
45
47
  :database => TestDatabaseHelper.test_database_name
46
48
  )
47
49
  end
@@ -1,4 +1,5 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
+ mount MyAppWrapped => "/rack_test"
3
4
  root :to => "home#index"
4
5
  end
@@ -1,4 +1,5 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
+ mount MyAppWrapped => "/rack_test"
3
4
  root :to => "home#index"
4
5
  end
@@ -1,4 +1,5 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
+ mount MyAppWrapped => "/rack_test"
3
4
  root :to => "home#index"
4
5
  end
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
- Rails40App::Application.load_tasks
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end