Skip to content

Commit 4f0b370

Browse files
committed
fix(branches): fix breaking change from probot v14 since this plugin still uses the rest method
fixes #1255
1 parent a2cacf6 commit 4f0b370

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

lib/plugins/branches.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export default class Branches {
1818
const params = Object.assign(this.repo, { branch: branch.name })
1919

2020
if (this.isEmpty(branch.protection)) {
21-
return this.github.repos.deleteBranchProtection(params)
21+
return this.github.rest.repos.deleteBranchProtection(params)
2222
} else {
2323
Object.assign(params, branch.protection, { headers: previewHeaders })
24-
return this.github.repos.updateBranchProtection(params)
24+
return this.github.rest.repos.updateBranchProtection(params)
2525
}
2626
})
2727
)

test/unit/lib/plugins/branches.test.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ describe('Branches', () => {
1010

1111
beforeEach(() => {
1212
github = {
13-
repos: {
14-
updateBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('updateBranchProtection')),
15-
deleteBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('deleteBranchProtection'))
13+
rest: {
14+
repos: {
15+
updateBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('updateBranchProtection')),
16+
deleteBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('deleteBranchProtection'))
17+
}
1618
}
1719
}
1820
})
@@ -36,7 +38,7 @@ describe('Branches', () => {
3638
])
3739

3840
return plugin.sync().then(() => {
39-
expect(github.repos.updateBranchProtection).toHaveBeenCalledWith({
41+
expect(github.rest.repos.updateBranchProtection).toHaveBeenCalledWith({
4042
owner: 'bkeepers',
4143
repo: 'test',
4244
branch: 'master',
@@ -66,8 +68,8 @@ describe('Branches', () => {
6668
])
6769

6870
return plugin.sync().then(() => {
69-
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
70-
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
71+
expect(github.rest.repos.updateBranchProtection).not.toHaveBeenCalled()
72+
expect(github.rest.repos.deleteBranchProtection).toHaveBeenCalledWith({
7173
owner: 'bkeepers',
7274
repo: 'test',
7375
branch: 'master'
@@ -86,8 +88,8 @@ describe('Branches', () => {
8688
])
8789

8890
return plugin.sync().then(() => {
89-
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
90-
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
91+
expect(github.rest.repos.updateBranchProtection).not.toHaveBeenCalled()
92+
expect(github.rest.repos.deleteBranchProtection).toHaveBeenCalledWith({
9193
owner: 'bkeepers',
9294
repo: 'test',
9395
branch: 'master'
@@ -106,8 +108,8 @@ describe('Branches', () => {
106108
])
107109

108110
return plugin.sync().then(() => {
109-
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
110-
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
111+
expect(github.rest.repos.updateBranchProtection).not.toHaveBeenCalled()
112+
expect(github.rest.repos.deleteBranchProtection).toHaveBeenCalledWith({
111113
owner: 'bkeepers',
112114
repo: 'test',
113115
branch: 'master'
@@ -126,8 +128,8 @@ describe('Branches', () => {
126128
])
127129

128130
return plugin.sync().then(() => {
129-
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
130-
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
131+
expect(github.rest.repos.updateBranchProtection).not.toHaveBeenCalled()
132+
expect(github.rest.repos.deleteBranchProtection).toHaveBeenCalledWith({
131133
owner: 'bkeepers',
132134
repo: 'test',
133135
branch: 'master'
@@ -145,8 +147,8 @@ describe('Branches', () => {
145147
])
146148

147149
return plugin.sync().then(() => {
148-
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
149-
expect(github.repos.deleteBranchProtection).not.toHaveBeenCalled()
150+
expect(github.rest.repos.updateBranchProtection).not.toHaveBeenCalled()
151+
expect(github.rest.repos.deleteBranchProtection).not.toHaveBeenCalled()
150152
})
151153
})
152154
})
@@ -165,9 +167,9 @@ describe('Branches', () => {
165167
])
166168

167169
return plugin.sync().then(() => {
168-
expect(github.repos.updateBranchProtection).toHaveBeenCalledTimes(2)
170+
expect(github.rest.repos.updateBranchProtection).toHaveBeenCalledTimes(2)
169171

170-
expect(github.repos.updateBranchProtection).toHaveBeenLastCalledWith({
172+
expect(github.rest.repos.updateBranchProtection).toHaveBeenLastCalledWith({
171173
owner: 'bkeepers',
172174
repo: 'test',
173175
branch: 'other',

0 commit comments

Comments
 (0)