Skip to content

Add comprehensive authorization tests for Book privacy - #1470

Open
drusepth wants to merge 2 commits into
tailwind-redesignfrom
claude/created-books-default-visibility-ud1jak
Open

Add comprehensive authorization tests for Book privacy#1470
drusepth wants to merge 2 commits into
tailwind-redesignfrom
claude/created-books-default-visibility-ud1jak

Conversation

@drusepth

Copy link
Copy Markdown
Member

Fixes #

Changes proposed:

  • Add BookAuthorizerTest with comprehensive test coverage for book privacy and authorization logic
  • Test default privacy behavior (books are private by default)
  • Test privacy inheritance from universes (public universes make books readable)
  • Test access control for read, update, and delete operations based on privacy settings
  • Test scope filtering (is_public) correctly excludes private books without public universes
  • Verify anonymous users and strangers cannot access private content

Test Plan:

All authorization scenarios are covered by the new test suite. Run with:

rails test test/authorizers/book_authorizer_test.rb

The tests verify the HasPrivacy concern implementation for books, including edge cases like universe-less books and privacy inheritance from parent universes.

@indentlabs/contributors

https://claude.ai/code/session_01FndSaxFpDnyhC2pShjxR4h

claude added 2 commits August 14, 2026 06:54
Books default to private via the privacy column default, and a book
created outside a universe has no way to become public: every
universe-based branch in BookAuthorizer#readable_by? is guarded by a
universe.present? check, and HasPrivacy#is_public joins against a NULL
universes.privacy that cannot match 'public'.

These tests pin that behavior down, and document the one case where a
book is readable despite its own privacy being 'private': when it
belongs to a public universe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FndSaxFpDnyhC2pShjxR4h
A book in a public universe is readable by anyone even when its own
privacy is 'private', but the settings sidebar showed a plain "Book is
Private" and the reader view told the author only they could see it.
Both now report the inherited visibility:

- the status banner reads "Public (through its universe)"
- a notice links to the universe and explains that making the universe
  private is what restores access control
- the private-chapter warning now also fires on inherited visibility,
  and points at the universe rather than the book's own toggle

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FndSaxFpDnyhC2pShjxR4h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants