8000 Use owner name as site title for User and Organization sites. by lardieri · Pull Request #197 · jekyll/github-metadata · GitHub
[go: up one dir, main page]

Skip to content

Use owner name as site title for User and Organization sites. #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Test cases for setting title of User and Org sites.
When generating metadata for a GitHub Pages site of a User or Organization, the default site title should be:
* the User/Org's display name, if there is one; or
* the User/Org's login, if there is no display name.
  • Loading branch information
lardieri committed Jul 10, 2021
commit 5e5b0af4eaaed725557e065e49ed49a10dc7cb67
58 changes: 58 additions & 0 deletions spec/site_github_munger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,64 @@
end
end

context "generating repo for user with displayname" do
before(:each) do
ENV["JEKYLL_ENV"] = "production"
ENV["PAGES_REPO_NWO"] = "jekyllbot/jekyllbot.github.io"
stub_api("/repos/jekyllbot/jekyllbot.github.io", "user_site")
stub_api_404("/orgs/jekyllbot")
stub_api("/users/jekyllbot", "user_with_displayname")
subject.munge!
end

it "sets title to user's displayname" do
expect(site.config["title"]).to eql("Jekyll Bot")
end
end

context "generating repo for user without displayname" do
before(:each) do
ENV["JEKYLL_ENV"] = "production"
ENV["PAGES_REPO_NWO"] = "jekyllbot/jekyllbot.github.io"
stub_api("/repos/jekyllbot/jekyllbot.github.io", "user_site")
stub_api_404("/orgs/jekyllbot")
stub_api("/users/jekyllbot", "user_without_displayname")
subject.munge!
end

it "sets title to user's login" do
expect(site.config["title"]).to eql("jekyllbot")
end
end

context "generating repo for org with displayname" do
before(:each) do
ENV["JEKYLL_ENV"] = "production"
ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io"
stub_api("/repos/jekyll/jekyll.github.io", "repo")
stub_api("/orgs/jekyll", "org",)
subject.munge!
end

it "sets title to org's displayname" do
expect(site.config["title"]).to eql("Jekyll")
end
end

context "generating repo for org without displayname" do
before(:each) do
ENV["JEKYLL_ENV"] = "production"
ENV["PAGES_REPO_NWO"] = "jekyll/jekyll.github.io"
stub_api("/repos/jekyll/jekyll.github.io", "repo")
stub_api("/orgs/jekyll", "org_without_displayname",)
subject.munge!
end

it "sets title to org's login" do
expect(site.config["title"]).to eql("jekyll")
end
end

