Merge pull request #4332 from Growstuff/crops-controller

Add coverage for crops
This commit is contained in:
Daniel O'Connor
2025-11-29 15:32:08 +10:30
committed by GitHub
parent 0a89ac7e28
commit 474f09e110
4 changed files with 12 additions and 6 deletions

View File

@@ -27,7 +27,7 @@ services:
command: sleep infinity
db:
image: postgres:latest
image: postgres:17
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data

View File

@@ -32,6 +32,7 @@
- if @crop.en_youtube_url.present?
%section.youtube
%h2 Video
.embed-responsive.embed-responsive-16by9
%iframe.embed-responsive-item{ src: "https://www.youtube.com/embed/#{youtube_video_id(@crop.en_youtube_url)}", allowfullscreen: true }

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_09_01_144900) do
ActiveRecord::Schema[7.2].define(version: 2025_11_28_200506) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -259,6 +259,8 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_144900) do
t.string "sowing_method"
t.string "sun_requirements"
t.integer "growing_degree_days"
t.string "en_youtube_url"
t.text "description"
t.index ["creator_id"], name: "index_crops_on_creator_id"
t.index ["name"], name: "index_crops_on_name"
t.index ["parent_id"], name: "index_crops_on_parent_id"
@@ -583,7 +585,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_144900) do
t.integer "harvests_count", default: 0
t.integer "likes_count", default: 0
t.boolean "failed", default: false, null: false
t.boolean "from_other_source"
t.integer "overall_rating"
t.index ["crop_id"], name: "index_plantings_on_crop_id"
t.index ["garden_id"], name: "index_plantings_on_garden_id"

View File

@@ -101,7 +101,7 @@ describe CropsController do
it { expect { subject }.to change(AlternateName, :count).by(2) }
it { expect { subject }.to change(ScientificName, :count).by(1) }
context 'with openfarm data' do
context 'with data' do
let(:crop_params) do
{
crop: {
@@ -110,16 +110,18 @@ describe CropsController do
row_spacing: 10,
spread: 20,
height: 30,
description: 'hello',
sowing_method: 'direct',
sun_requirements: 'full sun',
growing_degree_days: 100
growing_degree_days: 100,
en_youtube_url: 'https://www.youtube.com/watch?v=INZybkX8tLI'
},
alt_name: { '1': "egg plant", '2': "purple apple" },
sci_name: { '1': "fancy sci name", '2': "" }
}
end
it 'saves openfarm data' do
it 'saves data' do
subject
crop = Crop.last
expect(crop.row_spacing).to eq(10)
@@ -128,6 +130,8 @@ describe CropsController do
expect(crop.sowing_method).to eq('direct')
expect(crop.sun_requirements).to eq('full sun')
expect(crop.growing_degree_days).to eq(100)
expect(crop.description).to eq 'hello'
expect(crop.en_youtube_url).to eq 'https://www.youtube.com/watch?v=INZybkX8tLI'
end
end
end