From 79ef7347addd9a58aec43d0bd6efc076b0705848 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 8 Sep 2024 02:26:11 +0000 Subject: [PATCH 01/12] Avoid showing plantings which are finished --- app/views/gardens/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 76e071367..56f437a0a 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -40,7 +40,7 @@ Why not = link_to 'tell us more.', edit_garden_path(@garden) - - if @garden.plantings.where.not(planted_at: nil).any? + - if @garden.plantings.active.any? %section.card %h2 Garden progress .card-body From 5b9a59e2cdf544fcf123e1a9566839d5a04ebe68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 29 Sep 2024 07:08:40 +0000 Subject: [PATCH 02/12] Bump haml_lint from 0.58.0 to 0.59.0 Bumps [haml_lint](https://github.com/sds/haml-lint) from 0.58.0 to 0.59.0. - [Release notes](https://github.com/sds/haml-lint/releases) - [Changelog](https://github.com/sds/haml-lint/blob/main/CHANGELOG.md) - [Commits](https://github.com/sds/haml-lint/compare/v0.58.0...v0.59.0) --- updated-dependencies: - dependency-name: haml_lint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fa867332d..7a90ae62c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -290,7 +290,7 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.58.0) + haml_lint (0.59.0) haml (>= 5.0) parallel (~> 1.10) rainbow From c063a33e8b3e5ae447bc4a6fb326a007c9a2fe12 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 29 Sep 2024 18:28:42 +0930 Subject: [PATCH 03/12] Garden show and edit: encourage descriptions, add more calls to action (#3846) * Better edit links * Prompt for more detail * Better action links * Better action links * Update show.html.haml * Apply suggestions from code review * Apply suggestions from code review --- app/views/gardens/_form.html.haml | 2 +- app/views/gardens/show.html.haml | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 8ab82bc9b..9692ac4d0 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -16,7 +16,7 @@ %li= msg = f.text_field :name, maxlength: 255, required: true - = f.text_area :description, rows: 6 + = f.text_area :description, rows: 6, placeholder: "Tell us about this garden - where is it located? What does it look like? Do you have a link to a photo? Do you have irrigation? What are your plans?" = f.text_field :location, value: @garden.location || current_member.location, class: 'form-control', maxlength: 255 diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 56f437a0a..dbe863356 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -31,7 +31,7 @@ %p :markdown #{strip_tags markdownify(@garden.description)} - - unless @garden.description + - unless @garden.description.present? .row-fluid %p No description available yet. @@ -39,6 +39,11 @@ %p Why not = link_to 'tell us more.', edit_garden_path(@garden) + - else + - if can? :edit, @garden + %p + Did you want to + = link_to 'update this description.', edit_garden_path(@garden) - if @garden.plantings.active.any? %section.card @@ -55,6 +60,14 @@ - else .col-md-12 %p Nothing is currently planted here. + - if can?(:edit, @garden) + .col-md-12 + = garden_plant_something_button(@garden) + + - if can?(:destroy, @garden) + .dropdown-divider + = delete_button(@garden, classes: 'dropdown-item text-danger', + message: 'All plantings associated with this garden will also be deleted. Are you sure?') %section %h2 Current activities in garden @@ -65,6 +78,9 @@ - else .col-md-12 %p Nothing is currently planned here. + - if can?(:edit, @garden) + .col-md-12 + = garden_plan_something_button(@garden) - if @suggested_companions.any? %section.companions From 1c97ba1495d9ef55b613750378bb758dbbef25d6 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 29 Sep 2024 18:28:52 +0930 Subject: [PATCH 04/12] Garden collaboration (small part of community gardens) (#3862) * Add collaboration model * Permissions and garden show * List by owner, or where I am a collaborator * Add index * Add permissions * Typo * Typo * Add route * Update schema * Update schema * Add CRUD * Add CRUD * Add CRUD * Factory * Add validations * Rubocop * Rubocop * Rubocop * Unique index * Fix * Make CI more fine grained for faster feedback * Swap order * Fix path, fail-fast * Fix spec * Remove 'significant drop in coverage' as not everything runs in one giant run * Fix tests? --- .github/workflows/ci.yml | 28 +++++- .rubocop_todo.yml | 2 +- .../garden_collaborators_controller.rb | 87 +++++++++++++++++++ app/controllers/gardens_controller.rb | 5 +- app/models/ability.rb | 22 +++++ app/models/garden.rb | 1 + app/models/garden_collaborator.rb | 24 +++++ app/models/harvest.rb | 5 +- app/models/planting.rb | 5 +- .../garden_collaborators/_form.html.haml | 19 ++++ app/views/garden_collaborators/edit.html.haml | 3 + .../garden_collaborators/index.html.haml | 72 +++++++++++++++ app/views/garden_collaborators/new.html.haml | 3 + app/views/garden_collaborators/show.html.haml | 0 app/views/gardens/show.html.haml | 11 +++ config/routes.rb | 2 + ...40929041435_create_garden_collaborators.rb | 10 +++ db/schema.rb | 63 +++----------- spec/factories/garden_collaborators.rb | 6 ++ spec/rails_helper.rb | 3 - 20 files changed, 309 insertions(+), 62 deletions(-) create mode 100644 app/controllers/garden_collaborators_controller.rb create mode 100644 app/models/garden_collaborator.rb create mode 100644 app/views/garden_collaborators/_form.html.haml create mode 100644 app/views/garden_collaborators/edit.html.haml create mode 100644 app/views/garden_collaborators/index.html.haml create mode 100644 app/views/garden_collaborators/new.html.haml create mode 100644 app/views/garden_collaborators/show.html.haml create mode 100644 db/migrate/20240929041435_create_garden_collaborators.rb create mode 100644 spec/factories/garden_collaborators.rb 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_todo.yml b/.rubocop_todo.yml index 336d1041b..3195873c1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -158,7 +158,7 @@ Metrics/BlockLength: # Offense count: 7 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 183 + Max: 188 # Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns. 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/models/ability.rb b/app/models/ability.rb index c8118085e..7c32ea241 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -108,16 +108,38 @@ class Ability can :create, Planting can :update, Planting, garden: { owner_id: member.id }, crop: { approval_status: 'approved' } can :destroy, Planting, garden: { owner_id: member.id }, crop: { approval_status: 'approved' } + can :update, Planting do |planting| + planting.garden.garden_collaborators.where(member_id: member.id).any? + end + can :destroy, Planting do |planting| + planting.garden.garden_collaborators.where(member_id: member.id).any? + end + + can :create, GardenCollaborator, garden: { owner_id: member.id } + can :update, GardenCollaborator, garden: { owner_id: member.id } + can :destroy, GardenCollaborator, garden: { owner_id: member.id } can :create, Activity can :update, Activity, owner_id: member.id can :destroy, Activity, owner_id: member.id + can :update, Activity do |activity| + activity.garden&.garden_collaborators&.where(member_id: member.id)&.any? + end + can :destroy, Activity do |activity| + activity.garden&.garden_collaborators&.where(member_id: member.id)&.any? + end can :create, Harvest can :update, Harvest, owner_id: member.id can :destroy, Harvest, owner_id: member.id can :update, Harvest, owner_id: member.id, planting: { owner_id: member.id } can :destroy, Harvest, owner_id: member.id, planting: { owner_id: member.id } + can :update, Harvest do |harvest| + harvest.planting&.garden&.garden_collaborators&.where(member_id: member.id)&.any? + end + can :destroy, Harvest do |harvest| + harvest.planting&.garden&.garden_collaborators&.where(member_id: member.id)&.any? + end can :create, Photo can :update, Photo, owner_id: member.id diff --git a/app/models/garden.rb b/app/models/garden.rb index cb6c3c95f..5ef0adea3 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -10,6 +10,7 @@ class Garden < ApplicationRecord has_many :plantings, dependent: :destroy has_many :crops, through: :plantings has_many :activities, dependent: :destroy + has_many :garden_collaborators, dependent: :destroy belongs_to :garden_type, optional: true diff --git a/app/models/garden_collaborator.rb b/app/models/garden_collaborator.rb new file mode 100644 index 000000000..520303437 --- /dev/null +++ b/app/models/garden_collaborator.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class GardenCollaborator < ApplicationRecord + belongs_to :member + belongs_to :garden + + validates :member_id, uniqueness: { scope: :garden } + validate :not_garden_owner + + def not_garden_owner + return unless member + return unless garden + + errors.add(:member_id, "cannot be the garden owner") if garden.owner == member + end + + def member_slug + @member&.slug + end + + def member_slug=(_slug) + member_slug + end +end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 29069c75f..7fba64bc8 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -153,7 +153,10 @@ class Harvest < ApplicationRecord def owner_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner + return if owner == planting.owner || planting.garden.garden_collaborators.where(member_id: owner).any? + + errors.add(:owner, + "of harvest must be the same as planting, or a collaborator on that garden") end def harvest_must_be_after_planting diff --git a/app/models/planting.rb b/app/models/planting.rb index 9955a4345..134908ad8 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -127,6 +127,9 @@ class Planting < ApplicationRecord end def owner_must_match_garden_owner - errors.add(:owner, "must be the same as garden") unless owner == garden.owner + return if owner == garden.owner || garden.garden_collaborators.where(member_id: owner).any? + + errors.add(:owner, + "must be the same as garden, or a collaborator on that garden") end end diff --git a/app/views/garden_collaborators/_form.html.haml b/app/views/garden_collaborators/_form.html.haml new file mode 100644 index 000000000..88483ecab --- /dev/null +++ b/app/views/garden_collaborators/_form.html.haml @@ -0,0 +1,19 @@ +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + = bootstrap_form_for(@garden_collaborator.new_record? ? [@garden, @garden_collaborator] : garden_garden_collaborator_path(@garden, @garden_collaborator)) do |f| + .card-body + = required_field_help_text + - if @garden_collaborator.errors.any? + #error_explanation.alert.alert-warning{:role => "alert"} + %h4.alert-heading + = pluralize(@garden_collaborator.errors.size, "error") + prohibited this garden collaborator from being saved + %ul + - @garden_collaborator.errors.full_messages.each do |msg| + %li= msg + + .alert.alert-info + Ask your friend, family member or community garden member for their growstuff username to add them as a collaborator on your garden. + = f.text_field :member_slug, maxlength: 255, required: true + .row + .card-footer + .text-right= f.submit 'Save Collaboator' diff --git a/app/views/garden_collaborators/edit.html.haml b/app/views/garden_collaborators/edit.html.haml new file mode 100644 index 000000000..8993e192b --- /dev/null +++ b/app/views/garden_collaborators/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, "Edit garden collaborator" + += render 'form' \ No newline at end of file diff --git a/app/views/garden_collaborators/index.html.haml b/app/views/garden_collaborators/index.html.haml new file mode 100644 index 000000000..6f9fec3f2 --- /dev/null +++ b/app/views/garden_collaborators/index.html.haml @@ -0,0 +1,72 @@ +- content_for :title, "#{@garden} collaborators" + +%h1= "#{@garden} collaborators" + +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Gardens', gardens_path + %li.breadcrumb-item.active= link_to @garden, gardens_path(@garden) + +.row + .col-md-2 + - if current_member.present? + .flex-column.nav-pills.layout-nav{"role" => "tablist", "aria-orientation"=>"vertical"} + - if can?(:create, GardenCollaborator.new(garden: @garden)) + = link_to url_for([@garden, GardenCollaborator.new(garden: @garden), action: :new]), class: 'btn' do + Add a #{GardenCollaborator.new(garden: @garden).model_name.human} + - else + = render 'shared/signin_signup', to: "record your #{model.to_s.pluralize.downcase}" + + %hr/ + %p.text-center + #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're + harvesting from your home garden and see how productive it is. + + + .col-md-10 + - if @garden_collaborators.empty? + %p There are no collaborators to display. + - if can?(:create, GardenCollaborator) && @owner == current_member + = link_to 'Add a garden collaborator', new_garden_garden_collaborator_path, class: 'btn btn-primary' + + - else + %section + %h2= page_entries_info @garden_collaborators + = will_paginate @garden_collaborators + + - @garden_collaborators.each do |garden_collaborator| + - member = garden_collaborator.member + - cache member do + .card + .card-body + - if can?(:destroy, garden_collaborator) + %div{"style": "float: right"} + = link_to garden_garden_collaborator_path(@garden, garden_collaborator), method: :delete, class: "btn btn-danger" do + Remove access + + %h4.login-name= link_to member, member + %div + = render "members/avatar", member: member + %div + = link_to "view all #{member}'s gardens", member_gardens_path(member) + %p + %small + Joined + = distance_of_time_in_words(member.created_at, Time.zone.now) + ago. + - if member.location.present? + = link_to member.location, place_path(member.location) + .card-footer + %ul.nav.nav-justified.small + %li.nav-item.border-right + = link_to member_plantings_path(member) do + = localize_plural(member.plantings.active, Planting) + %li.nav-item.border-right + = link_to member_harvests_path(member) do + = localize_plural(member.harvests, Harvest) + %li.nav-item + = link_to member_seeds_path(member) do + = localize_plural(member.seeds.active, Seed) + + .row + .col-12= page_entries_info @garden_collaborators + .col-12= will_paginate @garden_collaborators diff --git a/app/views/garden_collaborators/new.html.haml b/app/views/garden_collaborators/new.html.haml new file mode 100644 index 000000000..9b5580903 --- /dev/null +++ b/app/views/garden_collaborators/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, "New garden collaborator" + += render 'form' diff --git a/app/views/garden_collaborators/show.html.haml b/app/views/garden_collaborators/show.html.haml new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index dbe863356..33934d87c 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -99,6 +99,17 @@ %p %strong Owner: = link_to @garden.owner, @garden.owner + %p + %strong Collaborators: + - if can?(:create, GardenCollaborator.new(garden: @garden)) + = link_to "Manage", garden_garden_collaborators_path(@garden) + - if @garden.garden_collaborators.any? + %ul + - @garden.garden_collaborators.each do |collabator| + %li= link_to collabator.member, collabator.member + - else + None + - if @garden.location.present? %p %strong Location: diff --git a/config/routes.rb b/config/routes.rb index 7b29b36e0..1e689a37c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,6 +30,8 @@ Rails.application.routes.draw do resources :gardens, concerns: :has_photos, param: :slug do get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } + + resources :garden_collaborators end resources :plantings, concerns: :has_photos, param: :slug do diff --git a/db/migrate/20240929041435_create_garden_collaborators.rb b/db/migrate/20240929041435_create_garden_collaborators.rb new file mode 100644 index 000000000..3b70b642a --- /dev/null +++ b/db/migrate/20240929041435_create_garden_collaborators.rb @@ -0,0 +1,10 @@ +class CreateGardenCollaborators < ActiveRecord::Migration[7.2] + def change + create_table :garden_collaborators do |t| + t.references :member + t.references :garden + t.timestamps + t.index [:member_id, :garden_id], unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 81cdec75f..44f298856 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do +ActiveRecord::Schema[7.2].define(version: 2024_09_29_041435) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -54,13 +54,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "slug" - t.integer "cached_votes_total", default: 0 - t.integer "cached_votes_score", default: 0 - t.integer "cached_votes_up", default: 0 - t.integer "cached_votes_down", default: 0 - t.integer "cached_weighted_score", default: 0 - t.integer "cached_weighted_total", default: 0 - t.float "cached_weighted_average", default: 0.0 t.integer "likes_count", default: 0 t.index ["garden_id"], name: "index_activities_on_garden_id" t.index ["owner_id"], name: "index_activities_on_owner_id" @@ -214,13 +207,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.text "body", null: false t.datetime "created_at", precision: nil t.datetime "updated_at", precision: nil - t.integer "cached_votes_total", default: 0 - t.integer "cached_votes_score", default: 0 - t.integer "cached_votes_up", default: 0 - t.integer "cached_votes_down", default: 0 - t.integer "cached_weighted_score", default: 0 - t.integer "cached_weighted_total", default: 0 - t.float "cached_weighted_average", default: 0.0 end create_table "crop_companions", force: :cascade do |t| @@ -280,6 +266,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.index ["slug"], name: "index_forums_on_slug", unique: true end + create_table "garden_collaborators", force: :cascade do |t| + t.bigint "member_id" + t.bigint "garden_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["garden_id"], name: "index_garden_collaborators_on_garden_id" + t.index ["member_id", "garden_id"], name: "index_garden_collaborators_on_member_id_and_garden_id", unique: true + t.index ["member_id"], name: "index_garden_collaborators_on_member_id" + end + create_table "garden_types", force: :cascade do |t| t.text "name", null: false t.text "slug", null: false @@ -504,13 +500,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.datetime "date_taken", precision: nil t.integer "likes_count", default: 0 t.string "source" - t.integer "cached_votes_total", default: 0 - t.integer "cached_votes_score", default: 0 - t.integer "cached_votes_up", default: 0 - t.integer "cached_votes_down", default: 0 - t.integer "cached_weighted_score", default: 0 - t.integer "cached_weighted_total", default: 0 - t.float "cached_weighted_average", default: 0.0 t.index ["fullsize_url"], name: "index_photos_on_fullsize_url", unique: true t.index ["thumbnail_url"], name: "index_photos_on_thumbnail_url", unique: true end @@ -553,13 +542,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.integer "days_to_last_harvest" t.integer "parent_seed_id" t.integer "harvests_count", default: 0 - t.integer "cached_votes_total", default: 0 - t.integer "cached_votes_score", default: 0 - t.integer "cached_votes_up", default: 0 - t.integer "cached_votes_down", default: 0 - t.integer "cached_weighted_score", default: 0 - t.integer "cached_weighted_total", default: 0 - t.float "cached_weighted_average", default: 0.0 t.integer "likes_count", default: 0 t.index ["slug"], name: "index_plantings_on_slug", unique: true end @@ -574,13 +556,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.integer "forum_id" t.integer "likes_count", default: 0 t.integer "comments_count", default: 0 - t.integer "cached_votes_total", default: 0 - t.integer "cached_votes_score", default: 0 - t.integer "cached_votes_up", default: 0 - t.integer "cached_votes_down", default: 0 - t.integer "cached_weighted_score", default: 0 - t.integer "cached_weighted_total", default: 0 - t.float "cached_weighted_average", default: 0.0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end @@ -628,22 +603,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_14_024918) do t.index ["slug"], name: "index_seeds_on_slug", unique: true end - create_table "votes", force: :cascade do |t| - t.string "votable_type" - t.bigint "votable_id" - t.string "voter_type" - t.bigint "voter_id" - t.boolean "vote_flag" - t.string "vote_scope" - t.integer "vote_weight" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope" - t.index ["votable_type", "votable_id"], name: "index_votes_on_votable" - t.index ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope" - t.index ["voter_type", "voter_id"], name: "index_votes_on_voter" - end - add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "harvests", "plantings" diff --git a/spec/factories/garden_collaborators.rb b/spec/factories/garden_collaborators.rb new file mode 100644 index 000000000..20cabd2e9 --- /dev/null +++ b/spec/factories/garden_collaborators.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :garden_collaborator do + garden + member + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2dfc3a2e7..40b8bf001 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,9 +7,6 @@ require 'simplecov' # output coverage locally AND send it to coveralls SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter]) -# fail if there's a significant test coverage drop -SimpleCov.maximum_coverage_drop 1 - require 'spec_helper' require File.expand_path('../config/environment', __dir__) require 'rspec/rails' From 0bfa4e4c857b05728c1cc9ec887ea692703974e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 07:12:36 +0000 Subject: [PATCH 05/12] Bump rspec-activemodel-mocks from 1.2.0 to 1.2.1 Bumps [rspec-activemodel-mocks](https://github.com/rspec/rspec-activemodel-mocks) from 1.2.0 to 1.2.1. - [Changelog](https://github.com/rspec/rspec-activemodel-mocks/blob/main/CHANGELOG.md) - [Commits](https://github.com/rspec/rspec-activemodel-mocks/compare/v1.2.0...v1.2.1) --- updated-dependencies: - dependency-name: rspec-activemodel-mocks dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7a90ae62c..0eb431300 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -527,7 +527,7 @@ GEM 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) @@ -536,7 +536,7 @@ GEM rspec-expectations (3.13.2) 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 (7.0.1) From 2c8d0c2d2ff0f1ccf3234bb929afb32cf98d3367 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:54:01 +0000 Subject: [PATCH 06/12] Bump rubocop-rspec from 3.0.5 to 3.1.0 Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 3.0.5 to 3.1.0. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.0.5...v3.1.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0eb431300..163aadf7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -585,7 +585,7 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.5) + rubocop-rspec (3.1.0) rubocop (~> 1.61) rubocop-rspec_rails (2.30.0) rubocop (~> 1.61) From ac22af47183805c763771e1baf6d565adb216b56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:11:41 +0000 Subject: [PATCH 07/12] Bump rswag-specs from 2.14.0 to 2.15.0 Bumps [rswag-specs](https://github.com/rswag/rswag) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/rswag/rswag/releases) - [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md) - [Commits](https://github.com/rswag/rswag/compare/2.14.0...2.15.0) --- updated-dependencies: - dependency-name: rswag-specs dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 163aadf7e..74c07cd0a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -329,7 +329,7 @@ GEM mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) io-console (0.7.2) - irb (1.14.0) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) jquery-rails (4.6.0) @@ -337,8 +337,8 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.7.2) - json-schema (4.3.1) - addressable (>= 2.8) + json-schema (5.0.1) + addressable (~> 2.8) jsonapi-resources (0.10.7) activerecord (>= 4.1) concurrent-ruby @@ -554,9 +554,9 @@ GEM rswag-api (2.14.0) activesupport (>= 5.2, < 8.0) railties (>= 5.2, < 8.0) - rswag-specs (2.14.0) + rswag-specs (2.15.0) activesupport (>= 5.2, < 8.0) - json-schema (>= 2.2, < 5.0) + json-schema (>= 2.2, < 6.0) railties (>= 5.2, < 8.0) rspec-core (>= 2.14) rswag-ui (2.14.0) From 28fe8466458e176e7a40f6a2e5b814b1a8dd50a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:36:51 +0000 Subject: [PATCH 08/12] Bump msgpack from 1.7.2 to 1.7.3 Bumps [msgpack](https://github.com/msgpack/msgpack-ruby) from 1.7.2 to 1.7.3. - [Changelog](https://github.com/msgpack/msgpack-ruby/blob/master/ChangeLog) - [Commits](https://github.com/msgpack/msgpack-ruby/compare/v1.7.2...v1.7.3) --- updated-dependencies: - dependency-name: msgpack dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 74c07cd0a..f1850bc37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -388,7 +388,7 @@ GEM mini_portile2 (2.8.7) minitest (5.25.1) moneta (1.0.0) - msgpack (1.7.2) + msgpack (1.7.3) multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) From e6069168b96d3fbad58089f575bf4a22a903b385 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:55:47 +0000 Subject: [PATCH 09/12] Bump rswag-ui from 2.14.0 to 2.15.0 Bumps [rswag-ui](https://github.com/rswag/rswag) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/rswag/rswag/releases) - [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md) - [Commits](https://github.com/rswag/rswag/compare/2.14.0...2.15.0) --- updated-dependencies: - dependency-name: rswag-ui dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f1850bc37..3ed81acd6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -559,7 +559,7 @@ GEM json-schema (>= 2.2, < 6.0) railties (>= 5.2, < 8.0) rspec-core (>= 2.14) - rswag-ui (2.14.0) + rswag-ui (2.15.0) actionpack (>= 5.2, < 8.0) railties (>= 5.2, < 8.0) rubocop (1.66.1) From 3d9d89726eeeb513d4c3e27e9b06fb5396d5e85f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:15:07 +0000 Subject: [PATCH 10/12] Bump rswag-api from 2.14.0 to 2.15.0 Bumps [rswag-api](https://github.com/rswag/rswag) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/rswag/rswag/releases) - [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md) - [Commits](https://github.com/rswag/rswag/compare/2.14.0...2.15.0) --- updated-dependencies: - dependency-name: rswag-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3ed81acd6..fa5e2d77c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -551,7 +551,7 @@ GEM rspectre (0.1.0) parser (>= 3.2.2.1) rspec (~> 3.9) - rswag-api (2.14.0) + rswag-api (2.15.0) activesupport (>= 5.2, < 8.0) railties (>= 5.2, < 8.0) rswag-specs (2.15.0) From 413b5969d6663f5c0a96a0a9e5177804ef54a77e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:45:51 +0000 Subject: [PATCH 11/12] Bump terser from 1.2.3 to 1.2.4 Bumps [terser](https://github.com/ahorek/terser-ruby) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/ahorek/terser-ruby/releases) - [Changelog](https://github.com/ahorek/terser-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/ahorek/terser-ruby/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: terser dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fa5e2d77c..97c26001d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -645,7 +645,7 @@ GEM temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - terser (1.2.3) + terser (1.2.4) execjs (>= 0.3.0, < 3) thor (1.3.2) thread_safe (0.3.6) From 15537139e4607887035200f401e4eac9e9b75838 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 02:11:25 +0000 Subject: [PATCH 12/12] Bump active_median from 0.4.1 to 0.5.0 Bumps [active_median](https://github.com/ankane/active_median) from 0.4.1 to 0.5.0. - [Changelog](https://github.com/ankane/active_median/blob/master/CHANGELOG.md) - [Commits](https://github.com/ankane/active_median/compare/v0.4.1...v0.5.0) --- updated-dependencies: - dependency-name: active_median dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 97c26001d..5da7c5b81 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,8 +80,8 @@ 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)