<commit_before>describe 'ActiveResource', ->
  beforeEach ->
    jasmine.Ajax.useMock()

  describe '::Persistence', ->
    describe '#persisted()', ->
      describe 'when the resource is not persisted', ->
        beforeEach ->
          @resource = MyLibrary::Product.build()

        it 'returns false', ->
          expect(@resource.persisted?()).toBeFalsy()

      describe 'when the resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.create(title: 'A product title', description: 'A product description', window.onCompletion)

          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()
          @resource = window.onCompletion.mostRecentCall.args[0]

        it 'returns true', ->
          expect(@resource.persisted?()).toBeTruthy()

    describe '#newresource()', ->
      describe 'when the resource is not persisted', ->
        beforeEach ->
          @resource = MyLibrary::Product.build()

        it 'returns true', ->
          expect(@resource.newresource?()).toBeTruthy()

      describe 'when the resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.create(title: 'A product title', description: 'A product description', window.onCompletion)

          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()
          @resource = window.onCompletion.mostRecentCall.args[0]

        it 'returns false', ->
          expect(@resource.newresource?()).toBeFalsy()

    describe '#save', ->
      describe 'in general', ->
        beforeEach ->
          MyLibrary::Product.last().then window.onSuccess

          mostRecentAjaxRequest().response(JsonApiResponses.Product.all.success)
          @resource = window.onSuccess.mostRecentCall.args[0]

        it 'executes the completion callback', ->
          @resource.save(window.onCompletion)
          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()

      describe 'when resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.last().then window.onSuccess

          mostRecentAjaxRequest().response(JsonApiResponses.Product.all.success)
          @resource = window.onSuccess.mostRecentCall.args[0]
<commit_msg>Patch method name calls<commit_after>describe 'ActiveResource', ->
  beforeEach ->
    jasmine.Ajax.useMock()

  describe '::Persistence', ->
    describe '#persisted()', ->
      describe 'when the resource is not persisted', ->
        beforeEach ->
          @resource = MyLibrary::Product.build()

        it 'returns false', ->
          expect(@resource.persisted?()).toBeFalsy()

      describe 'when the resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.create(title: 'A product title', description: 'A product description', window.onCompletion)

          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()
          @resource = window.onCompletion.mostRecentCall.args[0]

        it 'returns true', ->
          expect(@resource.persisted?()).toBeTruthy()

    describe '#newResource()', ->
      describe 'when the resource is not persisted', ->
        beforeEach ->
          @resource = MyLibrary::Product.build()

        it 'returns true', ->
          expect(@resource.newResource?()).toBeTruthy()

      describe 'when the resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.create(title: 'A product title', description: 'A product description', window.onCompletion)

          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()
          @resource = window.onCompletion.mostRecentCall.args[0]

        it 'returns false', ->
          expect(@resource.newResource?()).toBeFalsy()

    describe '#save', ->
      describe 'in general', ->
        beforeEach ->
          MyLibrary::Product.last().then window.onSuccess

          mostRecentAjaxRequest().response(JsonApiResponses.Product.all.success)
          @resource = window.onSuccess.mostRecentCall.args[0]

        it 'executes the completion callback', ->
          @resource.save(window.onCompletion)
          mostRecentAjaxRequest().response(JsonApiResponses.Product.save.success)
          expect(window.onCompletion).toHaveBeenCalled()

      describe 'when resource is persisted', ->
        beforeEach ->
          MyLibrary::Product.last().then window.onSuccess

          mostRecentAjaxRequest().response(JsonApiResponses.Product.all.success)
          @resource = window.onSuccess.mostRecentCall.args[0]

{'fraction_non_alphanumeric': 0.12400835073068893, 'fraction_numerical': 0.0016701461377870565, 'mean_word_length': 2.857487922705314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4788240', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1221, 'n_words': 235}