Skip to content

Commit

Permalink
Default new meeting time to next week
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Nov 26, 2023
1 parent fce2fb2 commit 355ba32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions modules/meeting/app/models/meeting.rb
Expand Up @@ -165,13 +165,15 @@ def all_changeable_participants
def copy(attrs)
copy = dup

# Called simply to initialize the value
copy.start_date
copy.start_time_hour
# Set a default to next week
copy.start_time = start_time + 1.week

copy.author = attrs.delete(:author)
copy.attributes = attrs
copy.set_initial_values
# Initialize virtual attributes
copy.start_date
copy.start_time_hour

copy.participants.clear
copy.participants_attributes = allowed_participants.collect(&:copy_attributes)
Expand Down
4 changes: 2 additions & 2 deletions modules/meeting/spec/features/meetings_copy_spec.rb
Expand Up @@ -62,7 +62,7 @@

shared_let(:twelve_hour_format) { "%I:%M %p" }
shared_let(:copied_meeting_time_heading) do
date = start_time.strftime("%m/%d/%Y")
date = start_time.next_week.strftime("%m/%d/%Y")
start_of_meeting = start_time.strftime(twelve_hour_format)
end_of_meeting = (start_time + meeting.duration.hours).strftime(twelve_hour_format)

Expand Down Expand Up @@ -90,7 +90,7 @@
expect(page)
.to have_field 'Duration', with: meeting.duration
expect(page)
.to have_field 'Start date', with: start_time.strftime("%Y-%m-%d")
.to have_field 'Start date', with: start_time.next_week.strftime("%Y-%m-%d")
expect(page)
.to have_field 'Time', with: start_time.strftime("%H:%M")

Expand Down
Expand Up @@ -271,7 +271,7 @@
click_button 'Create'

expect(page).to have_text 'Your meeting is empty'
new_meeting = StructuredMeeting.order(id: :asc).last
new_meeting = StructuredMeeting.reorder(id: :asc).last
expect(page).to have_current_path "/meetings/#{new_meeting.id}"
end

Expand Down

0 comments on commit 355ba32

Please sign in to comment.