Commit Graph

651 Commits

Author SHA1 Message Date
google-labs-jules[bot]
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]
7ed3a97263 Improve test coverage of ability_spec (#4283)
* Improve test coverage of ability_spec

* Fix specs

* Rubocop

---------

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: Daniel O'Connor <365751+CloCkWeRX@users.noreply.github.com>
2026-04-26 14:21:36 +09:30
Daniel O'Connor
163289e853 Fix RSpec/IndexedLet RuboCop issues in spec files (#4556)
* Fix RSpec/IndexedLet RuboCop issues in spec files

Replace indexed let variable names with descriptive names across 11 spec files.
This improves readability and complies with the RSpec/IndexedLet rule.

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

* Rubocop

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-26 03:10:03 +09:30
Daniel O'Connor
a133eddf21 Rubocop: RSpec/EmptyLineAfterExample 2026-04-25 16:52:34 +00:00
Daniel O'Connor
4a66bdc9fe Merge pull request #4546 from Growstuff/Rails/RedundantActiveRecordAllMethod
Rubocop: Rails/RedundantActiveRecordAllMethod
2026-04-23 23:46:39 +09:30
Daniel O'Connor
3f6dd59dfa Rubocop: Rails/RedundantActiveRecordAllMethod 2026-04-23 13:48:17 +00:00
Daniel O'Connor
ba75afb3f5 Rubocop: RSpecRails/InferredSpecType 2026-04-23 13:39:46 +00:00
Daniel O'Connor
6f59635ca7 Rubocop: RSpec/ExpectChange 2026-04-23 13:23:14 +00:00
Daniel O'Connor
f1acb35520 Merge pull request #4537 from Growstuff/FactoryBot/SyntaxMethods
Rubocop: FactoryBot/SyntaxMethods
2026-04-23 22:29:24 +09:30
Daniel O'Connor
ae639b6e74 Adjust expectation 2025-12-13 02:12:20 +00:00
Daniel O'Connor
ba9117db4d I have added the before_destroy callback to the Crop model to destroy all CropCompanion records where the crop is crop_b. (#4266)
I have added a new test to `spec/models/crop_spec.rb` to verify that deleting a crop also destroys the associated `CropCompanion` records.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-11-29 15:32:47 +10:30
Daniel O'Connor
ce946c3a83 Rubocop fixes 2025-09-20 09:45:56 +00:00
google-labs-jules[bot]
4d3c4ca10d Merge pull request #4154 from Growstuff/finish-expired-seeds-task
Add maintenance task to finish expired seeds
2025-08-28 00:16:16 +09:30
google-labs-jules[bot]
ba6ec689c5 Merge pull request #4150 from Growstuff/feature/failed-plantings
Add failed status to plantings
2025-08-27 23:42:53 +09:30
Daniel O'Connor
948bb78656 Fix percentage grown 2025-08-27 13:44:44 +00:00
google-labs-jules[bot]
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
4f5c47ba58 Ruby 3.2: Rubocop - Layout/* (#3785)
* Rubocop - Layout/*

* Regenerate
2024-07-13 15:19:09 +09:30
Daniel O'Connor
000f4979db Trial Ruby32 (#3418)
* Ruby 3.2/Bundler 2.4

* Fix creation

* Upgrade to js-routes 2. Put all js routes into a global namespace.

* Remove js-routes

* Remove

* Adjust ownership

* Appease codeclimate for the nth time

* Fix deprecation warning by explicitly calling to_fs

* Fix deprecation warning by explicitly calling to_fs

* Fix deprecation warning by explicitly calling to_fs

* Swap to will paginate successor for bootstrap

* Update app/views/members/show.html.haml

* Update app/views/plantings/index.rss.haml

* Update .env

* Update .devcontainer/.env

* Fix spec

* Update spec

* Fix spec

* Pin to 2.4.22

* 3 space indent

* Regenerate

* Update rubocop
2024-07-13 14:45:33 +09:30
Daniel O'Connor
725c146e2d Improve profile page on mobile (#3711)
* Avoid showing when there are 0 things

* Styling

* Styling

* Collapse stats by default on small screens

* Add ARIA skip links

* Refactoring out of partial, and use CSS to set order on mobile

* Remove partial

* Update expectations

* Fix visual appearance on Ban button on your own profile for admins

* Typo

* Stale expectation
2024-04-07 21:43:52 +09:30
Daniel O'Connor
1d52f8fcad Rename 2024-01-22 08:31:33 +00:00
Daniel O'Connor
ee45b518ce Rubocop fixes (Stacked PR) (#3454)
* Fix todo

* Rubcop

* Rubocop

* Rubocop

* Rename harvests_routing_spec.rb to harvests_controller_routing_spec.rb

Making codeclimate happier

* Rename for CodeFactor: updates_routing_spec.rb to posts_controller_updates_routing_spec.rb

For codefactor

* Rename for CodeFactor: follows_routing_spec.rb to follows_controller_routing_spec.rb

* Rename for CodeFactor: forums_routing_spec.rb to forums_controller_routing_spec.rb

* Rename spec/routing/roles_routing_spec.rb to spec/routing/admin/roles_controller_routing_spec.rb

* Rename authentications_routing_spec.rb to authentications_controller_routing_spec.rb

* Rename for CodeFactor: plantings_routing_spec.rb to plantings_controller_routing_spec.rb

* Rename for CodeFactor: scientific_names_routing_spec.rb to scientific_names_controller_routing_spec.rb

* Rename for CodeFactor: seeds_routing_spec.rb to seeds_controller_routing_spec.rb

* Rename for CodeFactor: comments_routing_spec.rb to comments_controller_routing_spec.rb

* Rename for CodeFactor: garden_types_routing_spec.rb to garden_types_controller_routing_spec.rb

* Rename for CodeFactor: admin_routing_spec.rb to admin_controller_routing_spec.rb

* Rename for CodeFactor: gardens_routing_spec.rb to gardens_controller_routing_spec.rb

* Rename for CodeFactor: photos_routing_spec.rb to photos_controller_routing_spec.rb

* Rename for CodeFactor: plant_parts_routing_spec.rb to plant_parts_controller_routing_spec.rb

* Rename for CodeFactor: crops_routing_spec.rb to crops_controller_routing_spec.rb

* [CodeFactor] Apply fixes

* Rename

* Code factor bot

---------

Co-authored-by: Cesy <cesy.avon@gmail.com>
Co-authored-by: codefactor-io <support@codefactor.io>
2024-01-07 21:05:59 +10:30
Daniel O'Connor
d22215f870 Merge branch 'bump-ruby-3.1.x' into rubocop-safe 2022-11-08 00:32:36 +10:30
Daniel O'Connor
96147809ee Fix deprecations 2022-11-08 00:30:44 +10:30
Daniel O'Connor
d1f754a288 Rubocop 2022-11-08 00:23:38 +10:30
Daniel O'Connor
2db3d1bacc Various corrections 2022-11-08 00:21:23 +10:30
Daniel O'Connor
e2942f17c7 Rubocop corrections 2022-11-08 00:18:35 +10:30
Daniel O'Connor
d3df63912c Typo 2022-11-07 23:56:37 +10:30
Daniel O'Connor
b846d995ef Regenerate 2022-11-07 23:34:43 +10:30
Daniel O'Connor
82c7c12cbe Described class 2022-11-07 23:32:12 +10:30
Daniel O'Connor
0843cbde9a Fix specs 2022-11-07 23:32:05 +10:30
Daniel O'Connor
9c0bc3762c Fix specs 2022-11-07 23:32:02 +10:30
Daniel O'Connor
89a2dda637 Revert "Rubocop - auto corrections"
This reverts commit 39ea0d4882.
2022-11-07 23:21:05 +10:30
Daniel O'Connor
39ea0d4882 Rubocop - auto corrections 2022-11-06 16:35:09 +10:30
Daniel O'Connor
b24b9f82e6 Rubocop - auto corrections 2022-11-06 16:34:36 +10:30
Brenda Wallace
9dbf8b7c8f New robocops 2020-08-26 12:36:58 +12:00
Awesome Code
8b2fc2fb0b Auto corrected by following Lint Ruby RSpec/ExampleWording 2020-04-14 09:07:08 +12:00
Awesome Code
132a961008 Auto corrected by following Lint Ruby RSpec/HookArgument 2020-03-04 00:37:36 +00:00
Awesome Code
4cbe6ca244 Auto corrected by following Lint Ruby RSpec/DescribedClass 2020-03-03 22:33:13 +00:00
Martina Simicic
b0a5223d97 Account for finished planting when counting days of life 2020-02-04 10:50:00 +13:00
codefactor-io
34ddf8e98f [CodeFactor] Apply fixes 2020-01-21 13:12:28 +13:00
Brenda Wallace
6cce74cf4d tests we find home page records for plantings 2020-01-12 09:52:47 +13:00
Brenda Wallace
709ca5a04f Fix seeds ES query 2020-01-11 23:10:33 +13:00
Brenda Wallace
c6988e2189 Re-instate the plantings quick actions 2020-01-05 21:31:51 +13:00
codefactor-io
7e30b6b6e0 [CodeFactor] Apply fixes 2020-01-03 11:28:51 +00:00
Brenda Wallace
e24ef32fe6 like spec, don't make so many photso 2020-01-01 08:41:34 +13:00
Brenda Wallace
676345815c tests for photos searching 2019-12-31 21:02:38 +13:00
Brenda Wallace
a3215d2555 Rubocop fixes 2019-12-31 14:47:15 +13:00
Brenda Wallace
c2b4c67077 crop compantion tests 2019-12-28 09:34:04 +13:00
Brenda Wallace
8bec2a277d Merge branch 'dev' into cache/harvests 2019-12-21 16:59:47 +13:00
Brenda Wallace
9c2beb304f show days of progress (#2344)
* show days of progress
* Update planting model spec to use age_in_days
2019-12-21 16:49:43 +13:00