Skip to content

Instantly share code, notes, and snippets.

@garethrees
Last active March 24, 2017 10:13
Show Gist options
  • Select an option

  • Save garethrees/b38b5cfa8236c3ca1f84aecf09d20602 to your computer and use it in GitHub Desktop.

Select an option

Save garethrees/b38b5cfa8236c3ca1f84aecf09d20602 to your computer and use it in GitHub Desktop.
Alaveteli new request where the followup is the last_event_forming_initial_request
request = FactoryGirl.create(:info_request, :user => User.last)
mail = RequestMailer.fake_response(request, request.user, 'Plz clarify', nil, nil)
request.receive(mail, mail.encoded, true)
event = request.log_event("status_update",
{ :user_id => request.user.id,
:old_described_state => request.described_state,
:described_state => 'waiting_clarification',
})
request.set_described_state('waiting_clarification', request.user, '')
followup = FactoryGirl.create(:new_information_followup, :info_request => request)
event = request.reload.last_event_forming_initial_request
# Destroying the _actual_ initial outgoing message is fine now,
# because the last_event_forming_initial_request points at the
# clarifying followup.
outgoing = request.outgoing_messages.first
outgoing.destroy
request.reload.last_event_forming_initial_request == event
# => true
followup.destroy
request.reload.last_event_forming_initial_request
# => RuntimeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment