Compare commits

..

4 Commits

Author SHA1 Message Date
Daniel O'Connor
1511de8a81 Merge branch 'dev' into fix-naming 2025-09-02 08:41:12 +09:30
Daniel O'Connor
df15383dd0 Merge branch 'dev' into fix-naming 2025-03-29 14:24:31 +10:30
Daniel O'Connor
bcaeaf3688 Merge branch 'dev' into fix-naming 2024-07-13 13:29:09 +09:30
Daniel O'Connor
2fc5b63c0e Change naming to be aware of plant parts, even if it sounds oddly format 2024-03-23 06:57:11 +00:00
76 changed files with 361 additions and 540 deletions

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (admin/)
run: bundle exec rspec spec/features/admin/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (comments/)
run: bundle exec rspec spec/features/comments/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -101,9 +101,3 @@ jobs:
- name: Run rspec (conversations/)
run: bundle exec rspec spec/features/conversations/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (crops/)
run: bundle exec rspec spec/features/crops/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (gardens/)
run: bundle exec rspec spec/features/gardens/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -99,11 +99,4 @@ jobs:
run: bundle exec rails search:reindex
- name: Run rspec (harvests/)
run: bundle exec rspec spec/features/harvests/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots
run: bundle exec rspec spec/features/harvests/ -fd -t ~@flaky

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -99,11 +99,4 @@ jobs:
run: bundle exec rails search:reindex
- name: Run rspec (home/)
run: bundle exec rspec spec/features/home/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots
run: bundle exec rspec spec/features/home/ -fd -t ~@flaky

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -99,11 +99,4 @@ jobs:
run: bundle exec rails search:reindex
- name: Run rspec (members/)
run: bundle exec rspec spec/features/members/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots
run: bundle exec rspec spec/features/members/ -fd -t ~@flaky

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (places/)
run: bundle exec rspec spec/features/places/ -fd
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (plantings/)
run: bundle exec rspec spec/features/plantings/ -fd
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -1,4 +1,4 @@
name: CI Features - Posts
name: CI Features - Admin
on: [pull_request]
@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (posts/)
run: bundle exec rspec spec/features/posts/ -fd
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -100,10 +100,3 @@ jobs:
- name: Run rspec (seeds/)
run: bundle exec rspec spec/features/seeds/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -99,11 +99,4 @@ jobs:
run: bundle exec rails search:reindex
- name: Run rspec (timeline/)
run: bundle exec rspec spec/features/timeline/ -fd -t ~@flaky
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots
run: bundle exec rspec spec/features/timeline/ -fd -t ~@flaky

View File

@@ -74,7 +74,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'
@@ -108,11 +108,4 @@ jobs:
run: bundle exec rspec spec/features/photos/ -fd
- name: Run rspec (rss/)
run: bundle exec rspec spec/features/rss/ -fd
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tmp/screenshots
run: bundle exec rspec spec/features/rss/ -fd

View File

@@ -89,7 +89,7 @@ jobs:
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v5
uses: actions/setup-node@v4
with:
node-version: '12'

View File

@@ -1,5 +1,5 @@
inherit_from: .rubocop_todo.yml
plugins:
require:
- rubocop-factory_bot
- rubocop-capybara
- rubocop-rails

View File

