diff --git a/NGitLab.Tests/EventTests.cs b/NGitLab.Tests/EventTests.cs index 23eeb40d..853d1024 100644 --- a/NGitLab.Tests/EventTests.cs +++ b/NGitLab.Tests/EventTests.cs @@ -13,33 +13,69 @@ public class EventTests [NGitLabRetry] public async Task Test_get_user_events_works() { + // Arrange using var context = await GitLabTestContext.CreateAsync(); var project = context.CreateProject(); var currentUserId = context.Client.Users.Current.Id; - var userEvents = context.Client.GetUserEvents(currentUserId); - var globalEvents = context.Client.GetEvents(); + var userEventClient = context.Client.GetUserEvents(currentUserId); - var firstEvent = userEvents.Get(new EventQuery { After = DateTime.UtcNow.AddMonths(-1) }).FirstOrDefault(); + // Act + var firstEvent = userEventClient.Get(new EventQuery { After = DateTime.UtcNow.AddMonths(-1) }).FirstOrDefault(); - if (firstEvent != null) - { - Assert.That(firstEvent.AuthorId, Is.EqualTo(currentUserId)); - } + // Assert + Assert.That(firstEvent, Is.Not.Null); + Assert.That(firstEvent.AuthorId, Is.EqualTo(currentUserId)); } [Test] [NGitLabRetry] public async Task Test_get_global_events_works() { + // Arrange using var context = await GitLabTestContext.CreateAsync(); var project = context.CreateProject(); - var currentUserId = context.Client.Users.Current.Id; - var globalEvents = context.Client.GetEvents(); + var globalEventClient = context.Client.GetEvents(); - var firstEvent = globalEvents.Get(new EventQuery { After = DateTime.UtcNow.AddMonths(-1) }).FirstOrDefault(); + // Act + var firstEvent = globalEventClient.Get(new EventQuery { After = DateTime.UtcNow.AddMonths(-1) }).FirstOrDefault(); + // Assert Assert.That(firstEvent, Is.Not.Null); } + + [Test] + [NGitLabRetry] + public async Task Test_get_events_of_specific_action_type() + { + // Arrange + using var context = await GitLabTestContext.CreateAsync(); + var project = context.CreateProject(); + + var issueClient = context.Client.Issues; + var issueTitle = $"Temporary Issue {Guid.NewGuid()}"; + var issue = issueClient.Create(new IssueCreate + { + ProjectId = project.Id, + Title = issueTitle, + }); + + issueClient.Edit(new IssueEdit + { + ProjectId = project.Id, + IssueId = issue.IssueId, + State = "close", + }); + + var currentUserId = context.Client.Users.Current.Id; + var userEventClient = context.Client.GetUserEvents(currentUserId); + + // Act + var closedEvents = userEventClient.Get(new EventQuery { Action = EventAction.Closed }); + var issueClosedEvent = closedEvents.SingleOrDefault(e => string.Equals(e.TargetTitle, issueTitle)); + + // Assert + Assert.That(issueClosedEvent, Is.Not.Null); + } } diff --git a/NGitLab/Models/EventAction.cs b/NGitLab/Models/EventAction.cs index 9457761c..872691e5 100644 --- a/NGitLab/Models/EventAction.cs +++ b/NGitLab/Models/EventAction.cs @@ -5,20 +5,32 @@ namespace NGitLab.Models; public enum EventAction { Accepted, + [EnumMember(Value = "approved")] Approved, + [EnumMember(Value = "created")] Created, + [EnumMember(Value = "updated")] Updated, Uploaded, Deleted, + [EnumMember(Value = "closed")] Closed, Opened, + [EnumMember(Value = "reopened")] Reopened, + [EnumMember(Value = "pushed")] Pushed, + [EnumMember(Value = "commented")] Commented, + [EnumMember(Value = "merged")] Merged, + [EnumMember(Value = "joined")] Joined, + [EnumMember(Value = "left")] Left, + [EnumMember(Value = "destroyed")] Destroyed, + [EnumMember(Value = "expired")] Expired, [EnumMember(Value = "pushed new")] PushedNew, diff --git a/NGitLab/Models/IssueCreate.cs b/NGitLab/Models/IssueCreate.cs index 92dc888e..212e7258 100644 --- a/NGitLab/Models/IssueCreate.cs +++ b/NGitLab/Models/IssueCreate.cs @@ -38,4 +38,7 @@ public class IssueCreate [JsonPropertyName("epic_id")] public long? EpicId { get; set; } + + [JsonPropertyName("weight")] + public int? Weight { get; set; } } diff --git a/NGitLab/Models/IssueEdit.cs b/NGitLab/Models/IssueEdit.cs index 3a1c4e43..0c69dfa4 100644 --- a/NGitLab/Models/IssueEdit.cs +++ b/NGitLab/Models/IssueEdit.cs @@ -41,4 +41,7 @@ public class IssueEdit [JsonPropertyName("epic_id")] public long? EpicId { get; set; } + + [JsonPropertyName("weight")] + public int? Weight { get; set; } } diff --git a/NGitLab/Models/ProjectUpdate.cs b/NGitLab/Models/ProjectUpdate.cs index e60dde17..2ede3ec4 100644 --- a/NGitLab/Models/ProjectUpdate.cs +++ b/NGitLab/Models/ProjectUpdate.cs @@ -22,8 +22,12 @@ public sealed class ProjectUpdate [Obsolete("Deprecated by GitLab. Use IssuesAccessLevel instead")] public bool? IssuesEnabled { get; set; } + [JsonIgnore] + [Obsolete("Use IssuesAccessLevel instead")] + public string IssuesAccessLeve { get => IssuesAccessLevel; set => IssuesAccessLevel = value; } + [JsonPropertyName("issues_access_level")] - public string IssuesAccessLeve { get; set; } + public string IssuesAccessLevel { get; set; } [JsonPropertyName("merge_pipelines_enabled")] public bool MergePipelinesEnabled { get; set; } @@ -92,6 +96,9 @@ public sealed class ProjectUpdate [JsonPropertyName("request_access_enabled")] public bool? RequestAccessEnabled { get; set; } + [JsonPropertyName("repository_access_level")] + public string RepositoryAccessLevel { get; set; } + [JsonPropertyName("packages_enabled")] public bool? PackagesEnabled { get; set; } diff --git a/NGitLab/PublicAPI.Unshipped.txt b/NGitLab/PublicAPI.Unshipped.txt index f3e14d2b..a9440892 100644 --- a/NGitLab/PublicAPI.Unshipped.txt +++ b/NGitLab/PublicAPI.Unshipped.txt @@ -2291,6 +2291,8 @@ NGitLab.Models.IssueCreate.ProjectId.get -> long NGitLab.Models.IssueCreate.ProjectId.set -> void NGitLab.Models.IssueCreate.Title.get -> string NGitLab.Models.IssueCreate.Title.set -> void +NGitLab.Models.IssueCreate.Weight.get -> int? +NGitLab.Models.IssueCreate.Weight.set -> void NGitLab.Models.IssueEdit NGitLab.Models.IssueEdit.AssigneeId.get -> long? NGitLab.Models.IssueEdit.AssigneeId.set -> void @@ -2315,6 +2317,8 @@ NGitLab.Models.IssueEdit.State.get -> string NGitLab.Models.IssueEdit.State.set -> void NGitLab.Models.IssueEdit.Title.get -> string NGitLab.Models.IssueEdit.Title.set -> void +NGitLab.Models.IssueEdit.Weight.get -> int? +NGitLab.Models.IssueEdit.Weight.set -> void NGitLab.Models.IssueEpic NGitLab.Models.IssueEpic.EpicId.get -> long NGitLab.Models.IssueEpic.EpicId.set -> void @@ -3734,6 +3738,8 @@ NGitLab.Models.ProjectUpdate.GroupRunnersEnabled.get -> bool? NGitLab.Models.ProjectUpdate.GroupRunnersEnabled.set -> void NGitLab.Models.ProjectUpdate.IssuesAccessLeve.get -> string NGitLab.Models.ProjectUpdate.IssuesAccessLeve.set -> void +NGitLab.Models.ProjectUpdate.IssuesAccessLevel.get -> string +NGitLab.Models.ProjectUpdate.IssuesAccessLevel.set -> void NGitLab.Models.ProjectUpdate.IssuesEnabled.get -> bool? NGitLab.Models.ProjectUpdate.IssuesEnabled.set -> void NGitLab.Models.ProjectUpdate.JobsEnabled.get -> bool? @@ -3763,6 +3769,8 @@ NGitLab.Models.ProjectUpdate.PublicBuilds.get -> bool? NGitLab.Models.ProjectUpdate.PublicBuilds.set -> void NGitLab.Models.ProjectUpdate.RemoveSourceBranchAfterMerge.get -> bool? NGitLab.Models.ProjectUpdate.RemoveSourceBranchAfterMerge.set -> void +NGitLab.Models.ProjectUpdate.RepositoryAccessLevel.get -> string +NGitLab.Models.ProjectUpdate.RepositoryAccessLevel.set -> void NGitLab.Models.ProjectUpdate.RequestAccessEnabled.get -> bool? NGitLab.Models.ProjectUpdate.RequestAccessEnabled.set -> void NGitLab.Models.ProjectUpdate.ResolveOutdatedDiffDiscussions.get -> bool?