context "with a client with no credentials" do
before(:each) do
Jekyll::GitHubMetadata.client = Jekyll::GitHubMetadata::Client.new(:access_token => "")
Expand Down
30 changes: 30 additions & 0 deletions spec/webmock/api_get_org_without_displayname.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"login": "jekyll",
"id": 3083652,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMwODM2NTI=",
"url": "https://api.github.com/orgs/jekyll",
"repos_url": "https://api.github.com/orgs/jekyll/repos",
"events_url": "https://api.github.com/orgs/jekyll/events",
"hooks_url": "https://api.github.com/orgs/jekyll/hooks",
"issues_url": "https://api.github.com/orgs/jekyll/issues",
"members_url": "https://api.github.com/orgs/jekyll/members{/member}",
"public_members_url": "https://api.github.com/orgs/jekyll/public_members{/member}",
"avatar_url": "https://avatars0.githubusercontent.com/u/3083652?v=4",
"description": "Jekyll is a blog-aware, static site generator in Ruby.",
"name": null,
"company": null,
"blog": "https://jekyllrb.com",
"location": null,
"email": "",
"is_verified": true,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 50,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/jekyll",
"created_at": "2012-12-19T19:37:35Z",
"updated_at": "2019-01-27T15:27:32Z",
"type": "Organization"
}
103 changes: 103 additions & 0 deletions spec/webmock/api_get_user_site.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"id": 50212532,
"node_id": "MDEwOlJlcG9zaXRvcnk1MDIxMjUzMg==",
"name": "github-pages-site",
"full_name": "jekyllbot/github-pages-site",
"private": false,
"owner": {
"login": "jekyllbot",
"id": 6166343,
"node_id": "MDQ6VXNlcjYxNjYzNDM=",
"avatar_url": "https://avatars.githubusercontent.com/u/6166343?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jekyllbot",
"html_url": "https://github.com/jekyllbot",
"followers_url": "https://api.github.com/users/jekyllbot/followers",
"following_url": "https://api.github.com/users/jekyllbot/following{/other_user}",
"gists_url": "https://api.github.com/users/jekyllbot/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jekyllbot/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jekyllbot/subscriptions",
"organizations_url": "https://api.github.com/users/jekyllbot/orgs",
"repos_url": "https://api.github.com/users/jekyllbot/repos",
"events_url": "https://api.github.com/users/jekyllbot/events{/privacy}",
"received_events_url": "https://api.github.com/users/jekyllbot/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/jekyllbot/github-pages-site",
"description": "Example GitHub Pages Site",
"fork": false,
"url": "https://api.github.com/repos/jekyllbot/github-pages-site",
"forks_url": "https://api.github.com/repos/jekyllbot/github-pages-site/forks",
"keys_url": "https://api.github.com/repos/jekyllbot/github-pages-site/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/jekyllbot/github-pages-site/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/jekyllbot/github-pages-site/teams",
"hooks_url": "https://api.github.com/repos/jekyllbot/github-pages-site/hooks",
"issue_events_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues/events{/number}",
"events_url": "https://api.github.com/repos/jekyllbot/github-pages-site/events",
"assignees_url": "https://api.github.com/repos/jekyllbot/github-pages-site/assignees{/user}",
"branches_url": "https://api.github.com/repos/jekyllbot/github-pages-site/branches{/branch}",
"tags_url": "https://api.github.com/repos/jekyllbot/github-pages-site/tags",
"blobs_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/jekyllbot/github-pages-site/statuses/{sha}",
"languages_url": "https://api.github.com/repos/jekyllbot/github-pages-site/languages",
"stargazers_url": "https://api.github.com/repos/jekyllbot/github-pages-site/stargazers",
"contributors_url": "https://api.github.com/repos/jekyllbot/github-pages-site/contributors",
"subscribers_url": "https://api.github.com/repos/jekyllbot/github-pages-site/subscribers",
"subscription_url": "https://api.github.com/repos/jekyllbot/github-pages-site/subscription",
"commits_url": "https://api.github.com/repos/jekyllbot/github-pages-site/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/jekyllbot/github-pages-site/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/jekyllbot/github-pages-site/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/jekyllbot/github-pages-site/contents/{+path}",
"compare_url": "https://api.github.com/repos/jekyllbot/github-pages-site/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/jekyllbot/github-pages-site/merges",
"archive_url": "https://api.github.com/repos/jekyllbot/github-pages-site/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/jekyllbot/github-pages-site/downloads",
"issues_url": "https://api.github.com/repos/jekyllbot/github-pages-site/issues{/number}",
"pulls_url": "https://api.github.com/repos/jekyllbot/github-pages-site/pulls{/number}",
"milestones_url": "https://api.github.com/repos/jekyllbot/github-pages-site/milestones{/number}",
"notifications_url": "https://api.github.com/repos/jekyllbot/github-pages-site/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/jekyllbot/github-pages-site/labels{/name}",
"releases_url": "https://api.github.com/repos/jekyllbot/github-pages-site/releases{/id}",
"deployments_url": "https://api.github.com/repos/jekyllbot/github-pages-site/deployments",
"created_at": "2016-01-22T22:53:40Z",
"updated_at": "2017-07-13T20:03:10Z",
"pushed_at": "2016-11-20T00:18:58Z",
"git_url": "git://github.com/jekyllbot/github-pages-site.git",
"ssh_url": "git@github.com:jekyllbot/github-pages-site.git",
"clone_url": "https://github.com/jekyllbot/github-pages-site.git",
"svn_url": "https://github.com/jekyllbot/github-pages-site",
"homepage": "https://jekyllbot.github.io/github-pages-site/",
"size": 16,
"stargazers_count": 6,
"watchers_count": 6,
"language": "JavaScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": true,
"forks_count": 6,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 6,
"open_issues": 0,
"watchers": 6,
"default_branch": "gh-pages",
"temp_clone_token": null,
"network_count": 6,
"subscribers_count": 1
}
33 changes: 33 additions & 0 deletions spec/webmock/api_get_user_with_displayname.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"login": "jekyllbot",
"id": 6166343,
"node_id": "MDQ6VXNlcjYxNjYzNDM=",
"avatar_url": "https://avatars0.githubusercontent.com/u/6166343?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jekyllbot",
"html_url": "https://github.com/jekyllbot",
"followers_url": "https://api.github.com/users/jekyllbot/followers",
"following_url": "https://api.github.com/users/jekyllbot/following{/other_user}",
"gists_url": "https://api.github.com/users/jekyllbot/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jekyllbot/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jekyllbot/subscriptions",
"organizations_url": "https://api.github.com/users/jekyllbot/orgs",
"repos_url": "https://api.github.com/users/jekyllbot/repos",
"events_url": "https://api.github.com/users/jekyllbot/events{/privacy}",
"received_events_url": "https://api.github.com/users/jekyllbot/received_events",
"type": "User",
"site_admin": false,
"name": "Jekyll Bot",
"company": null,
"blog": "https://github.com/parkr/auto-reply",
"location": null,
"email": null,
"hireable": null,
"bio": "I help make working with @jekyll fun and easy.",
"public_repos": 2,
"public_gists": 0,
"followers": 68,
"following": 0,
"created_at": "2013-12-12T02:49:00Z",
"updated_at": "2017-12-05T21:23:41Z"
}
33 changes: 33 additions & 0 deletions spec/webmock/api_get_user_without_displayname.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"login": "jekyllbot",
"id": 6166343,
"node_id": "MDQ6VXNlcjYxNjYzNDM=",
"avatar_url": "https://avatars0.githubusercontent.com/u/6166343?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jekyllbot",
"html_url": "https://github.com/jekyllbot",
"followers_url": "https://api.github.com/users/jekyllbot/followers",
"following_url": "https://api.github.com/users/jekyllbot/following{/other_user}",
"gists_url": "https://api.github.com/users/jekyllbot/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jekyllbot/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jekyllbot/subscriptions",
"organizations_url": "https://api.github.com/users/jekyllbot/orgs",
"repos_url": "https://api.github.com/users/jekyllbot/repos",
"events_url": "https://api.github.com/users/jekyllbot/events{/privacy}",
"received_events_url": "https://api.github.com/users/jekyllbot/received_events",
"type": "User",
"site_admin": false,
"name": null,
"company": null,
"blog": "https://github.com/parkr/auto-reply",
"location": null,
"email": null,
"hireable": null,
"bio": "I help make working with @jekyll fun and easy.",
"public_repos": 2,
"public_gists": 0,
"followers": 68,
"following": 0,
"created_at": "2013-12-12T02:49:00Z",
"updated_at": "2017-12-05T21:23:41Z"
}
0