Adds the `sitemap_generator` gem to generate a sitemap.
- Includes static routes and dynamic routes for active crops, plantings, seeds, photos, posts, and members.
- Implements a caching mechanism to ensure the sitemap is generated no more frequently than every 72 hours.
- Updates `robots.txt` to point to the new sitemap.
- Includes a unit test for the caching Rake task.
The `crops/show` view spec was failing with a `NoMethodError` because
the `@version_members` instance variable was `nil`. This variable is used
in the `_history` partial, which is rendered by the `show` view.
This commit fixes the spec by initializing `@version_members` to an
empty hash in the `before` block of the spec. This ensures that the
view can render without errors during the test run.
* feat(admin): add revert functionality to crops page
This change adds a "Revert" button to the admin crops page, allowing crop wranglers to revert changes to a previous version.
It introduces a new `Admin::VersionsController` with a `revert` action that uses `paper_trail`'s `reify` method to restore a previous version of a `Crop` object.
The view is updated to include a "Revert" button, which is guarded by a `can?(:wrangle, Crop)` check to ensure only authorized users can see it.
The controller also includes an authorization check to prevent unauthorized users from accessing the revert action directly.
A feature spec is added to test the new functionality, including the authorization logic.
* Consistent UX
* Specs
---------
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>
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>
* This change introduces a new feature that allows users to create recurring activities.
A user can now specify that an activity should be repeated "X" times, every "Y" weeks. When an activity is created with these options, the application will create the initial activity and then "X" additional copies, with each copy's due date offset by "Y" weeks from the previous one.
The repeat information is not stored in the database. It is only used at the time of creation to generate the recurring activities.
The following changes were made:
- Updated the new activity form to include fields for "repeat times" and "repeat weeks".
- Modified the `ActivitiesController#create` action to handle the creation of recurring activities.
- Added feature tests to ensure the new functionality works as expected.
* Remove not very useful spec
---------
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>
* feat: Add API token generation and authentication
This commit introduces API token generation and authentication for write operations.
- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.
* feat: Add API token generation and authentication
This commit introduces API token generation and authentication for write operations.
- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.
* Mark as editable
* Refactor
* WIP - Authentication
* Implement more test coverage
* Split 401 and 403
* Before Create hooks
* Update harvest specs, defaulting to the first plant part - this may not be right
* Update coverage
* Update coverage
* Rubocop
* Rubocop
* Rubocop
* Fix coverage
* For now, mark photos immutable again
* Fix specs
* Fix specs
* Rubocop
* Fix specs
---------
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>
This commit adds instructions for mobile users on how to install the Growstuff website as a Progressive Web App (PWA).
The changes include:
- A new section on the homepage with instructions for both iOS and Android devices. This section is only visible to logged-out users.
- New translations for the instructions in the `en.yml` locale file.
- Basic styling for the new section.
- Updated feature tests to verify the new section's visibility.
* I will add the international alternate names for the crops.
* Mark required
* Update factory
* Add placeholder
* Fix seeds
* Add language, though hardcoded to EN in most places
---------
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>
* 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>
This change removes the twitter authentication feature from the application.
It removes the `omniauth-twitter` gem and all related code from controllers, views, and tests. It also removes the twitter icon and environment variable settings.
* Split feature tests off to own area
* Split up feature specs
* Split up feature specs
* Split up feature specs
* Split up pipeline
* Split up pipeline
* Split up pipeline
* Split up pipeline
* Split further
* Improve stability slightly
* Skip tagged flaky
* Split mroe
* Improve reliability of test
* Improve reliability of test
* Extra asserts
* Increase reliability by asserting the current path is right
* Comment out unreliable area