@@ -1,30 +1,18 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-09-07 08:46:49 UTC using RuboCop version 1.80.2.
# 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: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 231
# Configuration parameters: EnforcedStyle.
# SupportedStyles: link_or_button, strict
Capybara/ClickLinkOrButtonStyle:
Enabled: false
# Offense count: 18
Capybara/NegationMatcherAfterVisit:
Exclude:
- 'spec/features/crops/crop_detail_page_spec.rb'
- 'spec/features/crops/crop_wranglers_spec.rb'
- 'spec/features/gardens/gardens_spec.rb'
- 'spec/features/members/deletion_spec.rb'
- 'spec/features/members/following_spec.rb'
- 'spec/features/members/profile_spec.rb'
- 'spec/features/plantings/planting_a_crop_spec.rb'
# Offense count: 34
# Offense count: 39
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: DefaultSelector.
Capybara/RSpec/HaveSelector:
@@ -37,6 +25,7 @@ Capybara/RSpec/HaveSelector:
- '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'
@@ -67,7 +56,8 @@ FactoryBot/AssociationStyle:
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, ExplicitOnly.
# Configuration parameters: AutoCorrect, Include, EnforcedStyle, ExplicitOnly.
# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb
# SupportedStyles: create_list, n_times
FactoryBot/CreateList:
Exclude:
@@ -76,29 +66,31 @@ FactoryBot/CreateList:
- 'spec/views/posts/index.html.haml_spec.rb'
# Offense count: 4
# Configuration parameters: MaxAmount.
# 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: 1144
# 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: 3
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'app/models/concerns/predict_planting.rb'
- 'app/models/member.rb'
- 'app/helpers/crops_helper.rb'
- 'db/seeds.rb'
# Offense count: 4
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: RequireParenthesesForMethodChains.
Lint/AmbiguousRange:
@@ -106,20 +98,14 @@ Lint/AmbiguousRange:
- 'app/models/concerns/search_activities.rb'
- 'app/models/concerns/search_harvests.rb'
- 'app/models/concerns/search_plantings.rb'
- 'db/seeds.rb'
# Offense count: 2
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
- 'app/models/harvest.rb'
- 'lib/actions/oauth_signup_action.rb'
# Offense count: 1
Lint/DuplicateMethods:
Exclude:
- 'app/models/planting.rb'
# Offense count: 8
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
@@ -138,6 +124,12 @@ 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:
Exclude:
- 'spec/rails_helper.rb'
# Offense count: 1
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
@@ -145,18 +137,14 @@ Lint/SuppressedException:
- 'lib/tasks/testing.rake'
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'config.rb'
- 'config/compass.rb'
# Offense count: 1
Lint/UselessConstantScoping:
Exclude:
- 'app/controllers/members_controller.rb'
# Offense count: 55
# Offense count: 52
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 151
@@ -165,42 +153,33 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 116
Max: 115
# Offense count: 9
# Offense count: 7
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 181
Max: 188
# Offense count: 8
# Offense count: 6
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 32
# Offense count: 73
# Offense count: 71
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 128
Max: 127
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 132
Max: 125
# Offense count: 7
# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 32
# Offense count: 2
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
# AllowedMethods: call
# WaywardPredicates: nonzero?
Naming/PredicateMethod:
Exclude:
- 'app/models/concerns/finishable.rb'
- 'app/models/seed.rb'
# Offense count: 3
RSpec/AnyInstance:
Exclude:
@@ -225,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'
@@ -240,10 +220,17 @@ RSpec/EmptyExampleGroup:
- 'spec/views/photos/edit.html.haml_spec.rb'
- 'spec/views/posts/_single.html.haml_spec.rb'
# Offense count: 137
# 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: 27
Max: 25
# Offense count: 32
RSpec/ExpectInHook:
@@ -258,8 +245,17 @@ RSpec/ExpectInHook:
- 'spec/features/plantings/planting_a_crop_spec.rb'
- 'spec/features/shared_examples/append_date.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Exclude:
- 'spec/requests/api/v1/plantings_request_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
RSpec/HooksBeforeExamples:
Exclude:
- 'spec/features/crops/creating_a_crop_spec.rb'
@@ -280,15 +276,21 @@ RSpec/IndexedLet:
- 'spec/models/member_spec.rb'
- 'spec/views/forums/index.html.haml_spec.rb'
# Offense count: 719
# Offense count: 720
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Enabled: false
# Offense count: 42
# Offense count: 40
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:
@@ -305,11 +307,11 @@ RSpec/MultipleDescribes:
Exclude:
- 'spec/features/crops/crop_wranglers_spec.rb'
# Offense count: 149
# Offense count: 152
RSpec/MultipleExpectations:
Max: 19
# Offense count: 147
# Offense count: 138
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 14
@@ -320,12 +322,12 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NamedSubject:
Enabled: false
# Offense count: 110
# Offense count: 111
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6
# Offense count: 407
# Offense count: 403
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
@@ -356,13 +358,15 @@ RSpec/RepeatedExampleGroupBody:
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
RSpec/ScatteredSetup:
Exclude:
- 'spec/features/percy/percy_spec.rb'
- 'spec/features/plantings/prediction_spec.rb'
# Offense count: 1
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata.
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- 'spec/controllers/member_controller_spec.rb'
@@ -376,6 +380,8 @@ RSpec/StubbedMock:
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: constant, string
RSpec/VerifiedDoubleReference:
Exclude:
- 'spec/models/member_spec.rb'
@@ -405,36 +411,30 @@ RSpecRails/HaveHttpStatus:
RSpecRails/InferredSpecType:
Enabled: false
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
Rails/Blank:
Exclude:
- 'lib/tasks/wikidata.rake'
# Offense count: 29
# Configuration parameters: Database.
# Offense count: 28
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql, postgresql
# Include: db/**/*.rb
Rails/BulkChangeTable:
Enabled: false
# Offense count: 4
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/CreateTableWithTimestamps:
Exclude:
- 'db/migrate/20150201052245_create_cms.rb'
- 'db/migrate/20171022032108_all_the_predictions.rb'
# Offense count: 3
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowToTime.
# SupportedStyles: strict, flexible
Rails/Date:
Exclude:
- 'app/controllers/activities_controller.rb'
- 'app/mailers/notifier_mailer.rb'
- 'app/models/concerns/search_seeds.rb'
# Offense count: 12
# Offense count: 11
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: order, limit, select, lock
@@ -445,55 +445,64 @@ Rails/FindEach:
- 'db/migrate/20171129041341_create_photographings.rb'
- 'db/migrate/20190130090437_add_crop_to_photographings.rb'
- 'db/migrate/20191119030244_cms_tags.rb'
- 'lib/tasks/wikidata.rake'
# Offense count: 2
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/member.rb'
- 'app/models/role.rb'
# Offense count: 5
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/member.rb'
# Offense count: 1
# Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb
Rails/I18nLocaleAssignment:
Exclude:
- 'spec/features/locale_spec.rb'
# Offense count: 37
# Offense count: 33
Rails/I18nLocaleTexts:
Enabled: false
# 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: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/OrderArguments:
Exclude:
- 'app/models/crop.rb'
# Offense count: 2
Rails/OutputSafety:
Exclude:
- '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.
# Include: **/Rakefile, **/*.rake
Rails/RakeEnvironment:
Exclude:
- 'lib/tasks/hooks.rake'
- 'lib/tasks/i18n.rake'
- 'lib/tasks/testing.rake'
# Offense count: 8
# Offense count: 9
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone
@@ -504,6 +513,7 @@ Rails/RedundantActiveRecordAllMethod:
- 'app/controllers/forums_controller.rb'
- 'app/controllers/plant_parts_controller.rb'
- 'app/controllers/scientific_names_controller.rb'
- 'app/services/openfarm_service.rb'
- 'spec/features/percy/percy_spec.rb'
- 'spec/models/harvest_spec.rb'
@@ -518,6 +528,8 @@ Rails/RedundantPresenceValidationOnBelongsTo:
# Offense count: 15
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb
Rails/ResponseParsedBody:
Exclude:
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
@@ -531,31 +543,29 @@ Rails/ResponseParsedBody:
- 'spec/requests/api/v1/seeds_request_spec.rb'
# Offense count: 9
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/ReversibleMigration:
Exclude:
- 'db/migrate/20130326092227_change_planted_at_to_date.rb'
- 'db/migrate/20191119020643_upgrade_cms.rb'
# Offense count: 3
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RootPathnameMethods:
Exclude:
- 'app/controllers/crops_controller.rb'
- 'app/helpers/icons_helper.rb'
- 'config/application.rb'
# Offense count: 2
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/20240810160538_set_default_language_for_existing_alternate_names.rb'
# Offense count: 21
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/ThreeStateBooleanColumn:
Enabled: false
# Offense count: 6
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
Exclude:
- 'app/models/follow.rb'
@@ -573,13 +583,12 @@ Rails/WhereEquals:
- 'app/models/harvest.rb'
- 'app/models/planting.rb'
# Offense count: 3
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/WhereRange:
Exclude:
- 'app/models/concerns/predict_planting.rb'
- 'app/models/garden.rb'
- 'app/models/seed.rb'
# Offense count: 1
Rake/MethodDefinitionInTask:
@@ -588,10 +597,8 @@ Rake/MethodDefinitionInTask:
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
# SupportedStylesForClasses: ~, nested, compact
# SupportedStylesForModules: ~, nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'lib/actions/oauth_signup_action.rb'
@@ -607,15 +614,7 @@ Style/CommentedKeyword:
- 'spec/models/photo_spec.rb'
- 'spec/models/planting_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: left_coerce, right_coerce, single_coerce, fdiv
Style/FloatDivision:
Exclude:
- 'app/models/concerns/predict_planting.rb'
# Offense count: 11
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
@@ -623,34 +622,23 @@ 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/20240716120000_add_social_media_to_members.rb'
- 'db/migrate/20240716120001_rename_other_handle_to_other_url_in_members.rb'
- 'db/migrate/20240929041435_create_garden_collaborators.rb'
- 'db/migrate/20250810120000_make_notifications_polymorphic.rb'
- 'db/migrate/20250824081313_change_comments_polymorphic.rb'
- 'db/migrate/20250901105232_add_source_to_seeds.rb'
- 'db/migrate/20250901110545_add_indexes_crops.rb'
- 'db/migrate/20250901130830_add_overall_rating_plantings.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: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashFetchChain:
# Configuration parameters: AllowedMethods.
# AllowedMethods: nonzero?
Style/IfWithBooleanLiteralBranches:
Exclude:
- 'app/models/concerns/open_farm_data.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/IdenticalConditionalBranches:
Exclude:
- 'lib/actions/oauth_signup_action.rb'
- 'app/controllers/gardens_controller.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
@@ -688,12 +676,11 @@ Style/OpenStructUse:
Exclude:
- 'spec/helpers/event_helper_spec.rb'
# Offense count: 3
# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/models/concerns/member_newsletter.rb'
# Offense count: 1
@@ -710,26 +697,6 @@ Style/RedundantFetchBlock:
Exclude:
- 'config/puma.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/RedundantInterpolation:
Exclude:
- 'app/helpers/buttons_helper.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Exclude:
- 'lib/tasks/wikidata.rake'
# Offense count: 4
# Configuration parameters: Max.
Style/SafeNavigationChainLength:
Exclude:
- 'app/models/ability.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowModifier.
@@ -738,35 +705,17 @@ Style/SoleNestedConditional:
- 'app/controllers/application_controller.rb'
- 'app/controllers/messages_controller.rb'
# Offense count: 28
# Offense count: 24
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'app/controllers/messages_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/buttons_helper.rb'
- 'app/models/photo.rb'
- 'config/initializers/rswag_api.rb'
- 'spec/helpers/gardens_helper_spec.rb'
- 'spec/helpers/seeds_helper_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiteralsInInterpolation:
Exclude:
- 'config/initializers/mailboxer.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: .
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: percent
MinSize: 3
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.

