Files
growstuff/spec/requests/suggestions_spec.rb
T
Brenda Wallace ef06bab74f Add crop suggestions feature and dashboard enhancements
- Introduced crop suggestions functionality allowing users to receive tailored crop recommendations based on their location and preferences.
- Implemented the ability for users to dismiss specific crop suggestions, preventing them from receiving recommendations for crops they are not interested in.
- Added a location picker for users to set their gardening location, enhancing the accuracy of crop suggestions.
- Enhanced the dashboard to display relevant statistics, including plantings and harvests, with comparisons to previous years.
- Created new views and partials for displaying statistics, crop suggestions, and user interactions on the dashboard.
- Updated routes to accommodate new features related to crop suggestions and member locations.
- Added migrations for new database tables and columns to support crop dismissal and suggestion preferences.
- Developed tests for the new features, ensuring functionality and user experience are maintained.
2026-10-12 19:12:18 +13:00

56 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
# The page of every crop to sow this month, and the switch for turning
# suggestions off.
describe 'Crop suggestions' do
include Devise::Test::IntegrationHelpers
let(:member) { create(:member) }
context 'when signed in' do
before { sign_in member }
it 'turns suggestions off' do
patch my_suggestions_path, params: { suggest: false }
expect(member.reload.suggest_crops).to be false
end
it 'turns suggestions back on' do
member.update_columns(suggest_crops: false)
patch my_suggestions_path, params: { suggest: true }
expect(member.reload.suggest_crops).to be true
end
it 'says so when suggestions are turned off' do
patch my_suggestions_path, params: { suggest: false }
expect(flash[:notice]).to eq "We've stopped suggesting crops."
end
it 'asks for a location before suggesting anything' do
get suggestions_path
expect(response.body).to include 'Tell us where you garden and we can suggest what to sow.'
end
it 'lists the month in the title' do
member.update_columns(latitude: -41.3, longitude: 174.7)
get suggestions_path
expect(response.body).to include "Easy to sow in #{I18n.l(Time.zone.today, format: '%B')} near you"
end
it 'says suggestions are off when they are' do
member.update_columns(latitude: -41.3, longitude: 174.7, suggest_crops: false)
get suggestions_path
expect(response.body).to include 'Crop suggestions are off.'
end
end
context 'when signed out' do
it 'does not show the page' do
get suggestions_path
expect(response).to redirect_to new_member_session_path
end
end
end