Repository: robsontenorio/vue-api-query
Pull request #175 (2021-01-19 13:26:24)

chore: config release
Trigger patch release for dependencies updates and remove header of release notes.


Patch:
diff --git a/.releaserc b/.releaserc
index e69de29..e8c259c 100644
--- a/.releaserc
+++ b/.releaserc
@@ -0,0 +1,16 @@
+{
+  "plugins": [
+    ["@semantic-release/commit-analyzer", {
+      "releaseRules": [
+        {"type": "chore", "scope":"deps", "release": "patch"}
+      ]
+    }],
+    ["@semantic-release/release-notes-generator", {
+      "writerOpts": {
+        "headerPartial": ""
+      }
+    }],
+    "@semantic-release/npm",
+    "@semantic-release/github"
+  ]
+}
diff --git a/src/Model.js b/src/Model.js
index f864731..cc3208a 100644
--- a/src/Model.js
+++ b/src/Model.js
@@ -423,6 +423,10 @@ export default class Model extends StaticModel {
    */
 
   delete() {
+    if (this._customResource) {
+      throw Error("The delete() method cannot be used in conjunction with the custom() method. Use for() instead.")
+    }
+
     if (!this.hasId()) {
       throw new Error('This model has a empty ID.')
     }
@@ -436,6 +440,10 @@ export default class Model extends StaticModel {
   }
 
   save() {
+    if (this._customResource) {
+      throw Error("The save() method cannot be used in conjunction with the custom() method. Use for() instead.")
+    }
+
     return this.hasId() ? this._update() : this._create()
   }
 
@@ -472,6 +480,10 @@ export default class Model extends StaticModel {
    */
 
   attach(params) {
+    if (this._customResource) {
+      throw Error("The attach() method cannot be used in conjunction with the custom() method. Use for() instead.")
+    }
+
     return this.request(
       this._reqConfig({
         method: 'POST',
@@ -482,6 +494,10 @@ export default class Model extends StaticModel {
   }
 
   sync(params) {
+    if (this._customResource) {
+      throw Error("The sync() method cannot be used in conjunction with the custom() method. Use for() instead.")
+    }
+
     return this.request(
       this._reqConfig({
         method: 'PUT',


Test patch:
diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml
index e31e783..df00063 100644
--- a/.github/workflows/test-and-release.yml
+++ b/.github/workflows/test-and-release.yml
@@ -5,15 +5,49 @@ name: Test and Release
 
 on:
   push:
-    branches: [ master, dev ]
+    branches: [
+        master,
+        dev,
+        alpha,
+        beta,
+        next,
+        next-major
+    ]
 
   pull_request:
-    branches: [ master, dev ]
+    branches: [
+        master,
+        dev,
+        alpha,
+        beta,
+        next,
+        next-major
+    ]
 
 jobs:
+  pre_job:
+    name: Pre Job
+
+    runs-on: ubuntu-latest
+
+    outputs:
+      should_skip: ${{ steps.skip_check.outputs.should_skip }}
+
+    steps:
+      - id: skip_check
+        uses: fkirc/skip-duplicate-actions@master
+        with:
+          github_token: ${{ github.token }}
+          paths_ignore: '["**/*.md", ".releaserc", ".editorconfig", ".gitignore", ".eslintignore", ".prettierignore", "docs/**", ".github/**"]'
+          do_not_skip: '["workflow_dispatch", "schedule"]'
+
   test:
     name: Test
 
+    needs: pre_job
+
+    if: needs.pre_job.outputs.should_skip != 'true' || (github.ref != 'refs/heads/dev' && github.head_ref != 'dev' && github.base_ref != 'dev')
+
     runs-on: ${{ matrix.os }}
 
     strategy:
@@ -55,7 +89,7 @@ jobs:
 
     runs-on: ${{ matrix.os }}
 
-    if: github.event_name == 'push' && github.ref == 'refs/heads/master'
+    if: github.event_name == 'push'
 
     strategy:
       matrix:
diff --git a/tests/model.test.js b/tests/model.test.js
index 385970f..368b62f 100644
--- a/tests/model.test.js
+++ b/tests/model.test.js
@@ -960,6 +960,38 @@ describe('Model methods', () => {
     expect(errorModel).toThrow('Arguments to custom() must be strings or instances of Model.')
   })
 
+  test('it throws an error when CRUD and relationship operations are used in conjunction with custom()', () => {
+    errorModel = () => {
+      const post = new Post({ text: 'Hello' }).custom('foo/bar').save()
+    }
+
+    expect(errorModel).toThrow("The save() method cannot be used in conjunction with the custom() method. Use for() instead.")
+
+    errorModel = () => {
+      const post = new Post({ id: 1 }).custom('foo/bar').delete()
+    }
+
+    expect(errorModel).toThrow("The delete() method cannot be used in conjunction with the custom() method. Use for() instead.")
+
+    errorModel = () => {
+      const post = new Post({ id: 1 })
+      const comment = post.comments().custom('foo/bar').attach({
+        text: 'Awesome post!'
+      })
+    }
+
+    expect(errorModel).toThrow("The attach() method cannot be used in conjunction with the custom() method. Use for() instead.")
+
+    errorModel = () => {
+      const post = new Post({ id: 1 })
+      const comment = post.comments().custom('foo/bar').sync({
+        text: 'Awesome post!'
+      })
+    }
+
+    expect(errorModel).toThrow("The sync() method cannot be used in conjunction with the custom() method. Use for() instead.")
+  })
+
   test('save() method makes a PUT request to the correct URL on nested object thas was fetched with find() method', async () => {
     axiosMock.onGet('http://localhost/posts/1/comments/1').reply(200, commentsResponse[0])
     axiosMock.onPut('http://localhost/posts/1/comments/1').reply(200, commentsResponse[0])