From e57ec69d3640b2377778f478ead6066ba88277b2 Mon Sep 17 00:00:00 2001 From: Michael Hahn Date: Thu, 1 May 2014 16:14:50 -0700 Subject: [PATCH] Fix for Issue #2: Should not be passing "commit=True" to django model instance "save" methods Django model's don't have a "commit" kwarg. --- src/rebar/group.py | 4 ++-- src/rebar/tests/helpers.py | 6 ++---- src/rebar/tests/test_groups.py | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/rebar/group.py b/src/rebar/group.py index bd030bd..0598159 100644 --- a/src/rebar/group.py +++ b/src/rebar/group.py @@ -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: diff --git a/src/rebar/tests/helpers.py b/src/rebar/tests/helpers.py index 97312bc..1411ae1 100644 --- a/src/rebar/tests/helpers.py +++ b/src/rebar/tests/helpers.py @@ -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): diff --git a/src/rebar/tests/test_groups.py b/src/rebar/tests/test_groups.py index 8635c29..87fdbbd 100644 --- a/src/rebar/tests/test_groups.py +++ b/src/rebar/tests/test_groups.py @@ -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', @@ -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):