diff --git a/.devcontainer/.env b/.devcontainer/.env index 2ba97513c..56866db42 100644 --- a/.devcontainer/.env +++ b/.devcontainer/.env @@ -1,2 +1,2 @@ # Ruby version -VARIANT=3.1.4 +VARIANT=3.3.4 diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9ed258cc8..2c7c2fad6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/ruby:0-3.1-bullseye +FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye # Install Rails RUN gem install rails:7.0.8 @@ -24,3 +24,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # [Optional] Uncomment this line to install global node packages. # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 + +# We run as the vscode user. +# Make sure this is writable as https://github.com/rubygems/rubygems/issues/6272 was removed +RUN su root -c "mkdir -p /usr/local/rvm/gems/default/cache/bundler/" +RUN su root -c "mkdir -p /usr/local/rvm/gems/default/bundler/gems/" +RUN su root -c "chown -R vscode:rvm /usr/local/rvm/gems/" +RUN su root -c "chmod -R 0755 /usr/local/rvm/gems/" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9bc93941c..9b538e89c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,53 +7,10 @@ updates: time: "07:00" open-pull-requests-limit: 20 versioning-strategy: lockfile-only - ignore: - - dependency-name: active_median - versions: - - "< 0.2.2, >= 0.2.1.a" - - dependency-name: rubocop - versions: - - "< 0.63, >= 0.62.a" - - dependency-name: rubocop - versions: - - "< 0.64, >= 0.63.a" - - dependency-name: sidekiq - versions: - - 5.2.4 - - dependency-name: oj - versions: - - 3.11.4 - - dependency-name: listen - versions: - - 3.5.0 - - dependency-name: rspec-rails - versions: - - 4.1.0 - - 5.0.0 - - dependency-name: searchkick - versions: - - 4.4.3 - - dependency-name: rswag-api - versions: - - 2.3.3 - - dependency-name: rswag-specs - versions: - - 2.3.3 - - dependency-name: rswag-ui - versions: - - 2.3.3 - - dependency-name: timecop - versions: - - 0.9.3 - - dependency-name: puma - versions: - - 5.2.0 - - dependency-name: capybara - versions: - - 3.35.1 - package-ecosystem: github-actions directory: "/" schedule: interval: daily time: "07:00" open-pull-requests-limit: 10 + diff --git a/.github/workflows/brakeman-analysis.yml b/.github/workflows/brakeman-analysis.yml deleted file mode 100644 index 191940f21..000000000 --- a/.github/workflows/brakeman-analysis.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This workflow integrates Brakeman with GitHub's Code Scanning feature -# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications - -name: Brakeman Scan - -# This section configures the trigger for the workflow. Feel free to customize depending on your convention -on: - pull_request: - branches: [ dev ] - -jobs: - brakeman-scan: - name: Brakeman Scan - runs-on: ubuntu-latest - steps: - # Checkout the repository to the GitHub Actions runner - - name: Checkout - uses: actions/checkout@v4 - - # Customize the ruby version depending on your needs - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - - - name: Setup Brakeman - env: - BRAKEMAN_VERSION: '5.1.1' # SARIF support is provided in Brakeman version 4.10+ - run: | - gem install brakeman --version $BRAKEMAN_VERSION - - # Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis - - name: Scan - continue-on-error: true - run: | - brakeman -f sarif -o output.sarif.json . - - # Upload the SARIF file generated in the previous step - - name: Upload SARIF - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: output.sarif.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 167bc6020..4b5f42866 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,15 +106,37 @@ jobs: - name: Prepare database for testing run: bundle exec rails db:prepare - + + + - name: Run rspec (lib) + run: bundle exec rspec spec/lib/ -fd --fail-fast + + - name: Run rspec (services) + run: bundle exec rspec spec/services/ -fd --fail-fast + + - name: Run rspec (models) + run: bundle exec rspec spec/models/ -fd --fail-fast + + - name: Run rspec (controllers) + run: bundle exec rspec spec/controllers/ -fd --fail-fast + + - name: Run rspec (views) + run: bundle exec rspec spec/views/ -fd --fail-fast + + - name: Run rspec (routing) + run: bundle exec rspec spec/routing/ -fd --fail-fast + + - name: Run rspec (request) + run: bundle exec rspec spec/requests/ -fd --fail-fast + - name: precompile assets run: bundle exec rails assets:precompile - + - name: index into elastic search run: bundle exec rails search:reindex - name: Run rspec (report results to Percy.io and CodeClimate) - run: bundle exec rspec spec -fd + run: bundle exec rspec spec/features/ -fd --fail-fast - name: Report to code climate run: | diff --git a/.rubocop.yml b/.rubocop.yml index b42b06f04..c2370187b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,17 @@ inherit_from: .rubocop_todo.yml require: + - rubocop-factory_bot + - rubocop-capybara - rubocop-rails - rubocop-rspec + - rubocop-rspec_rails + - rubocop-rake AllCops: NewCops: enable Exclude: - 'db/schema.rb' - 'vendor/**/*' - TargetRailsVersion: 7.0 + TargetRailsVersion: 7.1 Rails: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4fa490610..3195873c1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,15 +1,37 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-09-16 07:51:19 UTC using RuboCop version 1.56.3. +# on 2024-07-13 05:47:38 UTC using RuboCop version 1.65.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 15 +# Offense count: 231 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: link_or_button, strict +Capybara/ClickLinkOrButtonStyle: + Enabled: false + +# Offense count: 39 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: DefaultSelector. +Capybara/RSpec/HaveSelector: + Exclude: + - 'spec/features/conversations/index_spec.rb' + - 'spec/features/footer_spec.rb' + - 'spec/features/gardens/adding_gardens_spec.rb' + - 'spec/features/harvests/harvesting_a_crop_spec.rb' + - 'spec/features/members/list_spec.rb' + - 'spec/features/plantings/planting_a_crop_spec.rb' + - 'spec/features/seeds/adding_seeds_spec.rb' + - 'spec/features/shared_examples/crop_suggest.rb' + - 'spec/helpers/application_helper_spec.rb' + - 'spec/support/feature_helpers.rb' + - 'spec/views/posts/show.html.haml_spec.rb' + +# Offense count: 14 Capybara/SpecificMatcher: Exclude: - - 'spec/features/crops/browse_crops_spec.rb' - 'spec/features/footer_spec.rb' - 'spec/features/gardens/adding_gardens_spec.rb' - 'spec/features/harvests/harvesting_a_crop_spec.rb' @@ -23,8 +45,7 @@ Capybara/VisibilityMatcher: # Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include, EnforcedStyle, NonImplicitAssociationMethodNames. -# Include: spec/factories.rb, spec/factories/**/*.rb, features/support/factories/**/*.rb +# Configuration parameters: EnforcedStyle, NonImplicitAssociationMethodNames. # SupportedStyles: explicit, implicit FactoryBot/AssociationStyle: Exclude: @@ -33,81 +54,48 @@ FactoryBot/AssociationStyle: - 'spec/factories/like.rb' - 'spec/factories/scientific_name.rb' -# Offense count: 8 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include, EnforcedStyle, ExplicitOnly. -# Include: **/*_spec.rb, **/spec/**/*, spec/factories.rb, spec/factories/**/*.rb, features/support/factories/**/*.rb +# Configuration parameters: AutoCorrect, Include, EnforcedStyle, ExplicitOnly. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb # SupportedStyles: create_list, n_times FactoryBot/CreateList: Exclude: - - 'spec/factories/member.rb' - - 'spec/helpers/gardens_helper_spec.rb' - 'spec/views/comments/index.rss.haml_spec.rb' - - 'spec/views/home/index_spec.rb' - 'spec/views/photos/index.html.haml_spec.rb' - - 'spec/views/places/show.html.haml_spec.rb' - 'spec/views/posts/index.html.haml_spec.rb' -# Offense count: 1135 +# Offense count: 4 +# Configuration parameters: Include, MaxAmount. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +FactoryBot/ExcessiveCreateList: + Exclude: + - 'spec/controllers/posts_controller_spec.rb' + - 'spec/features/crops/show_spec.rb' + - 'spec/features/percy/percy_spec.rb' + +# Offense count: 1127 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb FactoryBot/SyntaxMethods: Enabled: false -# Offense count: 5 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'db/migrate/20171129041341_create_photographings.rb' - - 'db/migrate/20190130090437_add_crop_to_photographings.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'app/mailers/notifier_mailer.rb' - - 'app/models/seed.rb' - - 'lib/tasks/growstuff.rake' - - 'spec/features/rss/plantings_spec.rb' - - 'spec/features/rss/posts_spec.rb' - - 'spec/features/rss/seeds_spec.rb' - - 'spec/models/seed_spec.rb' - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/LineEndStringConcatenationIndentation: - Exclude: - - 'app/mailers/notifier_mailer.rb' - - 'app/models/seed.rb' - - 'lib/tasks/growstuff.rake' - - 'spec/features/rss/plantings_spec.rb' - - 'spec/features/rss/posts_spec.rb' - - 'spec/features/rss/seeds_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: - Max: 304 + Exclude: + - 'app/helpers/crops_helper.rb' + - 'db/seeds.rb' # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperatorPrecedence: - Exclude: - - 'db/seeds.rb' - - 'spec/helpers/gardens_helper_spec.rb' - - 'spec/helpers/seeds_helper_spec.rb' - -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: RequireParenthesesForMethodChains. Lint/AmbiguousRange: Exclude: + - 'app/models/concerns/search_activities.rb' - 'app/models/concerns/search_harvests.rb' - 'app/models/concerns/search_plantings.rb' @@ -130,6 +118,12 @@ Lint/EmptyBlock: - 'spec/features/crops/crop_detail_page_spec.rb' - 'spec/requests/authentications_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'db/migrate/20230313015323_create_active_storage_tables.active_storage.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/RedundantDirGlobSort: @@ -142,48 +136,46 @@ Lint/SuppressedException: Exclude: - 'lib/tasks/testing.rake' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, consistent -Lint/SymbolConversion: - Exclude: - - 'app/controllers/likes_controller.rb' - # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'config.rb' - 'config/compass.rb' -# Offense count: 45 +# Offense count: 52 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 151 -# Offense count: 10 +# Offense count: 14 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 61 + Max: 115 -# Offense count: 6 +# Offense count: 7 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 171 + Max: 188 -# Offense count: 4 +# Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 32 -# Offense count: 61 +# Offense count: 71 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 59 + Max: 127 -# Offense count: 3 +# Offense count: 2 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ModuleLength: + Max: 125 + +# Offense count: 5 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 32 @@ -202,7 +194,7 @@ RSpec/ContextWording: # Offense count: 36 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: @@ -212,6 +204,7 @@ RSpec/DescribedClass: # Offense count: 13 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Exclude: - 'spec/controllers/authentications_controller_spec.rb' @@ -227,24 +220,26 @@ RSpec/EmptyExampleGroup: - 'spec/views/photos/edit.html.haml_spec.rb' - 'spec/views/posts/_single.html.haml_spec.rb' -# Offense count: 134 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. +RSpec/EmptyLineAfterExample: + Exclude: + - 'spec/models/ability_spec.rb' + +# Offense count: 140 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 25 -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ExcessiveDocstringSpacing: - Exclude: - - 'spec/controllers/crops_controller_spec.rb' - - 'spec/features/crops/crop_photos_spec.rb' - -# Offense count: 30 +# Offense count: 32 RSpec/ExpectInHook: Exclude: - 'spec/controllers/garden_types_controller_spec.rb' - 'spec/controllers/gardens_controller_spec.rb' - 'spec/features/admin/forums_spec.rb' + - 'spec/features/admin/plant_parts_spec.rb' + - 'spec/features/admin/roles_spec.rb' - 'spec/features/crops/crop_photos_spec.rb' - 'spec/features/members/list_spec.rb' - 'spec/features/plantings/planting_a_crop_spec.rb' @@ -260,11 +255,12 @@ RSpec/HookArgument: # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. RSpec/HooksBeforeExamples: Exclude: - 'spec/features/crops/creating_a_crop_spec.rb' -# Offense count: 35 +# Offense count: 37 # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. RSpec/IndexedLet: Exclude: @@ -272,6 +268,7 @@ RSpec/IndexedLet: - 'spec/controllers/plantings_controller_spec.rb' - 'spec/features/crops/crop_photos_spec.rb' - 'spec/features/members/list_spec.rb' + - 'spec/features/members/profile_spec.rb' - 'spec/features/percy/percy_spec.rb' - 'spec/features/planting_reminder_spec.rb' - 'spec/features/timeline/index_spec.rb' @@ -279,7 +276,7 @@ RSpec/IndexedLet: - 'spec/models/member_spec.rb' - 'spec/views/forums/index.html.haml_spec.rb' -# Offense count: 710 +# Offense count: 720 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Enabled: false @@ -288,6 +285,12 @@ RSpec/InstanceVariable: RSpec/LetSetup: Enabled: false +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/MatchArray: + Exclude: + - 'spec/models/post_spec.rb' + # Offense count: 2 RSpec/MessageChain: Exclude: @@ -304,16 +307,16 @@ RSpec/MultipleDescribes: Exclude: - 'spec/features/crops/crop_wranglers_spec.rb' -# Offense count: 147 +# Offense count: 152 RSpec/MultipleExpectations: Max: 19 -# Offense count: 137 +# Offense count: 138 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 14 -# Offense count: 132 +# Offense count: 133 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -324,7 +327,7 @@ RSpec/NamedSubject: RSpec/NestedGroups: Max: 6 -# Offense count: 407 +# Offense count: 403 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: @@ -336,21 +339,6 @@ RSpec/PendingWithoutReason: - 'spec/features/seeds/misc_seeds_spec.rb' - 'spec/features/unsubscribing_spec.rb' -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/Rails/HaveHttpStatus: - Exclude: - - 'spec/controllers/api/v1/plantings_controller_spec.rb' - - 'spec/controllers/harvests_controller_spec.rb' - - 'spec/controllers/likes_controller_spec.rb' - - 'spec/requests/harvests_spec.rb' - -# Offense count: 16 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Inferences. -RSpec/Rails/InferredSpecType: - Enabled: false - # Offense count: 2 RSpec/RepeatedDescription: Exclude: @@ -370,6 +358,7 @@ RSpec/RepeatedExampleGroupBody: # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. RSpec/ScatteredSetup: Exclude: - 'spec/features/percy/percy_spec.rb' @@ -382,14 +371,6 @@ RSpec/SpecFilePathFormat: Exclude: - 'spec/controllers/member_controller_spec.rb' -# Offense count: 2 -# Configuration parameters: Include. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/SpecFilePathSuffix: - Exclude: - - 'spec/features/seeds/seed_photos.rb' - - 'spec/models/garden_type.rb' - # Offense count: 3 RSpec/StubbedMock: Exclude: @@ -413,7 +394,24 @@ RSpec/VerifiedDoubles: - 'spec/controllers/gardens_controller_spec.rb' - 'spec/views/devise/shared/_links_spec.rb' -# Offense count: 26 +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ResponseMethods. +# ResponseMethods: response, last_response +RSpecRails/HaveHttpStatus: + Exclude: + - 'spec/controllers/api/v1/plantings_controller_spec.rb' + - 'spec/controllers/harvests_controller_spec.rb' + - 'spec/controllers/likes_controller_spec.rb' + - 'spec/requests/harvests_spec.rb' + +# Offense count: 16 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Inferences. +RSpecRails/InferredSpecType: + Enabled: false + +# Offense count: 28 # Configuration parameters: Database, Include. # SupportedDatabases: mysql, postgresql # Include: db/**/*.rb @@ -436,17 +434,6 @@ Rails/Date: Exclude: - 'app/mailers/notifier_mailer.rb' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Exclude: - - 'app/controllers/crops_controller.rb' - - 'config/application.rb' - - 'config/environments/development.rb' - - 'db/seeds.rb' - # Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -485,12 +472,13 @@ Rails/I18nLocaleAssignment: Rails/I18nLocaleTexts: Enabled: false -# Offense count: 2 +# Offense count: 3 # Configuration parameters: Include. # Include: app/controllers/**/*.rb, app/mailers/**/*.rb Rails/LexicallyScopedActionFilter: Exclude: - 'app/controllers/data_controller.rb' + - 'app/controllers/registrations_controller.rb' # Offense count: 2 Rails/OutputSafety: @@ -498,6 +486,12 @@ Rails/OutputSafety: - 'app/helpers/auto_suggest_helper.rb' - 'app/helpers/gardens_helper.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rails/PluralizationGrammar: + Exclude: + - 'spec/requests/plantings_spec.rb' + # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. @@ -508,8 +502,10 @@ Rails/RakeEnvironment: - 'lib/tasks/i18n.rake' - 'lib/tasks/testing.rake' -# Offense count: 10 +# Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone Rails/RedundantActiveRecordAllMethod: Exclude: - 'app/controllers/admin/roles_controller.rb' @@ -518,7 +514,6 @@ Rails/RedundantActiveRecordAllMethod: - 'app/controllers/plant_parts_controller.rb' - 'app/controllers/scientific_names_controller.rb' - 'app/services/openfarm_service.rb' - - 'spec/features/members/deletion_spec.rb' - 'spec/features/percy/percy_spec.rb' - 'spec/models/harvest_spec.rb' @@ -541,8 +536,8 @@ Rails/ResponseParsedBody: - 'spec/controllers/likes_controller_spec.rb' - 'spec/requests/api/v1/crop_request_spec.rb' - 'spec/requests/api/v1/gardens_request_spec.rb' - - 'spec/requests/api/v1/harvest_request_spec.rb' - - 'spec/requests/api/v1/member_request_spec.rb' + - 'spec/requests/api/v1/harvests_request_spec.rb' + - 'spec/requests/api/v1/members_request_spec.rb' - 'spec/requests/api/v1/photos_request_spec.rb' - 'spec/requests/api/v1/plantings_request_spec.rb' - 'spec/requests/api/v1/seeds_request_spec.rb' @@ -562,26 +557,11 @@ Rails/RootPathnameMethods: - 'app/controllers/crops_controller.rb' - 'app/helpers/icons_helper.rb' -# Offense count: 20 +# Offense count: 21 # Configuration parameters: Include. # Include: db/**/*.rb Rails/ThreeStateBooleanColumn: - Exclude: - - 'db/migrate/20121203034745_add_tos_agreement_to_users.rb' - - 'db/migrate/20130206051328_add_show_email_to_member.rb' - - 'db/migrate/20130212123628_create_notifications.rb' - - 'db/migrate/20130327120024_add_send_email_to_member.rb' - - 'db/migrate/20130517051922_create_account_types.rb' - - 'db/migrate/20130718011247_add_trading_to_seeds.rb' - - 'db/migrate/20130722050836_remove_tradable_from_seeds.rb' - - 'db/migrate/20130827105823_add_newsletter_to_member.rb' - - 'db/migrate/20131025104228_add_fields_to_gardens.rb' - - 'db/migrate/20140829230600_add_finished_to_planting.rb' - - 'db/migrate/20140928085713_add_send_planting_reminder_to_member.rb' - - 'db/migrate/20171022032108_all_the_predictions.rb' - - 'db/migrate/20180213005731_seed_usage.rb' - - 'db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb' - - 'db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb' + Enabled: false # Offense count: 6 # Configuration parameters: Include. @@ -603,6 +583,18 @@ Rails/WhereEquals: - 'app/models/harvest.rb' - 'app/models/planting.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/WhereRange: + Exclude: + - 'app/models/concerns/predict_planting.rb' + - 'app/models/garden.rb' + +# Offense count: 1 +Rake/MethodDefinitionInTask: + Exclude: + - 'lib/tasks/growstuff.rake' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -622,13 +614,7 @@ Style/CommentedKeyword: - 'spec/models/photo_spec.rb' - 'spec/models/planting_spec.rb' -# Offense count: 37 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedVars. -Style/FetchEnvVar: - Enabled: false - -# Offense count: 4 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -636,33 +622,16 @@ Style/FrozenStringLiteralComment: Exclude: - 'config/initializers/new_framework_defaults_6_0.rb' - 'db/migrate/20200801084007_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb' - - 'db/migrate/20200815012538_remove_median_function.rb' - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' -# Offense count: 2 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: Exclude: - 'config/environments/production.rb' + - 'lib/tasks/gbif.rake' - 'lib/tasks/openfarm.rake' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Exclude: - - 'app/models/csv_importer.rb' - - 'spec/requests/api/v1/gardens_request_spec.rb' - - 'spec/requests/api/v1/plantings_request_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Exclude: - - 'bin/setup' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods. @@ -684,19 +653,23 @@ Style/MixinUsage: - 'spec/rails_helper.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/NegatedIfElseCondition: +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: Exclude: - - 'app/helpers/crops_helper.rb' + - 'app/models/activity.rb' -# Offense count: 3 +# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: + - 'app/helpers/crops_helper.rb' - 'app/helpers/harvests_helper.rb' - 'app/helpers/plantings_helper.rb' + - 'app/models/concerns/predict_planting.rb' # Offense count: 6 Style/OpenStructUse: @@ -710,15 +683,6 @@ Style/OptionalBooleanParameter: Exclude: - 'app/models/concerns/member_newsletter.rb' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: same_as_string_literals, single_quotes, double_quotes -Style/QuotedSymbols: - Exclude: - - 'app/models/seed.rb' - - 'spec/controllers/crops_controller_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. @@ -726,12 +690,6 @@ Style/RedundantArgument: Exclude: - 'app/helpers/application_helper.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantConstantBase: - Exclude: - - 'config.ru' - # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SafeForConstants. @@ -739,19 +697,6 @@ Style/RedundantFetchBlock: Exclude: - 'config/puma.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpArgument: - Exclude: - - 'db/migrate/20191119030244_cms_tags.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'app/controllers/messages_controller.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. @@ -760,7 +705,7 @@ Style/SoleNestedConditional: - 'app/controllers/application_controller.rb' - 'app/controllers/messages_controller.rb' -# Offense count: 20 +# Offense count: 24 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: diff --git a/.ruby-version b/.ruby-version index 0aec50e6e..a0891f563 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.4 +3.3.4 diff --git a/Gemfile b/Gemfile index 641f523bf..fc0af803c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,13 +5,13 @@ source 'https://rubygems.org' # Match ruby version in .ruby-version ruby File.read('.ruby-version') -gem 'rails', '~> 7.1.0' +gem 'rails', '~> 7.2.0' # Keeping old sprockets # https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050 gem "sprockets", "<4" -gem 'bundler', '>= 2.3.10' +gem 'bundler', '>= 2.4.22' gem 'coffee-rails' gem 'haml' @@ -167,8 +167,12 @@ group :development, :test do gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework gem 'rswag-specs' + gem 'rubocop-capybara' + gem 'rubocop-factory_bot' gem 'rubocop-rails' + gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'webrat' # provides HTML matchers for view tests gem 'dotenv-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 77c8549ae..ba55e7dcb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,51 +33,46 @@ GEM GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) + actionmailer (7.2.2.1) + actionpack (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (7.2.2.1) + actionview (= 7.2.2.1) + activesupport (= 7.2.2.1) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + useragent (~> 0.16) + actiontext (7.2.2.1) + actionpack (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (7.2.2.1) + activesupport (= 7.2.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -85,52 +80,56 @@ GEM active_link_to (1.0.5) actionpack addressable - active_median (0.4.1) - activesupport (>= 6.1) + active_median (0.5.0) + activesupport (>= 7) active_record_union (1.3.0) activerecord (>= 4.0) - active_utils (3.4.1) + active_utils (3.5.0) activesupport (>= 4.2) i18n - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activesupport (= 7.2.2.1) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (7.2.2.1) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) autoprefixer-rails (10.4.16.0) execjs (~> 2) - axe-core-api (4.9.1) + axe-core-api (4.10.2) dumb_delegator + ostruct virtus - axe-core-capybara (4.9.1) - axe-core-api (= 4.9.1) + axe-core-capybara (4.10.2) + axe-core-api (= 4.10.2) dumb_delegator - axe-core-rspec (4.9.1) - axe-core-api (= 4.9.1) + axe-core-rspec (4.10.2) + axe-core-api (= 4.10.2) dumb_delegator + ostruct virtus axiom-types (0.1.1) descendants_tracker (~> 0.0.4) @@ -138,11 +137,12 @@ GEM thread_safe (~> 0.3, >= 0.3.1) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.4.0) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) rouge (>= 1.0.0) - bigdecimal (3.1.8) + bigdecimal (3.1.9) bluecloth (2.2.0) bonsai-elasticsearch-rails (7.0.1) elasticsearch-model (< 8) @@ -156,10 +156,10 @@ GEM actionpack (>= 6.1) activemodel (>= 6.1) builder (3.3.0) - bullet (7.1.6) + bullet (8.0.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - byebug (11.1.3) + byebug (12.0.0) cancancan (3.6.1) capybara (3.40.0) addressable @@ -183,7 +183,7 @@ GEM image_processing (~> 1.1) marcel (~> 1.0.0) ssrf_filter (~> 1.0) - chartkick (5.0.7) + chartkick (5.1.4) childprocess (5.0.0) codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) @@ -199,20 +199,21 @@ GEM coffee-script-source (1.12.2) comfy_bootstrap_form (4.0.9) rails (>= 5.0.0) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) crass (1.0.6) - csv (3.3.0) - csv_shaper (1.3.2) + csv (3.3.1) + csv_shaper (1.4.0) activesupport (>= 3.0.0) + csv dalli (3.2.8) - database_cleaner (2.0.2) + database_cleaner (2.1.0) database_cleaner-active_record (>= 2, < 3) - database_cleaner-active_record (2.1.0) + database_cleaner-active_record (2.2.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.4) + date (3.4.1) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) devise (4.9.4) @@ -221,13 +222,13 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.5.1) - discard (1.3.0) - activerecord (>= 4.2, < 8) + diff-lcs (1.6.0) + discard (1.4.0) + activerecord (>= 4.2, < 9.0) docile (1.1.5) - dotenv (3.1.2) - dotenv-rails (3.1.2) - dotenv (= 3.1.2) + dotenv (3.1.7) + dotenv-rails (3.1.7) + dotenv (= 3.1.7) railties (>= 6.1) drb (2.2.1) dumb_delegator (1.0.0) @@ -244,22 +245,24 @@ GEM elasticsearch-transport (7.0.0) faraday multi_json - erubi (1.13.0) + erubi (1.13.1) erubis (2.7.0) - excon (0.110.0) - execjs (2.9.1) - factory_bot (6.4.5) - activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) - railties (>= 5.0.0) - faker (3.4.1) - i18n (>= 1.8.11, < 2) - faraday (2.10.0) - faraday-net_http (>= 2.0, < 3.2) + excon (1.2.5) logger - faraday-net_http (3.1.0) - net-http + execjs (2.10.0) + factory_bot (6.5.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) + railties (>= 5.0.0) + faker (3.5.1) + i18n (>= 1.8.11, < 2) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-net_http (3.4.0) + net-http (>= 0.5.0) ffi (1.16.3) flickraw (0.9.10) font-awesome-sass (5.15.1) @@ -267,7 +270,7 @@ GEM friendly_id (5.5.1) activerecord (>= 4.0.0) gbifrb (0.2.0) - geocoder (1.8.3) + geocoder (1.8.5) base64 (>= 0.1.0) csv (>= 3.0.0) gibbon (1.2.1) @@ -293,26 +296,29 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.58.0) + haml_lint (0.61.1) haml (>= 5.0) parallel (~> 1.10) rainbow rubocop (>= 1.0) sysexits (~> 1.1) hashie (5.0.0) - heroics (0.1.2) + heroics (0.1.3) + base64 erubis (~> 2.0) excon moneta multi_json (>= 1.9.2) webrick - highline (3.0.1) - httparty (0.21.0) + highline (3.1.2) + reline + httparty (0.22.0) + csv mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) - i18n-tasks (1.0.14) + i18n-tasks (1.0.15) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi @@ -321,25 +327,28 @@ GEM parser (>= 3.2.2.1) rails-i18n rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.8, >= 1.8.1) terminal-table (>= 1.5.1) - icalendar (2.10.1) + icalendar (2.10.3) ice_cube (~> 0.16) - ice_cube (0.16.4) + ostruct + ice_cube (0.17.0) ice_nine (0.11.2) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - io-console (0.7.2) - irb (1.13.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.7.2) - json-schema (4.1.1) - addressable (>= 2.8) + json (2.10.2) + json-schema (5.1.0) + addressable (~> 2.8) jsonapi-resources (0.10.7) activerecord (>= 4.1) concurrent-ruby @@ -348,20 +357,21 @@ GEM kgio (2.11.4) kramdown (2.4.0) rexml - language_server-protocol (3.17.0.3) - launchy (3.0.0) + language_server-protocol (3.17.0.4) + launchy (3.0.1) addressable (~> 2.8) childprocess (~> 5.0) - leaflet-rails (1.9.4) + leaflet-rails (1.9.5) actionpack (>= 4.2.0) railties (>= 4.2.0) letter_opener (1.10.0) launchy (>= 2.2, < 4) + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.0) - loofah (2.22.0) + logger (1.7.0) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -380,22 +390,22 @@ GEM railties (>= 3.2) matrix (0.4.2) memcachier (0.0.2) - method_source (1.0.0) + method_source (1.1.0) mimemagic (0.4.3) nokogiri (~> 1) rake mini_magick (4.12.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.24.1) + mini_portile2 (2.8.8) + minitest (5.25.5) moneta (1.0.0) - msgpack (1.7.2) + msgpack (1.8.0) multi_json (1.15.0) - multi_xml (0.6.0) - mutex_m (0.2.0) - net-http (0.4.1) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + net-http (0.6.0) uri - net-imap (0.4.11) + net-imap (0.4.19) date net-protocol net-pop (0.1.2) @@ -404,15 +414,16 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) - nokogiri (1.16.6) + nio4r (2.7.4) + nokogiri (1.18.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nokogiri (1.18.4-x86_64-linux-gnu) racc (~> 1.4) oauth (0.5.6) - oj (3.16.4) + oj (3.16.10) bigdecimal (>= 3.0) + ostruct (>= 0.2) omniauth (1.9.2) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) @@ -426,29 +437,35 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - parallel (1.25.1) - parser (3.3.3.0) + ostruct (0.6.1) + parallel (1.26.3) + parser (3.3.7.3) ast (~> 2.4.1) racc percy-capybara (5.0.0) capybara (>= 3) - pg (1.5.6) - platform-api (3.7.0) + pg (1.5.9) + platform-api (3.8.0) heroics (~> 0.1.1) moneta (~> 1.0.0) rate_throttle_client (~> 0.1.0) popper_js (2.11.8) - pry (0.14.2) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + prism (1.4.0) + pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.1.2) + psych (5.2.3) + date stringio - public_suffix (5.0.5) - puma (6.4.2) + public_suffix (6.0.1) + puma (6.6.0) nio4r (~> 2.0) - query_diet (0.7.1) - racc (1.8.0) - rack (2.2.9) + query_diet (0.7.2) + racc (1.8.1) + rack (2.2.13) rack-cors (2.0.2) rack (>= 2.0.0) rack-protection (3.2.0) @@ -456,25 +473,25 @@ GEM rack (~> 2.2, >= 2.2.4) rack-session (1.0.2) rack (< 3) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rackup (1.0.0) + rackup (1.0.1) rack (< 3) webrick - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (7.2.2.1) + actioncable (= 7.2.2.1) + actionmailbox (= 7.2.2.1) + actionmailer (= 7.2.2.1) + actionpack (= 7.2.2.1) + actiontext (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activemodel (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 7.2.2.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -483,10 +500,10 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - rails-i18n (7.0.9) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) rails_12factor (0.0.3) @@ -494,99 +511,114 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb + railties (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - raindrops (0.20.0) + raindrops (0.20.1) rake (13.2.1) rate_throttle_client (0.1.2) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.7.0) + rdoc (6.12.0) psych (>= 4.0.0) - recaptcha (5.17.0) - redis-client (0.22.2) + recaptcha (5.19.0) + redis-client (0.23.2) connection_pool - regexp_parser (2.9.2) - reline (0.5.9) + regexp_parser (2.10.0) + reline (0.6.0) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.1) - strscan + rexml (3.4.1) rouge (4.1.2) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-activemodel-mocks (1.2.0) + rspec-activemodel-mocks (1.2.1) activemodel (>= 3.0) activesupport (>= 3.0) rspec-mocks (>= 2.99, < 4.0) - rspec-core (3.13.0) + rspec-core (3.13.3) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.3) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) + rspec-rails (7.1.1) + actionpack (>= 7.0) + activesupport (>= 7.0) + railties (>= 7.0) rspec-core (~> 3.13) rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.1) + rspec-support (3.13.2) rspectre (0.1.0) parser (>= 3.2.2.1) rspec (~> 3.9) - rswag-api (2.13.0) - activesupport (>= 3.1, < 7.2) - railties (>= 3.1, < 7.2) - rswag-specs (2.13.0) - activesupport (>= 3.1, < 7.2) - json-schema (>= 2.2, < 5.0) - railties (>= 3.1, < 7.2) + rswag-api (2.16.0) + activesupport (>= 5.2, < 8.1) + railties (>= 5.2, < 8.1) + rswag-specs (2.16.0) + activesupport (>= 5.2, < 8.1) + json-schema (>= 2.2, < 6.0) + railties (>= 5.2, < 8.1) rspec-core (>= 2.14) - rswag-ui (2.13.0) - actionpack (>= 3.1, < 7.2) - railties (>= 3.1, < 7.2) - rubocop (1.64.1) + rswag-ui (2.16.0) + actionpack (>= 5.2, < 8.1) + railties (>= 5.2, < 8.1) + rubocop (1.75.1) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.43.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) - rubocop-rails (2.25.1) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.43.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-factory_bot (2.27.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rails (2.30.3) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.0.2) - rubocop (~> 1.61) + rubocop (>= 1.72.1, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) + rubocop-rake (0.7.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-rspec (3.5.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec_rails (2.31.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (~> 3.5) ruby-progressbar (1.13.0) - ruby-units (4.0.3) + ruby-units (4.1.0) ruby-vips (2.2.1) ffi (~> 1.12) - rubyzip (2.3.2) + rubyzip (2.4.1) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -600,19 +632,20 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (5.3.8) + scout_apm (5.6.1) parser searchkick (5.3.1) activemodel (>= 6.1) hashie - selenium-webdriver (4.22.0) + securerandom (0.4.1) + selenium-webdriver (4.30.1) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sidekiq (7.3.0) - concurrent-ruby (< 2) + sidekiq (7.3.9) + base64 connection_pool (>= 2.3.0) logger rack (>= 2.2.4) @@ -622,7 +655,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sprockets (3.7.3) + sprockets (3.7.5) base64 concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -631,32 +664,35 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) ssrf_filter (1.1.2) - stringio (3.1.1) - strscan (3.1.0) + stringio (3.1.5) sysexits (1.2.0) temple (0.10.3) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) - terser (1.2.3) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + terser (1.2.5) execjs (>= 0.3.0, < 3) - thor (1.3.1) + thor (1.3.2) thread_safe (0.3.6) - tilt (2.3.0) + tilt (2.6.0) timecop (0.9.10) - timeout (0.4.1) + timeout (0.4.3) trollop (1.16.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) unicorn (6.1.0) kgio (~> 2.6) raindrops (~> 0.7) uniform_notifier (1.16.0) - uri (0.13.0) + uri (1.0.3) + useragent (0.16.11) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix - vcr (6.2.0) + vcr (6.3.1) + base64 virtus (2.0.0) axiom-types (~> 0.1) coercible (~> 1.0) @@ -667,8 +703,8 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) - webrick (1.8.1) - websocket (1.2.10) + webrick (1.9.1) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -679,7 +715,7 @@ GEM webrick xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.16) + zeitwerk (2.7.2) PLATFORMS ruby @@ -698,7 +734,7 @@ DEPENDENCIES bootstrap-datepicker-rails bootstrap_form (>= 4.5.0) bullet - bundler (>= 2.3.10) + bundler (>= 2.4.22) byebug cancancan capybara @@ -757,7 +793,7 @@ DEPENDENCIES query_diet rack-cors rack-protection (>= 2.0.1) - rails (~> 7.1.0) + rails (~> 7.2.0) rails-assets-leaflet.markercluster! rails-controller-testing rails_12factor @@ -771,8 +807,12 @@ DEPENDENCIES rswag-specs rswag-ui rubocop + rubocop-capybara + rubocop-factory_bot rubocop-rails + rubocop-rake rubocop-rspec + rubocop-rspec_rails ruby-units sassc-rails scout_apm @@ -791,7 +831,7 @@ DEPENDENCIES xmlrpc RUBY VERSION - ruby 3.1.4p223 + ruby 3.3.4p94 BUNDLED WITH - 2.3.11 + 2.4.22 diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 801617ff9..768d54c34 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -1,11 +1,19 @@ $(document).ready(function() { $('.like-btn').show(); - $('.post-like').on('ajax:success', function(event, data) { - var likeButton = $('#post-' + data.id + ' .post-like'); - var likeBadge = $('#post-'+ data.id + ' .like-badge'); + /** + * Handles the result of an ajax call and updates UI + * + * @param {object} data JSON data from ajax response + * @param {string} type object type (ie: post, activity, etc) + */ + var likeableSuccess = function(data, type) { + var target = '.' + type + '-' + data.id; + var objectClass = type.charAt(0).toUpperCase() + type.slice(1); + var likeButton = $(target + ' .' + type + '-like'); + var likeBadge = $(target + ' .like-badge'); - $('#post-' + data.id + ' .like-count').text(data.like_count); + $(target + ' .like-count').text(data.like_count); if (data.liked_by_member) { likeBadge.addClass('liked'); likeButton.data('method', 'delete'); @@ -14,11 +22,26 @@ $(document).ready(function() { } else { likeBadge.removeClass('liked'); likeButton.data('method', 'post'); - likeButton.attr('href', '/likes.json?type=Post&id=' + data.id); + likeButton.attr('href', '/likes.json?type=' + objectClass + '&id=' + data.id); likeButton.text('Like'); } + }; + + $('.post-like').on('ajax:success', function(event, data) { + likeableSuccess(data, 'post'); }); + $('.activity-like').on('ajax:success', function(event, data) { + likeableSuccess(data, 'activity'); + }); + + $('.planting-like').on('ajax:success', function(event, data) { + likeableSuccess(data, 'planting'); + }); + + $('.harvest-like').on('ajax:success', function(event, data) { + likeableSuccess(data, 'harvest'); + }); $('.photo-like').on('ajax:success', function(event, data) { var likeBadge = $('#photo-'+ data.id + ' .like-badge'); diff --git a/app/assets/stylesheets/_plantings.scss b/app/assets/stylesheets/_plantings.scss index a65aeb75c..98f6cf862 100755 --- a/app/assets/stylesheets/_plantings.scss +++ b/app/assets/stylesheets/_plantings.scss @@ -47,4 +47,13 @@ margin-left: auto; } } + + .card-footer { + max-height: 2em; + -webkit-line-clamp: 1; + overflow: hidden; + text-overflow: ellipsis; + margin-bottom: 0.5em; + padding-top: 0; + } } diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 4db01eb15..116db6012 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -8,6 +8,9 @@ body { font-family: $default-font; } +.navbar { + flex-wrap: nowrap; +} .navbar-brand { .site-name { font-family: "Modak", cursive; @@ -16,7 +19,7 @@ body { } img { - height: 60px; + height: 100%; } } diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index f4e236e3a..08e8aa4bd 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -29,7 +29,8 @@ class ActivitiesController < DataController def new @activity = Activity.new( - owner: current_member + owner: current_member, + due_date: Date.today ) if params[:garden_id] @activity.garden = Garden.find_by( @@ -81,8 +82,8 @@ class ActivitiesController < DataController end def specifics - if @owner.present? - "#{@owner.to_param}-" - end + return if @owner.blank? + + "#{@owner.to_param}-" end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 43bf8f694..7db3be745 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,9 +3,7 @@ class ApplicationController < ActionController::Base protect_from_forgery # Working from codespaces, we want to turn off validation - if Rails.env.development? && ENV['CODESPACE_NAME'] - skip_before_action :verify_authenticity_token - end + skip_before_action :verify_authenticity_token if Rails.env.development? && ENV['CODESPACE_NAME'] include ApplicationHelper diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index d974b9201..a80234bfb 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -81,7 +81,7 @@ class CropsController < ApplicationController @companions = @crop.companions.approved end format.svg do - icon_data = @crop.svg_icon.presence || File.read(Rails.root.join('app', 'assets', 'images', 'icons', 'sprout.svg')) + icon_data = @crop.svg_icon.presence || File.read(Rails.root.join("app/assets/images/icons/sprout.svg")) send_data(icon_data, type: "image/svg+xml", disposition: "inline") end format.json do @@ -113,7 +113,12 @@ class CropsController < ApplicationController @crop.approval_status = "pending" end - notify_wranglers if Crop.transaction { @crop.save && save_crop_names } + if Crop.transaction { @crop.save && save_crop_names } + notify_wranglers + else + @crop.alternate_names.build + @crop.scientific_names.build + end respond_with @crop end diff --git a/app/controllers/garden_collaborators_controller.rb b/app/controllers/garden_collaborators_controller.rb new file mode 100644 index 000000000..50804e288 --- /dev/null +++ b/app/controllers/garden_collaborators_controller.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +class GardenCollaboratorsController < ApplicationController + before_action :authenticate_member!, except: %i(index show) + before_action :load_garden + load_and_authorize_resource id_param: :slug + + respond_to :html + responders :flash + + def index + @garden_collaborators = @garden.garden_collaborators.paginate(page: params[:page]) + respond_with(@garden_collaborators) + end + + def show + @garden_collaborator = GardenCollaborator.find(params[:garden_collaborator_id]) + + respond_with(@garden_collaborator) + end + + def new + @garden_collaborator = GardenCollaborator.new(garden: @garden) + + authorize! :create, @garden_collaborator + + respond_with(@garden_collaborator) + end + + def edit + @garden_collaborator = GardenCollaborator.find(params[:id]) + + authorize! :update, @garden_collaborator + + respond_with(@garden_collaborator) + end + + def create + @garden_collaborator = GardenCollaborator.new(garden: @garden) + authorize! :create, @garden_collaborator + + @member = Member.find_by(slug: params[:garden_collaborator][:member_slug]) + + @garden_collaborator.member = @member + if @garden_collaborator.save + redirect_to garden_garden_collaborators_path(@garden) + else + respond_with(@garden_collaborator) + end + end + + def update + @garden_collaborator = GardenCollaborator.find(params[:id]) + authorize! :update, @garden_collaborator + + @member = Member.find_by(slug: params[:garden_collaborator][:member_slug]) + + @garden_collaborator.member = @member + @garden_collaborator.save + + respond_with(@garden_collaborator) + end + + def destroy + @garden_collaborator = GardenCollaborator.find(params[:id]) + + authorize! :destroy, @garden_collaborator + + if @garden_collaborator.destroy + redirect_to garden_garden_collaborators_path(@garden) + else + respond_with(@garden_collaborator) + end + end + + private + + def load_garden + @garden = Garden.find_by(slug: params[:garden_slug]) + end + + def garden_collaborator_params + params.require(:garden_collaborator).permit( + :member_slug + ) + end +end diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 8fc3be890..cfca79acb 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -8,7 +8,10 @@ class GardensController < DataController @gardens = @gardens.includes(:owner) @gardens = @gardens.active unless @show_all - @gardens = @gardens.where(owner: @owner) if @owner.present? + if @owner.present? + @gardens = @gardens.left_joins(:garden_collaborators) + @gardens = @gardens.where(owner: @owner).or(@gardens.where(garden_collaborators: { member: @owner })) + end @gardens = @gardens.where.not(members: { confirmed_at: nil }) .order(:name).paginate(page: params[:page]) respond_with(@gardens) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 638a5038c..3093ce42e 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -58,7 +58,7 @@ class LikesController < ApplicationController def failed(like, message) respond_to do |format| - format.json { render(json: { 'error': message }, status: :forbidden) } + format.json { render(json: { error: message }, status: :forbidden) } format.html do flash[:error] = message if like&.likeable diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 1211e870e..2099ffd46 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -61,7 +61,7 @@ class MembersController < ApplicationController end def unsubscribe - verifier = ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN']) + verifier = ActiveSupport::MessageVerifier.new(ENV.fetch('RAILS_SECRET_TOKEN', nil)) decrypted_message = verifier.verify(params[:message]) @member = Member.find(decrypted_message[:member_id]) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9efc7ae42..bd34e3ce1 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -21,7 +21,7 @@ class MessagesController < ApplicationController return if params[:recipient_id].blank? @recipient = Member.find_by(id: params[:recipient_id]) - return if @recipient.nil? + nil if @recipient.nil? end def create diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index e19114b88..e8e54befb 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -41,7 +41,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController def after_sign_in_path_for(resource) if resource.tos_agreement - super(resource) + super else finish_signup_path(resource) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee1b6d7e2..992dc1b6b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,12 +28,6 @@ module ApplicationHelper "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" end - def required_field_help_text - asterisk = tag.span('*', class: ['red']) - text = tag.em('denotes a required field') - tag.div(asterisk + ' '.html_safe + text, class: ['margin-bottom']) - end - # A helper to replace the complex template compilation mess # of HAML, Tilt, and dynamic compilation with interpolated ruby. def markdownify(text) diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb index 1b8521c82..ff0558ef2 100644 --- a/app/helpers/auto_suggest_helper.rb +++ b/app/helpers/auto_suggest_helper.rb @@ -13,7 +13,7 @@ module AutoSuggestHelper resource = resource.class.name.downcase source_path = Rails.application.routes.url_helpers.send("search_#{source}s_path", format: :json) %( -