mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-07 01:38:50 +01:00
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:
parent
0877bf9ab8
commit
c2111b2f8e
5 changed files with 101 additions and 54 deletions
21
test/models/todo_from_rich_message_test.rb
Normal file
21
test/models/todo_from_rich_message_test.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
|
||||
class TodoFromRichMessageTest < ActiveSupport::TestCase
|
||||
|
||||
def setup
|
||||
@completed = Todo.find(8)
|
||||
end
|
||||
|
||||
def test_from_rich_message_adds_to_default_context
|
||||
user = @completed.user
|
||||
default_context_id = @completed.context_id
|
||||
builder = TodoFromRichMessage.new(user, default_context_id, "new todo", "notes")
|
||||
new_todo = builder.construct
|
||||
|
||||
assert_not_nil new_todo
|
||||
assert_equal "new todo", new_todo.description
|
||||
assert_equal "notes", new_todo.notes
|
||||
assert_equal default_context_id, new_todo.context_id
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -477,15 +477,4 @@ class TodoTest < ActiveSupport::TestCase
|
|||
assert_equal "<p><strong>test</strong></p>", todo.rendered_notes
|
||||
end
|
||||
|
||||
def test_from_rich_message_adds_to_default_context
|
||||
user = @completed.user
|
||||
default_context_id = @completed.context_id
|
||||
new_todo = Todo::from_rich_message(user, default_context_id, "new todo", "notes")
|
||||
|
||||
assert_not_nil new_todo
|
||||
assert_equal "new todo", new_todo.description
|
||||
assert_equal "notes", new_todo.notes
|
||||
assert_equal default_context_id, new_todo.context_id
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue