'Posting a new or updated detail object with a related m2m object
should save the m2m object if it\'s included inline.'

def test_save_m2m_changed(self):

    resource = api.canonical_resource_for('tag')
    request = MockRequest()
    request.GET = {'format': 'json'}
    request.method = 'POST'
    body_dict = {'name': 'school', 'taggabletags': [{'extra': 7}]}
    request.set_body(json.dumps(body_dict))
    with self.assertNumQueries(4):
        resp = resource.wrap_view('dispatch_list')(request)
    self.assertEqual(resp.status_code, 201)
    tag = Tag.objects.all()[0]
    taggable_tag = tag.taggabletags.all()[0]
    self.assertEqual(taggable_tag.extra, 7)
    body_dict['taggabletags'] = [{'extra': 1234}]
    request.set_body(json.dumps(body_dict))
    request.path = reverse('api_dispatch_detail', kwargs={'pk': tag.pk, 'resource_name': resource._meta.resource_name, 'api_name': resource._meta.api_name})
    with self.assertNumQueries(5):
        resource.put_detail(request)
    tag = Tag.objects.all()[0]
    taggable_tag = tag.taggabletags.all()[0]
    self.assertEqual(taggable_tag.extra, 1234)
