Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Fix for Issue #2: Should not be passing "commit=True" to django model in... #3

Merged
merged 1 commit into from
May 1, 2014
Merged
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
4 changes: 2 additions & 2 deletions src/rebar/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def save(self):
if isinstance(form, BaseForm):
form.save(commit=False)

# call save on the instance and commit
self.instance.save(commit=True)
# call save on the instance
self.instance.save()

# call any post-commit hooks that have been stashed on Forms
for form in self.forms:
Expand Down
6 changes: 2 additions & 4 deletions src/rebar/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ def __init__(self, **kwargs):
self.id = None
self.__dict__.update(kwargs)

def save(self, commit=False):

if commit:
self.id = 42
def save(self):
self.id = 42


class CallSentinel(object):
Expand Down
4 changes: 2 additions & 2 deletions src/rebar/tests/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def test_save_calls_instance_save_once(self):

with patch.object(FakeModel, 'save', autospec=True) as save_mock:

save_mock.side_effect = lambda s, commit: setattr(s, 'id', 42)
save_mock.side_effect = lambda s: setattr(s, 'id', 42)
form_data = {
'group-name-first_name': 'John',
'group-name-last_name': 'Doe',
Expand All @@ -561,7 +561,7 @@ def test_save_calls_instance_save_once(self):

form_group.save()

save_mock.assert_called_once_with(ANY, commit=True)
save_mock.assert_called_once_with(ANY)

def test_inline_formsets_saved_after_parent_saved(self):

Expand Down