mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-28 19:51:57 -04:00
* This change introduces a new feature that allows users to create recurring activities. A user can now specify that an activity should be repeated "X" times, every "Y" weeks. When an activity is created with these options, the application will create the initial activity and then "X" additional copies, with each copy's due date offset by "Y" weeks from the previous one. The repeat information is not stored in the database. It is only used at the time of creation to generate the recurring activities. The following changes were made: - Updated the new activity form to include fields for "repeat times" and "repeat weeks". - Modified the `ActivitiesController#create` action to handle the creation of recurring activities. - Added feature tests to ensure the new functionality works as expected. * Remove not very useful spec --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.feature 'Creating a recurring activity' do
|
|
let(:member) { create(:member) }
|
|
let!(:garden) { create(:garden, owner: member) }
|
|
|
|
before do
|
|
login_as(member)
|
|
visit new_activity_path
|
|
end
|
|
|
|
scenario 'a member creates a recurring activity' do
|
|
fill_in 'What needs to be done?', with: 'Water the plants'
|
|
select 'Watering', from: 'activity_category'
|
|
fill_in 'Repeat how many times?', with: '3'
|
|
fill_in 'Every how many weeks?', with: '2'
|
|
click_button 'Save'
|
|
|
|
expect(page).to have_content('Activity was successfully created.')
|
|
expect(Activity.count).to eq(4)
|
|
|
|
original_activity = Activity.first
|
|
expect(original_activity.name).to eq('Water the plants')
|
|
expect(original_activity.due_date).to eq(Date.today)
|
|
|
|
second_activity = Activity.second
|
|
expect(second_activity.name).to eq('Water the plants')
|
|
expect(second_activity.due_date).to eq(Date.today + 2.weeks)
|
|
|
|
third_activity = Activity.third
|
|
expect(third_activity.name).to eq('Water the plants')
|
|
expect(third_activity.due_date).to eq(Date.today + 4.weeks)
|
|
|
|
fourth_activity = Activity.fourth
|
|
expect(fourth_activity.name).to eq('Water the plants')
|
|
expect(fourth_activity.due_date).to eq(Date.today + 6.weeks)
|
|
end
|
|
end
|