mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-31 03:09:06 -04:00
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>
29 lines
778 B
Ruby
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
|