Extract behavior from Todo.from_rich_message

`Todo.from_rich_message` was partially tested from the MessageGateway,
but it is mostly untested and does not belong in Todo due to it's unique
nature. Extract it entirely from `Todo` into it's own dedicated object
for unit testing.
This commit is contained in:
Matt Bridges 2013-07-18 16:35:51 -05:00
parent 0877bf9ab8
commit c2111b2f8e
5 changed files with 101 additions and 54 deletions

View file

@ -23,7 +23,8 @@ class MessageGateway < ActionMailer::Base
end
end
todo = Todo.from_rich_message(user, context.id, description, notes)
todo_builder = TodoFromRichMessage.new(user, context.id, description, notes)
todo = todo_builder.construct
todo.save!
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
end