Files
growstuff/spec/requests/harvests_spec.rb
T
Daniel O'Connorandgoogle-labs-jules[bot] c7eef27f9a Fix new harvest from planting not prefilling crop (#4786)
When initializing a new harvest from a planting (via `planting_slug`
or `harvest[planting_id]`), `HarvestsController#new` now properly looks
up the planting, assigns `@harvest.planting` and `@harvest.crop` from
the planting's crop, and sets `@planting` and `@crop` instance variables
for view rendering.

Regression tests added to `HarvestsController` spec and request spec.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-09-20 14:10:14 +09:30

29 lines
778 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe "Harvests" do
let(:member) { create(:member) }
let(:crop) { create(:crop, name: "Super Tomato") }
let(:planting) { create(:planting, crop: crop, owner: member, garden: member.gardens.first) }
describe "GET /harvests" do
it "works!" do
get harvests_path
expect(response).to have_http_status :ok
end
end
describe "GET /plantings/:planting_slug/harvests/new" do
before { sign_in member }
it "prefills planting crop information" do
get new_planting_harvest_path(planting_slug: planting.slug)
expect(response).to have_http_status :ok
expect(response.body).to include(crop.name)
expect(response.body).to include(planting.garden.name)
end
end
end