discourse/spec
Ted Johansson b50b63808c
DEV: Make Guardian#can_see? default to false for unwatched objects (#20412)
When invoking e.g. `can_see?(Foo.new)`, the guardian checks if there's a method `#can_see_foo?` defined and if so uses that to determine whether the user can see it or not.

When such a method is not defined, the guardian currently returns `true`, but it is probably a better call (pun intended) to make it "safe by default" and return `false` instead. I.e. if you can't explicitly see it, you can't see it at all.

This change makes the change to `Guardian#can_see?` to fall back to `false` if no visibility check method is defined.

For `#can_see_user?` and `#can_see_tag?` we don't have any particular logic that prevents viewing. We previously relied on the implicit `true` value, but since that's now change to `false`, I have explicitly implemented these two methods in `UserGuardian` and `TagGuardian` modules. If in the future we want to add some logic for it, this would be the place.

To be clear, **the behaviour remains the same**, but the `true` value is now explicit rather than implicit.
2023-02-24 15:57:01 +08:00
..
fabricators FIX: dominant color not working for 16bit images (#20300) 2023-02-15 12:41:04 +11:00
fixtures DEV: Remove old secure_media setting (#20259) 2023-02-14 09:41:18 +10:00
helpers DEV: Replace #pluck_first freedom patch with AR #pick in core (#19893) 2023-02-13 12:39:45 +08:00
import_export DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
initializers DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
integration DEV: fix a flakey spec in slugs_controller (#20350) 2023-02-17 18:56:25 +01:00
integrity DEV: Colocate wizard component templates (#20309) 2023-02-15 11:29:22 +00:00
jobs FEATURE: Roll out new search optimisations (#20364) 2023-02-20 11:53:35 +11:00
lib DEV: Make Guardian#can_see? default to false for unwatched objects (#20412) 2023-02-24 15:57:01 +08:00
mailers DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
models FIX: Add support for Europe/Kyiv timezone (#20394) 2023-02-21 11:52:04 -05:00
multisite DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
requests DEV: Apply form template to categories (#20337) 2023-02-23 11:18:14 -08:00
script/import_scripts DEV: Correct syntax_tree violations 2023-02-02 13:03:11 +00:00
serializers UX: Release new user profile navigation for sidebar compatibility (#20134) 2023-02-21 10:16:16 +08:00
services FIX: do not notify admins on suppressed categories (#20238) 2023-02-14 16:45:06 +11:00
support FIX: Fast edit doesn’t work on content with certain characters (#20410) 2023-02-23 11:30:16 +08:00
system DEV: Apply form template to categories (#20337) 2023-02-23 11:18:14 -08:00
tasks FEATURE: Add rake task to mark old hashtag format for rebake (#19876) 2023-01-18 10:16:05 +10:00
views SECURITY: Show only visible tags in metadata 2023-02-23 17:22:20 +01:00
rails_helper.rb DEV: Port sidebar mobile view acceptance tests to system tests (#20421) 2023-02-23 15:01:39 +08:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00