Skip to content

Commit

Permalink
Merge 2e7dc7a into ba2637e
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhub committed Aug 14, 2019
2 parents ba2637e + 2e7dc7a commit 9e4c874
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 2 additions & 5 deletions doorstop/core/item.py
Expand Up @@ -501,7 +501,6 @@ def set_attributes(self, attributes):
"""Set the item's attributes and save them."""
self._set_attributes(attributes)

@auto_save
def edit(self, tool=None, edit_all=True):
"""Open the item for editing.
Expand All @@ -515,7 +514,9 @@ def edit(self, tool=None, edit_all=True):
self.tree.vcs.lock(self.path)
# Edit the whole file in an editor
if edit_all:
self.save()
editor.edit(self.path, tool=tool)
self.load(True)
# Edit only the text part in an editor
else:
# Edit the text in a temporary file
Expand All @@ -524,10 +525,6 @@ def edit(self, tool=None, edit_all=True):
)
# Save the text in the actual item file
self.text = edited_text
self.save()

# Force reloaded
self._loaded = False

@auto_save
def link(self, value):
Expand Down
4 changes: 3 additions & 1 deletion doorstop/core/tests/test_item.py
Expand Up @@ -426,8 +426,9 @@ def test_extended_set_standard(self):
self.item.set('text', "extended access")
self.assertEqual("extended access", self.item.text)

@patch('doorstop.core.item.Item.load')
@patch('doorstop.core.editor.launch')
def test_edit(self, mock_launch):
def test_edit(self, mock_launch, mock_load):
"""Verify an item can be edited."""
self.item.tree = Mock()
# Act
Expand All @@ -436,6 +437,7 @@ def test_edit(self, mock_launch):
self.item.tree.vcs.lock.assert_called_once_with(self.item.path)
self.item.tree.vcs.edit.assert_called_once_with(self.item.path)
mock_launch.assert_called_once_with(self.item.path, tool='mock_editor')
mock_load.assert_called_once_with(True)

def test_link(self):
"""Verify links can be added to an item."""
Expand Down

0 comments on commit 9e4c874

Please sign in to comment.