Files
growstuff/spec/views/crops/show.html.haml_spec.rb
google-labs-jules[bot] 6f0d0afdb8 Fix(specs): Initialize @version_members in crops/show view spec
The `crops/show` view spec was failing with a `NoMethodError` because
the `@version_members` instance variable was `nil`. This variable is used
in the `_history` partial, which is rendered by the `show` view.

This commit fixes the spec by initializing `@version_members` to an
empty hash in the `before` block of the spec. This ensures that the
view can render without errors during the test run.
2025-12-01 02:34:46 +00:00

51 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe "crops/show" do
before do
@crop = FactoryBot.create(:maize)
@posts = []
assign(:crop, @crop)
@member = FactoryBot.create(:crop_wrangling_member)
sign_in @member
@current_member = @member
@harvest = FactoryBot.create(:harvest, owner: @member)
controller.stub(:current_user) { @member }
assign(:version_members, {})
end
it "hides sunniness block if no sunniness" do
render
expect(rendered).to have_no_content "Sunniness"
end
it "has sunniness block if sunny planting" do
FactoryBot.create(:sunny_planting, crop: @crop)
render
expect(rendered).to have_content "Sunniness"
end
it "hides planted from block if no planted_from" do
render
expect(rendered).to have_no_content "Planted from"
end
it "has planted from block if seed planting" do
FactoryBot.create(:seed_planting, crop: @crop)
render
expect(rendered).to have_content "Planted from"
end
it "hides harvested block if no harvests" do
render
expect(rendered).to have_no_content "Harvested for"
end
it "has harvested block if harvest" do
@crop.harvests << @harvest
render
expect(rendered).to have_content "Harvested for"
end
end