diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs
index 008d9955b0..d9ca53a334 100644
--- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using System.Reactive;
namespace Octokit.Reactive
{
@@ -156,5 +157,25 @@ public interface IObservableIssuesClient
///
///
IObservable Update(string owner, string name, int number, IssueUpdate issueUpdate);
+
+ ///
+ /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
+ ///
+ /// https://developer.github.com/v3/issues/#lock-an-issue
+ /// The owner of the repository
+ /// The name of the repository
+ /// The issue number
+ ///
+ IObservable Lock(string owner, string name, int number);
+
+ ///
+ /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
+ ///
+ /// https://developer.github.com/v3/issues/#unlock-an-issue
+ /// The owner of the repository
+ /// The name of the repository
+ /// The issue number
+ ///
+ IObservable Unlock(string owner, string name, int number);
}
-}
+}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs
index 4571696334..007b743db4 100644
--- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs
@@ -1,6 +1,7 @@
using System;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
+using System.Reactive;
namespace Octokit.Reactive
{
@@ -222,5 +223,37 @@ public IObservable Update(string owner, string name, int number, IssueUpd
return _client.Update(owner, name, number, issueUpdate).ToObservable();
}
+
+ ///
+ /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
+ ///
+ /// https://developer.github.com/v3/issues/#lock-an-issue
+ /// The owner of the repository
+ /// The name of the repository
+ /// The issue number
+ ///
+ public IObservable Lock(string owner, string name, int number)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
+ return _client.Lock(owner, name, number).ToObservable();
+ }
+
+ ///
+ /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
+ ///
+ /// https://developer.github.com/v3/issues/#unlock-an-issue
+ /// The owner of the repository
+ /// The name of the repository
+ /// The issue number
+ ///
+ public IObservable Unlock(string owner, string name, int number)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
+ return _client.Unlock(owner, name, number).ToObservable();
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs
index 3dd7be567f..c9619a4bef 100644
--- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs
@@ -61,6 +61,24 @@ public async Task CanCreateRetrieveAndCloseIssue()
}
[IntegrationTest]
+ public async Task CanLockAndUnlockIssue()
+ {
+ var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
+ Assert.False(issue.Locked);
+
+ await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
+ var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
+ Assert.NotNull(retrieved);
+ Assert.True(retrieved.Locked);
+
+ await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
+ retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
+ Assert.NotNull(retrieved);
+ Assert.False(retrieved.Locked);
+ }
+
+ [IntegrationTest]
public async Task CanListOpenIssuesWithDefaultSort()
{
var newIssue1 = new NewIssue("A test issue1") { Body = "A new unassigned issue" };
diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs
index 5eb94af756..9c6acf9885 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs
@@ -72,6 +72,23 @@ public async Task CanCreateAndUpdateIssues()
Assert.Equal("Modified integration test issue", updateResult.Title);
}
+ [IntegrationTest]
+ public async Task CanLockAndUnlockIssues()
+ {
+ var newIssue = new NewIssue("Integration Test Issue");
+
+ var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
+ Assert.False(createResult.Locked);
+
+ await _client.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
+ var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
+ Assert.True(lockResult.Locked);
+
+ await _client.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
+ var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
+ Assert.False(unlockIssueResult.Locked);
+ }
+
public void Dispose()
{
_context.Dispose();
diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs
index 2f3b759b19..bcb14395f9 100644
--- a/Octokit.Tests/Clients/IssuesClientTests.cs
+++ b/Octokit.Tests/Clients/IssuesClientTests.cs
@@ -185,6 +185,58 @@ public async Task EnsuresArgumentsNotNull()
}
}
+ public class TheLockMethod
+ {
+ [Fact]
+ public void PostsToCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new IssuesClient(connection);
+
+ client.Lock("fake", "repo", 42);
+
+ connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any