diff options
Diffstat (limited to 'spec/experiments')
-rw-r--r-- | spec/experiments/application_experiment_spec.rb | 29 | ||||
-rw-r--r-- | spec/experiments/new_project_readme_content_experiment_spec.rb | 4 |
2 files changed, 32 insertions, 1 deletions
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb index 9c03910cf66..4966e508f7e 100644 --- a/spec/experiments/application_experiment_spec.rb +++ b/spec/experiments/application_experiment_spec.rb @@ -209,6 +209,35 @@ RSpec.describe ApplicationExperiment, :experiment do end end + describe "#process_redirect_url" do + using RSpec::Parameterized::TableSyntax + + where(:url, :processed_url) do + 'https://about.gitlab.com/' | 'https://about.gitlab.com/' + 'https://gitlab.com/' | 'https://gitlab.com/' + 'http://docs.gitlab.com' | 'http://docs.gitlab.com' + 'https://docs.gitlab.com/some/path?foo=bar' | 'https://docs.gitlab.com/some/path?foo=bar' + 'http://badgitlab.com' | nil + 'https://gitlab.com.nefarious.net' | nil + 'https://unknown.gitlab.com' | nil + "https://badplace.com\nhttps://gitlab.com" | nil + 'https://gitlabbcom' | nil + 'https://gitlabbcom/' | nil + end + + with_them do + it "returns the url or nil if invalid" do + allow(Gitlab).to receive(:dev_env_or_com?).and_return(true) + expect(subject.process_redirect_url(url)).to eq(processed_url) + end + + it "considers all urls invalid when not on dev or com" do + allow(Gitlab).to receive(:dev_env_or_com?).and_return(false) + expect(subject.process_redirect_url(url)).to be_nil + end + end + end + context "when resolving variants" do it "uses the default value as specified in the yaml" do expect(Feature).to receive(:enabled?).with('namespaced_stub', subject, type: :experiment, default_enabled: :yaml) diff --git a/spec/experiments/new_project_readme_content_experiment_spec.rb b/spec/experiments/new_project_readme_content_experiment_spec.rb index 92a883078df..f76b8a1ded1 100644 --- a/spec/experiments/new_project_readme_content_experiment_spec.rb +++ b/spec/experiments/new_project_readme_content_experiment_spec.rb @@ -30,7 +30,9 @@ RSpec.describe NewProjectReadmeContentExperiment, :experiment do end it "renders redirect URLs" do - expect(markdown).to include(Rails.application.routes.url_helpers.experiment_redirect_url(subject, initial_url)) + expect(markdown).to include( + Rails.application.routes.url_helpers.experiment_redirect_url(subject, url: initial_url) + ) end end end |