Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def edit
def update
if params[:confirm]
@proposal.update(confirmed_at: Time.current)
@proposal.sync_program_session
redirect_to event_event_proposals_url(slug: @event.slug, uuid: @proposal), flash: { success: "Thank you for confirming your participation" }
elsif @proposal.speaker_update_and_notify(proposal_params)
redirect_to event_proposal_url(event_slug: @event.slug, uuid: @proposal)
Expand Down
11 changes: 11 additions & 0 deletions app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def speaker_update_and_notify(attributes)
old_title = title
speaker_updates = attributes.merge({ updated_by_speaker_at: Time.current })
if update(speaker_updates)
sync_program_session
field_names = last_change.join(', ')
reviewers.each do |reviewer|
Notification.create_for(reviewer, proposal: self,
Expand Down Expand Up @@ -282,6 +283,16 @@ def update_tags(old, new, internal)
taggings.create(tags)
end

# When a speaker makes minor changes to their submitted proposal (such as fixing a typo),
# the associated program_session becomes outdated. Consequently, the program.json also becomes outdated.
# Strictly, organizers should prohibit speakers from editing their submitted proposals directly.
# However, for practical reasons, we allow modifications by speakers.
def sync_program_session
if program_session.present?
program_session.update!(title: title, abstract: abstract)
end
end

def has_public_reviewer_comments?
public_comments.reject { |comment| speakers.include?(comment.user_id) }.any?
end
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,26 @@
pitch: 'new_pitch' }}
}.to change { Notification.count }.by(1)
end

context "when the proposal approved (has program_session)" do
let!(:program_session) { create(:program_session, proposal: proposal, track: proposal.track, speakers: [speaker]) }

before do
proposal.update(title: 'orig_title', abstract: "orig_abst", pitch: 'orig_pitch')
program_session.update(title: 'orig_title', abstract: "orig_abst")
end

it "updates the program_session attributes also" do
put :update, params: {event_slug: proposal.event.slug, uuid: proposal,
proposal: { title: 'new_title', abstract: 'new_abst', pitch: 'new_pitch' }}

proposal.reload
program_session.reload
expect(proposal.title).to eq('new_title')
expect(proposal.pitch).to eq('new_pitch')
expect(program_session.title).to eq('new_title')
expect(program_session.abstract).to eq('new_abst')
end
end
end
end