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

Commit

Permalink
Merge pull request #3 from eventbrite/fix-issue-2
Browse files Browse the repository at this point in the history
Fix for Issue #2: Should not be passing "commit=True" to django model in...
  • Loading branch information
Michael Hahn committed May 1, 2014
2 parents 0fe306a + e57ec69 commit 323684c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
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

0 comments on commit 323684c

Please sign in to comment.