View File

@@ -199,4 +199,6 @@ group :travis do
gem 'platform-api'
end
gem "i18n_data", "~> 1.1"

View File

@@ -457,8 +457,8 @@ GEM
racc
percy-capybara (5.0.0)
capybara (>= 3)
pg (1.6.2)
pg (1.6.2-x86_64-linux)
pg (1.6.1)
pg (1.6.1-x86_64-linux)
platform-api (3.8.0)
heroics (~> 0.1.1)
moneta (~> 1.0.0)
@@ -475,7 +475,7 @@ GEM
date
stringio
public_suffix (6.0.1)
puma (7.0.0)
puma (6.6.1)
nio4r (~> 2.0)
query_diet (0.7.2)
racc (1.8.1)
@@ -601,7 +601,7 @@ GEM
rswag-ui (2.16.0)
actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1)
rubocop (1.80.2)
rubocop (1.80.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
@@ -630,7 +630,7 @@ GEM
rubocop-rake (0.7.1)
lint_roller (~> 1.1)
rubocop (>= 1.72.1)
rubocop-rspec (3.7.0)
rubocop-rspec (3.6.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)

View File

@@ -132,8 +132,6 @@ section {
border-radius: 5%;
margin: 0.5em 0.5em 0.5em 0;
width: 200px;
align-items: stretch;
justify-content: space-between;
.img-card {
border-top-left-radius: 5%;

View File

@@ -29,7 +29,7 @@ class ActivitiesController < DataController
def new
@activity = Activity.new(
owner: current_member,
owner: current_member,
due_date: Date.today
)
if params[:garden_id]

View File

@@ -6,7 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
prepend_before_action :check_captcha, only: [:create] # Change this to be any actions you want to protect with recaptcha.
def edit
@flickr_auth = current_member.auth('flickr')
@flickr_auth = current_member.auth('flickr')
render "edit"
end

View File

@@ -21,28 +21,6 @@ module ApplicationHelper
classes
end
# Similar to Rails' time_ago_in_words, but gives a more standard
# output like "in 3 days" or "5 months ago".
# Also handles the case where from_time is a Date and to_time is a Date
# (in which case it just says "today" if they're the same date).
#
# NOTE: This is similar to distance_of_time_in_words but different enough
# that I think it's worth having a separate helper for it.
#
# from_time - the starting time (Time or Date)
# to_time - the ending time (Time or Date). Default: now (Time.zone.now)
# include_seconds - whether to include seconds in the calculation
#
# Returns a string like "in 3 days" or "5 months ago"
def standard_time_distance(from_time, to_time = 0, include_seconds = false)
return 'today' if from_time.is_a?(Date) && (from_time == to_time)
return 'now' if from_time == to_time
return distance_of_time_in_words(from_time, to_time, include_seconds:) + ' ago' if from_time > to_time
'in ' + distance_of_time_in_words(from_time, to_time, include_seconds:)
end
def count_github_contibutors
File.open(Rails.root.join('CONTRIBUTORS.md')).readlines.grep(/^-/).size
end

View File

@@ -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)
%(
<input id="#{source}" class="auto-suggest #{options[:class]}" #{'required="required"' if options[:required]}
<input id="#{source}" class="auto-suggest #{options[:class]}" #{options[:required] ? 'required="required"' : ''}
type="text" value="#{default}" data-source-url="#{source_path}",
placeholder="e.g. lettuce">
<noscript class="text-warning">

View File

@@ -7,8 +7,8 @@ module EventHelper
def event_description(event)
render "#{event.event_type.pluralize}/description", event_model: resolve_model(event)
rescue ActionView::MissingTemplate
"#{event.event_type.humanize.downcase}d"
rescue ActionView::MissingTemplate
"#{event.event_type.humanize.downcase}d"
end
def resolve_model(event)

View File

@@ -9,9 +9,7 @@ module SearchActivities
mappings: {
properties: {
active: { type: :boolean },
created_at: { type: :integer },
updated_at: { type: :integer },
due_date: { type: :date }
created_at: { type: :integer }
}
}
@@ -25,10 +23,8 @@ module SearchActivities
category:,
garden_id:,
garden_name: garden&.name,
garden_slug: garden&.garden_slug,
planting_id:,
planting_name: planting&.crop&.name,
planting_slug: planting&.slug,
description:,
# owner

View File

@@ -90,7 +90,7 @@ class Crop < ApplicationRecord
def popular_plant_parts
PlantPart.joins(:harvests)
.where("crop_id = ?", id)
.order(count_harvests_id: :desc)
.order("count_harvests_id DESC")
.group("plant_parts.id", "plant_parts.name")
.count("harvests.id")
end

View File

@@ -3,7 +3,6 @@
class Forum < ApplicationRecord
extend FriendlyId
include Ownable
validates :name, presence: true
validates :description, presence: true
friendly_id :name, use: %i(slugged finders)

View File

@@ -2,7 +2,6 @@
class GardenType < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)
has_many :gardens, dependent: :nullify

View File

@@ -53,7 +53,6 @@ class Harvest < ApplicationRecord
delegate :name, :slug, to: :crop, prefix: true
delegate :login_name, :slug, to: :owner, prefix: true
delegate :name, to: :plant_part, prefix: true
##
## Validations
@@ -109,7 +108,7 @@ class Harvest < ApplicationRecord
def to_s
# 50 individual apples, weighing 3lb
# 2 buckets of apricots, weighing 10kg
"#{quantity_to_human} #{unit_to_human} #{crop_name_to_human} #{weight_to_human}".strip
"#{quantity_to_human} #{unit_to_human} #{plant_part_name_to_human} of #{crop_name} #{weight_to_human}".strip
end
def quantity_to_human
@@ -132,13 +131,13 @@ class Harvest < ApplicationRecord
"weighing #{number_to_human(weight_quantity, strip_insignificant_zeros: true)} #{weight_unit}"
end
def crop_name_to_human
def plant_part_name_to_human
if unit != 'individual' # buckets of apricot*s*
crop.name.pluralize
plant_part.name.pluralize
elsif quantity == 1
crop.name
plant_part.name
else
crop.name.pluralize
plant_part.name.pluralize
end.to_s
end

View File

@@ -2,14 +2,12 @@
class Member < ApplicationRecord
include Discard::Model
acts_as_messageable # messages can be sent to this model
include Geocodable
include MemberFlickr
include MemberNewsletter
extend FriendlyId
friendly_id :login_name, use: %i(slugged finders)
#
@@ -93,9 +91,9 @@ class Member < ApplicationRecord
uniqueness: {
case_sensitive: false
}
validates :website_url, format: { with: %r{\Ahttps?://}, message: "must start with http:// or https://" }, allow_blank: true
validates :other_url, format: { with: %r{\Ahttps?://}, message: "must start with http:// or https://" }, allow_blank: true
validates :instagram_handle, :facebook_handle, :bluesky_handle, format: { without: %r{\Ahttps?://|/}, message: "should be a handle, not a URL" }, allow_blank: true
validates :website_url, format: { with: /\Ahttps?:\/\//, message: "must start with http:// or https://" }, allow_blank: true
validates :other_url, format: { with: /\Ahttps?:\/\//, message: "must start with http:// or https://" }, allow_blank: true
validates :instagram_handle, :facebook_handle, :bluesky_handle, format: { without: %r{\Ahttps?:\/\/|\/}, message: "should be a handle, not a URL" }, allow_blank: true
#
# Triggers

View File

@@ -2,7 +2,6 @@
class PlantPart < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)
has_many :harvests, dependent: :destroy
@@ -12,6 +11,10 @@ class PlantPart < ApplicationRecord
scope :joins_members, -> { joins("INNER JOIN members ON members.id = harvests.owner_id") }
def whole_plant?
name == 'whole plant'
end
def to_s
name
end

View File

@@ -2,7 +2,6 @@
class Role < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)
validates :name, uniqueness: true, presence: true

View File

@@ -6,7 +6,6 @@ class Seed < ApplicationRecord
include Finishable
include Ownable
include SearchSeeds
friendly_id :seed_slug, use: %i(slugged finders)
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze
@@ -49,7 +48,7 @@ class Seed < ApplicationRecord
"are heirloom, hybrid, or unknown" }
validates :source, allow_blank: true,
inclusion: { in: SOURCE_VALUES, message: "You must say where the seeds are from," \
"or that you don't know" }
"or that you don't know" }
#
# Delegations

View File

@@ -20,24 +20,16 @@
- if can? :destroy, activity
.dropdown-divider
= delete_button(activity, classes: 'dropdown-item text-danger')
.card-body
= link_to activity_path(slug: activity.slug) do
= link_to activity_path(slug: activity.slug) do
.card-body.text-center
%h4= activity.name
- if activity.due_date
%small.due-date{title: activity.due_date}
= standard_time_distance(activity.due_date.to_date, Time.zone.now.to_date)
%div
%small.text-justify{title: activity.description}= activity.description.truncate(150)
%p
%ul.list-unstyled
- if activity.garden_name && activity.garden_slug
%li
%small= link_to activity.garden_name, garden_path(slug: activity.garden_slug)
- if activity.planting_name && activity.planting_slug
%li
%small= link_to activity.planting_name, planting_path(slug: activity.planting_slug)
.text-center= activity.description
- if activity.garden
.text-center= activity.garden
- if activity.planting
.text-center= activity.planting
.card-footer
%small.chip.member-chip
= link_to member_path(slug: activity.owner_slug) do
= activity.owner_login_name
.float-right
%span.chip.member-chip
= link_to member_path(slug: activity.owner_slug) do
= activity.owner_login_name

View File

@@ -27,13 +27,13 @@
.row
.col-md-4
= f.collection_radio_buttons(:garden_id, @activity.owner.gardens.active.order_by_name,
= f.collection_radio_buttons(:garden_id, @activity.owner.gardens.active,
:id, :name,
label: 'Is this for a specific garden?')
= link_to "Add a garden.", new_garden_path
.col-md-4
= f.collection_radio_buttons(:planting_id, @activity.owner.plantings.active.recent,
= f.collection_radio_buttons(:planting_id, @activity.owner.plantings.active,
:id, :crop_name,
label: 'Is this for a specific planting?')
= link_to "Add a planting.", new_planting_path

View File

@@ -12,7 +12,7 @@
#{harvest.owner} harvested #{display_quantity(harvest)}.
.float-right= render 'members/location', member: harvest.owner
.harvest-timeago
%small #{standard_time_distance(harvest.harvested_at, Time.zone.now.to_date)}
%small #{distance_of_time_in_words(harvest.harvested_at, Time.zone.now)} ago.
%li.list-group-item= link_to "View all #{crop.name} harvests", crop_harvests_path(crop), class: 'card-link'
- if crop.approved?
- if current_member

View File

@@ -11,9 +11,6 @@
.row
.col-md-2
%small
%a{href: "#content"}
Skip to main content
= render 'layouts/nav', model: Garden
%label
= link_to show_inactive_tickbox_path('gardens', owner: @owner, show_all: @show_all) do
@@ -23,7 +20,7 @@
%hr/
= render @owner
.col-md-10#content
.col-md-10
- if @gardens.empty?
%p There are no gardens to display.
- if can?(:create, Garden) && @owner == current_member

View File

@@ -46,7 +46,7 @@
%h3
Harvested
= editable :date, @harvest, :harvested_at, display_field: '.harvested_at'
%strong.harvested_at #{standard_time_distance @harvest.harvested_at, Time.zone.now.to_date}
%strong.harvested_at #{distance_of_time_in_words @harvest.harvested_at, Time.zone.now.to_date} ago
%span.harvested_at= I18n.l @harvest.harvested_at
.card{class: @harvest.quantity.present? ? '' : 'text-muted'}

View File

@@ -11,11 +11,11 @@
%br
%p
- if current_member.plantings.active.any?
= link_to member_path(current_member, anchor: "content"), class: 'btn btn-dark' do
= link_to member_path(current_member, anchor: "#content"), class: 'btn btn-dark' do
= planting_icon
Track my plantings
%p
= link_to member_gardens_path(current_member, anchor: "content"), class: 'btn btn-dark' do
= link_to member_gardens_path(current_member), class: 'btn btn-dark' do
= garden_icon
Show me my garden
- else

View File

@@ -2,10 +2,10 @@
%ul.navbar-nav.mr-auto.bg-dark
- if signed_in?
%li.nav-item
= link_to timeline_index_path, method: :get, class: 'nav-link text-white', title: "Timeline" do
= link_to timeline_index_path, method: :get, class: 'nav-link text-white' do
= image_tag 'icons/notification.svg', class: 'img img-icon', alt: "Notifications"
%li.nav-item
= link_to member_gardens_path(current_member, anchor: "content"), class: 'nav-link text-white', title: "My gardens" do
= link_to member_gardens_path(current_member), class: 'nav-link text-white', title: "My gardens" do
= image_icon 'gardens'
%li.nav-item.dropdown
%a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"}

View File

@@ -83,14 +83,14 @@
.row
%section.order-3.order-md-1.col-12= render "map", member: @member
- if @harvesting.size.positive?
%section.harvests.order-2.order-md-1.col-12#harvests
%section.harvests.order-2.order-md-1.col-12
%h2 Ready to harvest
.index-cards
- @harvesting.each do |planting|
= render 'plantings/thumbnail', planting: planting
- if @others.size.positive?
%section.planting-progress.order-2.order-md-1.col-12#planting-progress
%section.planting-progress.order-2.order-md-1.col-12
%h2 Progress report
%p Still growing and not ready for harvesting.
.list-group
@@ -99,7 +99,7 @@
%span= render 'plantings/tiny', planting: planting
%span= render 'plantings/progress', planting: planting
- if @late.size.positive?
%section.late.order-2.order-md-1.col-12#late
%section.late.order-2.order-md-1.col-12
%h2 Late
%p
These plantings are at the end of their lifecycle.
@@ -109,7 +109,7 @@
- @late.each do |planting|
= render 'plantings/thumbnail', planting: planting
- if @super_late.any?
%section.superlate.order-2.order-md-1.col-12#superlate
%section.superlate.order-2.order-md-1.col-12
%h2 Super late
%p
We suspect the following plantings finished long ago and no longer need tracking.
@@ -122,14 +122,14 @@
planted on #{planting.planted_at.to_date}
- if @harvests.any?
%section.havests.order-2.order-md-1.col-12#recent-harvests
%section.havests.order-2.order-md-1.col-12
%h2 Recent Harvests
.index-cards
- @harvests.each do |harvest|
= render 'harvests/thumbnail', harvest: harvest
- if @activity.any?
%section.activity.order-2.order-md-1.col-12#activity
%section.activity.order-2.order-md-1.col-12
%h2 Activity
.list-group
- @activity.each do |event|

View File

@@ -27,7 +27,7 @@
.row
.col-md-8
= f.collection_radio_buttons(:garden_id, @planting.owner.gardens.active.order_by_name,
= f.collection_radio_buttons(:garden_id, @planting.owner.gardens.active,
:id, :name, required: true,
label: 'Where did you plant it?')
= link_to "Add a garden.", new_garden_path

View File

@@ -9,7 +9,7 @@
%p Which garden is the planting in?
%ul.list-group
- planting.owner.gardens.active.order_by_name.each do |garden|
- planting.owner.gardens.active.order(:name).each do |garden|
%li.list-group-item
= link_to plantings_path(planting: {crop_id: planting.crop_id, garden_id: garden.id}), method: :post do
.md-v-line

View File

@@ -5,7 +5,7 @@ Mailboxer.setup do |config|
config.uses_emails = true
# Configures the default from for emails sent for Messages and Notifications
config.default_from = "Growstuff <#{ENV.fetch('GROWSTUFF_EMAIL', "no-reply@growstuff.org")}>"
config.default_from = "Growstuff <#{ENV.fetch('GROWSTUFF_EMAIL', "no-reply@growstuff.org")}>"
# Configures the methods needed by mailboxer
# config.email_method = :email

View File

@@ -2,10 +2,10 @@
class SetDefaultLanguageForExistingAlternateNames < ActiveRecord::Migration[7.2]
def up
AlternateName.update_all(language: 'en') # rubocop:disable Rails/SkipsModelValidations
AlternateName.update_all(language: 'en')
end
def down
AlternateName.update_all(language: nil) # rubocop:disable Rails/SkipsModelValidations
AlternateName.update_all(language: nil)
end
end

View File

@@ -36,15 +36,15 @@ namespace :wikidata do
aliases = wikidata_data['entities'][wikidata_id]['aliases']
aliases.each do |lang, values|
values.each do |value|
next if AlternateName.exists?(name: value['value'], language: lang, crop: crop)
AlternateName.create!(
name: value['value'],
language: lang,
crop: crop,
creator: creator
)
puts " Added alternate name: #{value['value']} (#{lang})"
unless AlternateName.exists?(name: value['value'], language: lang, crop: crop)
AlternateName.create!(
name: value['value'],
language: lang,
crop: crop,
creator: creator
)
puts " Added alternate name: #{value['value']} (#{lang})"
end
end
end
else

View File

@@ -4,7 +4,6 @@ require 'rails_helper'
RSpec.describe GardenTypesController, type: :controller do
include Devise::Test::ControllerHelpers
let(:valid_params) { { name: 'My second GardenType' } }
let(:garden_type) { FactoryBot.create(:garden_type) }

View File

@@ -4,7 +4,6 @@ require 'rails_helper'
RSpec.describe GardensController, type: :controller do
include Devise::Test::ControllerHelpers
let(:valid_params) { { name: 'My second Garden' } }
let(:garden) { FactoryBot.create(:garden) }

View File

@@ -2,7 +2,7 @@
FactoryBot.define do
factory :comment do
commentable factory: %i(post)
association :commentable, factory: :post
author
sequence(:body) { |n| "OMG LOL #{n}" }
# because our commenters are more polite than YouTube's

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
FactoryBot.define do
factory :garden_collaborator do
garden

View File

@@ -10,7 +10,7 @@ FactoryBot.define do
body { "MyText" }
read { false }
notifiable factory: %i(post)
association :notifiable, factory: :post
factory :no_email_notification do
recipient { FactoryBot.create(:no_email_notifications_member) }

View File

@@ -18,7 +18,7 @@ describe "Conversations", :js do
click_link 'Inbox'
end
it_behaves_like 'is accessible'
include_examples 'is accessible'
it { expect(page).to have_content 'something i want to say' }
it { page.percy_snapshot(page, name: 'conversations#index') }

View File

@@ -83,23 +83,23 @@ describe "Alternate names", :js do
end
context 'Anonymous' do
it_behaves_like 'show alt names'
include_examples 'show alt names'
end
context 'Signed in member' do
include_context 'signed in member'
it_behaves_like 'show alt names'
include_examples 'show alt names'
end
context 'Crop wrangler' do
include_context 'signed in crop wrangler'
it_behaves_like 'show alt names'
it_behaves_like 'edit alt names'
include_examples 'show alt names'
include_examples 'edit alt names'
end
context 'Admin' do
include_context 'signed in admin'
it_behaves_like 'show alt names'
it_behaves_like 'edit alt names'
include_examples 'show alt names'
include_examples 'edit alt names'
end
end

View File

@@ -34,25 +34,25 @@ describe "browse crops", :search do
end
context 'anon' do
it_behaves_like 'shows crops'
include_examples 'shows crops'
it { expect(page).to have_no_link "Add New Crop" }
end
context 'member' do
include_context 'signed in member'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
include_examples 'shows crops'
include_examples 'add new crop'
end
context 'wrangler' do
include_context 'signed in crop wrangler'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
include_examples 'shows crops'
include_examples 'add new crop'
end
context 'admin' do
include_context 'signed in admin'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
include_examples 'shows crops'
include_examples 'add new crop'
end
end

View File

@@ -25,7 +25,7 @@ describe "Crop", :js do
shared_examples 'request crop' do
describe "requesting a crop with multiple scientific and alternate name" do
it_behaves_like 'fill in form'
include_examples 'fill in form'
before do
within "form#new_crop" do
fill_in "request_notes", with: "This is the Philippine national flower."
@@ -42,7 +42,7 @@ describe "Crop", :js do
shared_examples 'create crop' do
describe "creating a crop with multiple scientific and alternate name" do
it_behaves_like 'fill in form'
include_examples 'fill in form'
before do
click_button "Save"
end
@@ -61,16 +61,16 @@ describe "Crop", :js do
context 'member' do
include_context 'signed in member'
it_behaves_like 'request crop'
include_examples 'request crop'
end
context 'crop wrangler' do
include_context 'signed in crop wrangler'
it_behaves_like 'create crop'
include_examples 'create crop'
end
context 'admin' do
include_context 'signed in admin'
it_behaves_like 'create crop'
include_examples 'create crop'
end
end

View File

@@ -59,17 +59,17 @@ describe "crop detail page", :js, :search do
context "when signed in" do
include_context 'signed in member'
it_behaves_like "shows photos"
include_examples "shows photos"
end
context "when signed in as photos owner" do
include_context 'signed in member'
let(:member) { owner_member }
it_behaves_like "shows photos"
include_examples "shows photos"
end
context "when not signed in" do
it_behaves_like "shows photos"
include_examples "shows photos"
end
end

View File

@@ -27,11 +27,11 @@ describe "Delete crop spec" do
context "As a crop wrangler" do
include_context 'signed in crop wrangler'
it_behaves_like 'delete crop'
include_examples 'delete crop'
end
context 'admin' do
include_context 'signed in admin'
it_behaves_like 'delete crop'
include_examples 'delete crop'
end
end

View File

@@ -25,7 +25,7 @@ describe "Gardens" do
context 'my gardens' do
before { visit gardens_path(member_slug: member.slug) }
it_behaves_like "has buttons bar at top"
include_examples "has buttons bar at top"
context 'with actions menu expanded' do
before { click_link 'Actions' }
@@ -43,13 +43,13 @@ describe "Gardens" do
context 'all gardens' do
before { visit gardens_path }
it_behaves_like "has buttons bar at top"
include_examples "has buttons bar at top"
end
context "other member's garden" do
before { visit gardens_path(member_slug: FactoryBot.create(:member).slug) }
it_behaves_like "has buttons bar at top"
include_examples "has buttons bar at top"
describe 'does not show actions on other member garden' do
it { is_expected.to have_no_link 'Actions' }
end

View File

@@ -8,7 +8,7 @@ describe "Gardens", :js do
include_context 'signed in member'
before { visit new_garden_path }
it_behaves_like 'is accessible'
include_examples 'is accessible'
it "displays required and optional fields properly" do
expect(page).to have_selector ".required", text: "Name"

View File

@@ -14,7 +14,7 @@ describe "Gardens#index", :js do
visit member_gardens_path(member_slug: member.slug)
end
it_behaves_like 'is accessible'
include_examples 'is accessible'
it "displays each of the gardens" do
member.gardens.each do |garden|

View File

@@ -26,7 +26,7 @@ describe "Harvesting a crop", :js, :search do
within "form#new_harvest" do
choose plant_part.name
fill_in "When?", with: Time.zone.local(2014, 0o6, 15)
fill_in "When?", with: Time.new(2014, 06, 15)
fill_in "How many?", with: 42
fill_in "Weighing (in total)", with: 42
fill_in "Notes", with: "It's killer."

View File

@@ -58,13 +58,13 @@ describe 'Likeable', :js, :search do
describe 'photos#index' do
let(:path) { photos_path }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
describe 'photos#show' do
let(:path) { photo_path(photo) }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
describe 'crops#show' do
@@ -74,7 +74,7 @@ describe 'Likeable', :js, :search do
before { planting.photos << photo }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
end
@@ -82,27 +82,27 @@ describe 'Likeable', :js, :search do
let(:like_count_class) { ".post-#{post.id} .like-count" }
let(:path) { post_path(post) }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
describe 'activities' do
let(:like_count_class) { ".activity-#{activity.id} .like-count" }
let(:path) { activity_path(activity) }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
describe 'plantings' do
let(:like_count_class) { ".planting-#{planting.id} .like-count" }
let(:path) { planting_path(planting) }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
describe 'harvests' do
let(:like_count_class) { ".harvest-#{harvest.id} .like-count" }
let(:path) { harvest_path(harvest) }
it_behaves_like 'object can be liked'
include_examples 'object can be liked'
end
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe "member deletion", :flaky do
describe "member deletion", flaky: true do
context "with activity and followers" do
let(:member) { FactoryBot.create(:member) }
let(:other_member) { FactoryBot.create(:member) }
@@ -63,7 +63,7 @@ describe "member deletion", :flaky do
member.reload
expect(member.discarded?).to be true
# Frustratingly, this cannot be discarded? and also meet
# Frustratingly, this cannot be discarded? and also meet
# `@member = Member.confirmed.kept.find_by!(slug: params[:slug])`
#
# Yet, we see the below assert fail in CI.
@@ -96,7 +96,7 @@ describe "member deletion", :flaky do
end
describe 'member exists but is marked deleted' do
subject { Member.find(member.id) }
subject { Member.all.find(member.id) }
it { expect(subject).to eq member }
it { expect(subject.discarded?).to be true }

View File

@@ -34,11 +34,11 @@ describe "signout" do
end
describe 'after signout, redirect to signin page if page needs authentication' do
it_behaves_like "sign-in redirects", "/plantings/new"
it_behaves_like "sign-in redirects", "/harvests/new"
it_behaves_like "sign-in redirects", "/posts/new"
it_behaves_like "sign-in redirects", "/gardens/new"
it_behaves_like "sign-in redirects", "/seeds/new"
include_examples "sign-in redirects", "/plantings/new"
include_examples "sign-in redirects", "/harvests/new"
include_examples "sign-in redirects", "/posts/new"
include_examples "sign-in redirects", "/gardens/new"
include_examples "sign-in redirects", "/seeds/new"
end
it 'photos' do

View File

@@ -136,7 +136,6 @@ describe Ability do
it "can manage members" do
ability.should be_able_to(:destroy, FactoryBot.create(:member))
end
it "cannot delete themselves" do
ability.should_not be_able_to(:destroy, member)
end

View File

@@ -154,7 +154,7 @@ describe Crop do
it { expect(crop.default_photo).to eq photo }
it_behaves_like 'has default photo'
include_examples 'has default photo'
end
context 'with a harvest photo' do
@@ -165,7 +165,7 @@ describe Crop do
it { expect(crop.default_photo).to eq photo }
it_behaves_like 'has default photo'
include_examples 'has default photo'
context 'and planting photo' do
let(:planting) { FactoryBot.create(:planting, crop:) }

View File

@@ -149,78 +149,94 @@ describe Harvest do
end
context "stringification" do
let(:crop) { FactoryBot.create(:crop, name: "apricot") }
let(:whole_plant) { FactoryBot.create(:plant_part, name: "whole plant") }
let(:leaf) { FactoryBot.create(:plant_part, name: "leaf") }
let(:fruit) { FactoryBot.create(:plant_part, name: "fruit") }
let(:other) { FactoryBot.create(:plant_part, name: "other") }
it "apricots" do
@h = FactoryBot.create(:harvest, crop:,
quantity: nil,
unit: nil,
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "apricots"
end
let(:apricot) { FactoryBot.create(:crop, name: "apricot") }
let(:lettuce) { FactoryBot.create(:crop, name: "lettuce") }
it "1 individual apricot" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 1,
unit: 'individual',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1 individual apricot"
end
context "apricots" do
it "apricots" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: nil,
unit: nil,
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "fruits of apricot"
end
it "10 individual apricots" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'individual',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "10 individual apricots"
end
it "1 individual apricot" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 1,
unit: 'individual',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1 individual fruit of apricot"
end
it "1 bushel of apricots" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 1,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1 bushel of apricots"
end
it "10 individual apricots" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 10,
unit: 'individual',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "10 individual fruits of apricot"
end
it "1.5 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 1.5,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1.5 bushels of apricots"
end
it "1 bushel of apricots" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 1,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1 bushel of fruits of apricot"
end
it "10 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "10 bushels of apricots"
end
it "1.5 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 1.5,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "1.5 bushels of fruits of apricot"
end
it "apricots weighing 1.2 kg" do
@h = FactoryBot.create(:harvest, crop:,
quantity: nil,
unit: nil,
weight_quantity: 1.2,
weight_unit: 'kg')
expect(@h.to_s).to eq "apricots weighing 1.2 kg"
end
it "10 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 10,
unit: 'bushel',
weight_quantity: nil,
weight_unit: nil)
expect(@h.to_s).to eq "10 bushels of fruits of apricot"
end
it "10 bushels of apricots weighing 100 kg" do
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'bushel',
weight_quantity: 100,
weight_unit: 'kg')
expect(@h.to_s).to eq "10 bushels of apricots weighing 100 kg"
it "apricots weighing 1.2 kg" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: nil,
unit: nil,
weight_quantity: 1.2,
weight_unit: 'kg')
expect(@h.to_s).to eq "fruits of apricot weighing 1.2 kg"
end
it "10 bushels of apricots weighing 100 kg" do
@h = FactoryBot.create(:harvest, crop: apricot,
plant_part: fruit,
quantity: 10,
unit: 'bushel',
weight_quantity: 100,
weight_unit: 'kg')
expect(@h.to_s).to eq "10 bushels of fruits of apricot weighing 100 kg"
end
end
end

View File

@@ -523,7 +523,6 @@ describe Planting do
context "failed" do
let(:failed_planting) { FactoryBot.create(:planting, failed: true) }
it 'has a failed field' do
expect(failed_planting.failed).to be true
end
@@ -536,20 +535,20 @@ describe Planting do
end
it 'is not included in the active scope' do
@p = FactoryBot.create(:planting)
@f = FactoryBot.create(:planting, failed: true)
described_class.active.should include @p
described_class.active.should_not include @f
@p = FactoryBot.create(:planting)
@f = FactoryBot.create(:planting, failed: true)
described_class.active.should include @p
described_class.active.should_not include @f
end
it 'cannot be finished and failed' do
@f = FactoryBot.build(:planting, finished: true, failed: true)
@f.should_not be_valid
@f = FactoryBot.build(:planting, finished: true, failed: true)
@f.should_not be_valid
end
it 'is not finished' do
@f = FactoryBot.build(:planting, finished: true, failed: true)
expect(@f.finished?).to be false
@f = FactoryBot.build(:planting, finished: true, failed: true)
expect(@f.finished?).to be false
end
end
@@ -588,7 +587,7 @@ describe Planting do
FactoryBot.create(:finished_planting, owner: member, garden: member.gardens.first)
end
let!(:failed_planting) do
FactoryBot.create(:planting, failed: true, owner: member, garden: member.gardens.first)
FactoryBot.create(:planting, failed: true, owner: member, garden: member.gardens.first)
end
it { expect(member.plantings.active).to include(planting) }

View File

@@ -144,7 +144,7 @@ describe Post do
end
it "does not duplicate" do
expect(post.crops).to contain_exactly(tomato, maize)
expect(post.crops).to match_array([tomato, maize])
end
it "is updated when post was modified" do

View File

@@ -70,8 +70,8 @@ include Warden::Test::Helpers
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
Rails.root.glob("spec/features/shared_examples/**/*.rb").sort.each { |f| require f }
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].sort.each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.

View File

@@ -116,7 +116,7 @@ RSpec.describe 'Plantings', type: :request do
end
describe "by member/owner" do
before do
before :each do
@member1 = planting.owner
@planting2 = create(:planting, owner: create(:owner))
@member2 = @planting2.owner

View File

@@ -15,7 +15,7 @@ describe "Plantings" do
before do
@member = create(:interesting_member)
@predictable_planting = create(:predictable_planting, owner: @member, planted_at: 1.day.ago, days_to_first_harvest: 10,
@predictable_planting = create(:predictable_planting, owner: @member, planted_at: 1.days.ago, days_to_first_harvest: 10,
days_to_last_harvest: 20)
@predictable_planting.crop.update(median_days_to_first_harvest: 10)

View File

@@ -14,17 +14,17 @@ module FeatureHelpers
shared_context 'signed in member' do
let(:member) { FactoryBot.create(:member) }
it_behaves_like 'sign in'
include_examples 'sign in'
end
shared_context 'signed in crop wrangler' do
let(:member) { FactoryBot.create(:crop_wrangling_member) }
it_behaves_like 'sign in'
include_examples 'sign in'
end
shared_context 'signed in admin' do
let(:member) { FactoryBot.create(:admin_member) }
it_behaves_like 'sign in'
include_examples 'sign in'
end
shared_context 'sign in' do

View File

@@ -58,7 +58,7 @@ describe "photos/show" do
render
end
it_behaves_like "photo data renders"
include_examples "photo data renders"
it "has a delete button" do
assert_select "a[href='#{photo_path(@photo)}']"
@@ -71,8 +71,8 @@ describe "photos/show" do
render
end
it_behaves_like "photo data renders"
it_behaves_like "No links to change data"
include_examples "photo data renders"
include_examples "No links to change data"
end
context "not signed in" do
@@ -81,8 +81,8 @@ describe "photos/show" do
render
end
it_behaves_like "photo data renders"
it_behaves_like "No links to change data"
include_examples "photo data renders"
include_examples "No links to change data"
end
context "CC-licensed photo" do

View File

@@ -31,7 +31,7 @@ describe 'seeds/index.rss.haml', :search do
render
end
it_behaves_like 'displays seed in rss feed'
include_examples 'displays seed in rss feed'
it 'shows RSS feed title' do
expect(rendered).to have_content "Recent seeds from all members"
@@ -60,6 +60,6 @@ describe 'seeds/index.rss.haml', :search do
expect(rendered).to have_content "Recent seeds from #{seed.owner}"
end
it_behaves_like 'displays seed in rss feed'
include_examples 'displays seed in rss feed'
end
end