rails_onboarding 0.8.2 → 0.8.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a33d58aa73f7c851196a6ed683c0a907eabc60addda69cc841206ef7765201e
4
- data.tar.gz: 28b37e7d218f6503e256e35292eb71c48a2074bb18f89be4581e417a98365cc0
3
+ metadata.gz: 007cab6c758c3d50c9c2b9dca6c8f798956b6c09d61a0078de8c347f2b857395
4
+ data.tar.gz: d431ee736da8d5de6af011483929f64cefd5da668844d88934ad48d30e3af5a1
5
5
  SHA512:
6
- metadata.gz: b1e1fa8588b97a8402ae6f68c0c968e88a0e8229fff82f9f1e79249bfec60b067f465369800241f56bcf63543663d979dcc5dbb14eefabd7982af921695edcaa
7
- data.tar.gz: eb6c36a63a60df9e93e83713022ffa175d6579fba9cd9b73246f1a82f8c1cc7fa165729b8d5f852564d494e246e7e0b099fcd3a6478bf184cb5a7d1e36ec125a
6
+ metadata.gz: b6f99c18d8a9e4143aa445392866e46e88561ec28e51f8d29a72c37458eecfbab311bed79ed9c400104849ba2669acecc8307464a5bbb8edbe3001543df763ec
7
+ data.tar.gz: c4db1b37aeec6472fb839ac1647f8d4ddc9fd1f643e4118e889e0a14db9a5ec1b9793bd3d3af0cfbb1f1550cced75c5439216f8a3c1b7f26402bf26d276a0dfb
@@ -112,7 +112,15 @@ module RailsOnboarding
112
112
  private
113
113
 
114
114
  def authenticate_user!
115
- unless respond_to?(:current_user) && current_user
115
+ # respond_to? omits private methods, and a host app that hand-rolls
116
+ # authentication commonly keeps current_user private - a public method on
117
+ # a controller can be reached as an action. Without the second argument
118
+ # this guard is false for every such host and the page is unreachable no
119
+ # matter who is signed in. (Gift Posse is exactly that shape.) The helper
120
+ # and layout uses of respond_to?(:current_user) elsewhere are fine as they
121
+ # stand: they run in view context, where helper_method has already defined
122
+ # a public current_user.
123
+ unless respond_to?(:current_user, true) && current_user
116
124
  redirect_to main_app.root_path, alert: "Please log in to view milestones"
117
125
  end
118
126
  end
@@ -242,12 +242,23 @@ module RailsOnboarding
242
242
 
243
243
  # Check if milestone-based feature is ready
244
244
  def milestone_based_ready?(feature)
245
- return false unless respond_to?(:earned_milestones)
245
+ # Onboardable exposes the awarded keys as #achieved_milestones. This used
246
+ # to guard on #earned_milestones, which the engine has never defined, so
247
+ # the guard was false for every host and a :milestone_based feature was
248
+ # never revealed to anyone - silently, since a reveal that does not happen
249
+ # looks exactly like one whose condition is not met yet. #earned_milestones
250
+ # is still honoured for any host that defines it itself.
251
+ milestones = if respond_to?(:achieved_milestones)
252
+ achieved_milestones
253
+ elsif respond_to?(:earned_milestones)
254
+ earned_milestones
255
+ end
256
+ return false unless milestones
246
257
 
247
258
  required_milestone = feature[:required_milestone]
248
259
  return false unless required_milestone
249
260
 
250
- earned_milestones.include?(required_milestone.to_s)
261
+ milestones.map(&:to_s).include?(required_milestone.to_s)
251
262
  end
252
263
 
253
264
  # Check if engagement-based feature is ready
@@ -1,3 +1,3 @@
1
1
  module RailsOnboarding
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_onboarding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lewis
@@ -282,7 +282,7 @@ licenses:
282
282
  metadata:
283
283
  allowed_push_host: https://rubygems.org
284
284
  homepage_uri: https://github.com/bunnahabhain/rails_onboarding
285
- source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.2
285
+ source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.4
286
286
  changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
287
287
  rdoc_options: []
288
288
  require_paths: