Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit f864171

Browse files
committed
Display placeholder text if no PR body present.
1 parent 1ae6a85 commit f864171

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public async Task Load(PullRequest pullRequest, IList<PullRequestFile> files)
312312
Number = pullRequest.Number;
313313
Author = new Models.Account(pullRequest.User, avatarProvider.GetAvatar(new AccountCacheItem(pullRequest.User)));
314314
CreatedAt = pullRequest.CreatedAt;
315-
Body = pullRequest.Body;
315+
Body = !string.IsNullOrWhiteSpace(pullRequest.Body) ? pullRequest.Body : "*No description provided.*";
316316
ChangedFilesCount = files.Count;
317317

318318
ChangedFilesTree.Clear();

src/UnitTests/GitHub.App/ViewModels/PullRequestDetailViewModelTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ public class PullRequestDetailViewModelTests : TestBaseClass
1616
{
1717
static readonly Uri Uri = new Uri("http://foo");
1818

19+
[Fact]
20+
public async Task ShouldUsePlaceholderBodyIfNoneExists()
21+
{
22+
var target = CreateTarget();
23+
24+
await target.Load(CreatePullRequest(body: string.Empty), new PullRequestFile[0]);
25+
26+
Assert.Equal("*No description provided.*", target.Body);
27+
}
28+
1929
[Fact]
2030
public async Task ShouldCreateChangesTree()
2131
{
@@ -224,14 +234,14 @@ PullRequestDetailViewModel CreateTarget(
224234
Substitute.For<IAvatarProvider>());
225235
}
226236

227-
PullRequest CreatePullRequest()
237+
PullRequest CreatePullRequest(string body = "PR Body")
228238
{
229239
var repository = CreateRepository("foo", "bar");
230240
var user = CreateUserAndScopes("foo").User;
231241

232242
return new PullRequest(
233243
Uri, Uri, Uri, Uri, Uri, Uri,
234-
1, ItemState.Open, "PR 1", string.Empty,
244+
1, ItemState.Open, "PR 1", body,
235245
DateTimeOffset.Now, DateTimeOffset.Now, null, null,
236246
new GitReference(string.Empty, "foo:bar", "bar", string.Empty, user, repository),
237247
new GitReference(string.Empty, "foo:baz", "baz", string.Empty, user, repository),

0 commit comments

Comments
 (0)