Commit Graph
31 Commits
Author SHA1 Message Date
Daniel O'Connor 8cfef5ce1a Rubocop fixes 2026-04-26 13:09:00 +00:00
3b60e8f974 Implement blocking feature (#4199)
* Implement blocking feature

This commit introduces a blocking feature that allows members to block other members.

A blocked member is prevented from:
- following the blocker
- sending private messages to the blocker
- replying to the blocker's posts
- liking the blocker's content

The implementation includes:
- A new `Block` model and a corresponding database table.
- Updates to the `Member` model to include associations for blocks.
- A new `BlocksController` to handle blocking and unblocking actions.
- New routes for the `BlocksController`.
- UI changes to add block/unblock buttons to the member profile page.
- Validations in the `Follow`, `Comment`, and `Like` models to enforce the blocking rules.
- A check in the `MessagesController` to prevent sending messages to a member who has blocked the sender.
- A callback in the `Block` model to destroy the follow relationship when a block is created.
- New feature and model specs to test the blocking functionality.

* Implement blocking feature and fix failing tests

This commit introduces a blocking feature that allows members to block other members.

A blocked member is prevented from:
- following the blocker
- sending private messages to the blocker
- replying to the blocker's posts
- liking the blocker's content

The implementation includes:
- A new `Block` model and a corresponding database table.
- Updates to the `Member` model to include associations for blocks.
- A new `BlocksController` to handle blocking and unblocking actions.
- New routes for the `BlocksController`.
- UI changes to add block/unblock buttons to the member profile page.
- Validations in the `Follow`, `Comment`, and `Like` models to enforce the blocking rules.
- A check in the `MessagesController` to prevent sending messages to a member who has blocked the sender.
- A callback in the `Block` model to destroy the follow relationship when a block is created.
- New feature and model specs to test the blocking functionality.

This commit also fixes a failing test in the blocking feature. The error was caused by the validation being called even when the `member` association was `nil`. A guard has been added to the validation methods in the `Like`, `Follow`, and `Comment` models to prevent this from happening.

* Generate schema

* Fix tests

* Add permissions

* Define Block permissions in Ability model

The feature specs for member blocking were failing because the "Block"
link was not being rendered on member profiles. This was due to the
lack of explicit create and destroy permissions for the Block resource
in the Ability model, which is used by CanCanCan to authorize actions
and by the view to conditionally show links.

This change adds the necessary permissions to `member_abilities`:
- Allows members to create blocks (except for blocking themselves).
- Allows members to destroy blocks where they are the blocker.

These rules ensure that the "Block" and "Unblock" links are correctly
rendered and authorized for signed-in members.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Comment out specs for now

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
2026-04-26 14:22:32 +09:30
google-labs-jules[bot]andDaniel O'Connor 8564ec7a7c Add comments to photos (#4130)
* Add comments to photos

Extend the photo show page to support comments by logged in users.

- Make the Comment model polymorphic.
- Update the Photo and Post models to have comments.
- Update the comments controller to handle the polymorphic association.
- Update the photo show page to display comments and a comment form.
- Create a reusable comments partial.

* Add migration

* Fix tests

* Fix tests

* Slightly fix tests

* Fix variables

* Add field

* Refactor slightly

* Refactor slightly

* Refactor slightly

* Refactor

* Photos respond to this as well

* Refactor to polymorphic_url

* Rename

* Wrong relationship

* Refactor and fix tests

* Fix relationships

* Fix rendering

* Fix tests

* Fix model tests

* Fix test

* Fix test

* Fix test

* Fix test

* Fix controller spec

* Fix view tests

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
2025-08-24 21:10:16 +09:30
Daniel O'Connor b24b9f82e6 Rubocop - auto corrections 2022-11-06 16:34:36 +10:30
Brenda 13c675d6f7 rewrote order by to not be raw sql 2020-08-26 12:36:58 +12:00
codefactor-io 4ff95fbac9 [CodeFactor] Apply fixes 2020-01-21 22:26:08 +13:00
Brenda aab345cf09 Adding more counter caches 2020-01-10 16:50:52 +13:00
Brenda 7257b2ada1 Update with frozen literals 2020-01-10 16:50:52 +13:00
Brenda Wallace 04fd1a343a Rubocop update (#2334)
* Update rubocop config

* Rubocop update - for rubocop 0.77

* [CodeFactor] Apply fixes

* rubocop fixes

* [CodeFactor] Apply fixes to commit 2826c2e
2019-12-16 22:35:33 +13:00
Brenda Wallace 67ce5265b4 Migrate from paranoia to discard
closes #1995
2019-07-21 16:59:06 +12:00
Brenda Wallace 4a78a30779 Put membet activity on their profile 2019-05-19 15:10:03 +12:00
Brenda Wallace 7b01fcbd4b Align all the hashes 2018-12-30 15:22:29 +13:00
Brenda Wallace 1e7e275684 Adding inverse relationships (except for photos) 2018-10-08 13:43:09 +13:00
Brenda Wallace d1d1a61be3 Added inverse to model 2018-09-29 15:52:32 +12:00
Brenda Wallace 748da6c3e6 Comments from deleted members need to show 2018-06-04 16:02:07 +12:00
Brenda Wallace b6c9b13d4d Models inherit from application record 2018-01-03 17:16:14 +13:00
Brenda Wallace 7719d1f896 Remote default ordering scopes, and clean up models 2017-11-29 20:59:37 +13:00
Brenda Wallace d07509f9e4 Rubocop compliance for comment model 2017-01-14 17:23:39 +13:00
Brenda Wallace 62e7c716dd Removed extra empty blank lines 2016-11-26 12:06:02 +13:00
Daniel O'Connor 4b4e0cf69a $ rubocop --only HashSyntax --auto-correct
483 files inspected, 2018 offenses detected, 2018 offenses corrected
2016-05-19 15:53:11 -04:00
Taylor Griffin acbd3f9a9e implement strong parameters instead of protected attributes 2014-11-18 20:08:54 +11:00
Taylor Griffin 70185156aa use lambda instead of just relation in names scope 2014-11-16 12:11:56 +11:00
Taylor Griffin 40a88b5b09 tests run but fail like whoa 2014-11-15 21:44:55 +11:00
Skud e17dcf8671 Reordered comments: they are now DESC by default
Added scope "post_order" to order them ASC for display on post page.
Also tweaked post/comment views a bit.
2013-05-24 14:36:58 +10:00
Miles Gould bb1e8ede19 Fix misordered comments on post page bug.
https://www.pivotaltracker.com/story/show/46799417
2013-03-28 10:43:47 +00:00
Skud adaee1c9ab don't send notifications to yourself 2013-02-22 17:27:40 +11:00
Skud cdee808933 prettified notifications inbox etc 2013-02-16 01:22:19 +11:00
Skud 528a5ce32c changed to/from to recipient/sender 2013-02-16 00:28:31 +11:00
Skud 4516a2f099 comments now generate notifications 2013-02-16 00:18:49 +11:00
gnattery 6da3e4fae5 Added associations and tested them 2013-02-06 15:20:44 +11:00
gnattery 3cff543184 rails g scaffold Comment 2013-02-06 14:49:49 +11:00