Commit 3b74e409 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'jejacks0n/experiment/new_project_readme_content_tracking' into 'master'

Add link instrumentation in readme markdown templates

See merge request gitlab-org/gitlab!64564
parents 60368b84 1f075bff
......@@ -2,6 +2,7 @@
class NewProjectReadmeContentExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
TEMPLATE_PATH = Rails.root.join('app', 'experiments', 'templates', 'new_project_readme_content')
include Rails.application.routes.url_helpers
def run_with(project, variant: nil)
@project = project
......@@ -17,6 +18,10 @@ class NewProjectReadmeContentExperiment < ApplicationExperiment # rubocop:disabl
template('readme_advanced.md')
end
def redirect(to_url)
experiment_redirect_url(self, to_url)
end
private
def template(name)
......
......@@ -11,8 +11,8 @@ Already a pro? Just edit this README.md and make it your own. Want to make it ea
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
- [ ] [Create](<%= redirect("https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file") %>) or [upload](<%= redirect("https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file") %>) files
- [ ] [Add files using the command line](<%= redirect("https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line") %>) or push an existing Git repository with the following command:
```
cd existing_repo
......@@ -23,27 +23,27 @@ git push -uf origin <%= @project.default_branch_or_main %>
## Integrate with your tools
- [ ] [Set up project integrations](https://docs.gitlab.com/ee/user/project/integrations/)
- [ ] [Set up project integrations](<%= redirect("https://docs.gitlab.com/ee/user/project/integrations/") %>)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
- [ ] [Invite team members and collaborators](<%= redirect("https://docs.gitlab.com/ee/user/project/members/") %>)
- [ ] [Create a new merge request](<%= redirect("https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html") %>)
- [ ] [Automatically close issues from merge requests](<%= redirect("https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically") %>)
- [ ] [Automatically merge when pipeline succeeds](<%= redirect("https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html") %>)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Get started with GitLab CI/CD](<%= redirect("https://docs.gitlab.com/ee/ci/quick_start/index.html") %>)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](<%= redirect("https://docs.gitlab.com/ee/user/application_security/sast/") %>)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](<%= redirect("https://www.makeareadme.com/") %>) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
......
......@@ -7,7 +7,7 @@ RSpec.describe NewProjectReadmeContentExperiment, :experiment do
let(:project) { create(:project, name: 'Experimental', description: 'An experiment project') }
it "renders the basic template" do
it "renders the basic README" do
expect(subject.run_with(project)).to eq(<<~MARKDOWN.strip)
# Experimental
......@@ -15,13 +15,22 @@ RSpec.describe NewProjectReadmeContentExperiment, :experiment do
MARKDOWN
end
it "renders the advanced template" do
expect(subject.run_with(project, variant: :advanced)).to include(<<~MARKDOWN.strip)
# Experimental
describe "the advanced variant" do
let(:markdown) { subject.run_with(project, variant: :advanced) }
let(:initial_url) { 'https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file' }
An experiment project
it "renders the project details" do
expect(markdown).to include(<<~MARKDOWN.strip)
# Experimental
## Getting started
MARKDOWN
An experiment project
## Getting started
MARKDOWN
end
it "renders redirect URLs" do
expect(markdown).to include(Rails.application.routes.url_helpers.experiment_redirect_url(subject, initial_url))
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment