summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:01 +0000
commitbd497e352ebd279536ae11855871162e82a3f88c (patch)
tree2241444d4be33e199d7011b872713071a8f8cd41 /spec
parent0388886f9439fa93efea29a159522aec5643f7c8 (diff)
downloadgitlab-ce-bd497e352ebd279536ae11855871162e82a3f88c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/feature/gitaly_spec.rb18
-rw-r--r--spec/lib/gitlab/metrics/dashboard/url_spec.rb42
-rw-r--r--spec/models/repository_spec.rb1
-rw-r--r--spec/requests/api/internal/base_spec.rb8
-rw-r--r--spec/support/shared_examples/metrics/url_shared_examples.rb31
-rw-r--r--spec/views/shared/projects/_list.html.haml_spec.rb78
6 files changed, 124 insertions, 54 deletions
diff --git a/spec/lib/feature/gitaly_spec.rb b/spec/lib/feature/gitaly_spec.rb
index 4e07acf9c1a..afb522d05e1 100644
--- a/spec/lib/feature/gitaly_spec.rb
+++ b/spec/lib/feature/gitaly_spec.rb
@@ -5,10 +5,6 @@ require 'spec_helper'
describe Feature::Gitaly do
let(:feature_flag) { "mep_mep" }
- before do
- stub_const("#{described_class}::SERVER_FEATURE_FLAGS", [feature_flag])
- end
-
describe ".enabled?" do
context 'when the gate is closed' do
before do
@@ -28,15 +24,13 @@ describe Feature::Gitaly do
end
describe ".server_feature_flags" do
- context 'when one flag is disabled' do
- before do
- stub_feature_flags(gitaly_mep_mep: false)
- end
+ before do
+ allow(Feature).to receive(:persisted_names).and_return(%w[gitaly_mep_mep foo])
+ end
- subject { described_class.server_feature_flags }
+ subject { described_class.server_feature_flags }
- it { is_expected.to be_a(Hash) }
- it { is_expected.to eq("gitaly-feature-mep-mep" => "false") }
- end
+ it { is_expected.to be_a(Hash) }
+ it { is_expected.to eq("gitaly-feature-mep-mep" => "true") }
end
end
diff --git a/spec/lib/gitlab/metrics/dashboard/url_spec.rb b/spec/lib/gitlab/metrics/dashboard/url_spec.rb
index daaf66cba46..d98aa5e3697 100644
--- a/spec/lib/gitlab/metrics/dashboard/url_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/url_spec.rb
@@ -3,38 +3,6 @@
require 'spec_helper'
describe Gitlab::Metrics::Dashboard::Url do
- shared_examples_for 'a regex which matches the expected url' do
- it { is_expected.to be_a Regexp }
-
- it 'matches a metrics dashboard link with named params' do
- expect(subject).to match url
-
- subject.match(url) do |m|
- expect(m.named_captures).to eq expected_params
- end
- end
- end
-
- shared_examples_for 'does not match non-matching urls' do
- it 'does not match other gitlab urls that contain the term metrics' do
- url = Gitlab::Routing.url_helpers.active_common_namespace_project_prometheus_metrics_url('foo', 'bar', :json)
-
- expect(subject).not_to match url
- end
-
- it 'does not match other gitlab urls' do
- url = Gitlab.config.gitlab.url
-
- expect(subject).not_to match url
- end
-
- it 'does not match non-gitlab urls' do
- url = 'https://www.super_awesome_site.com/'
-
- expect(subject).not_to match url
- end
- end
-
describe '#regex' do
let(:url) do
Gitlab::Routing.url_helpers.metrics_namespace_project_environment_url(
@@ -59,10 +27,9 @@ describe Gitlab::Metrics::Dashboard::Url do
}
end
- subject { described_class.regex }
+ subject { described_class.metrics_regex }
- it_behaves_like 'a regex which matches the expected url'
- it_behaves_like 'does not match non-matching urls'
+ it_behaves_like 'regex which matches url when expected'
end
describe '#grafana_regex' do
@@ -89,15 +56,14 @@ describe Gitlab::Metrics::Dashboard::Url do
subject { described_class.grafana_regex }
- it_behaves_like 'a regex which matches the expected url'
- it_behaves_like 'does not match non-matching urls'
+ it_behaves_like 'regex which matches url when expected'
end
describe '#build_dashboard_url' do
it 'builds the url for the dashboard endpoint' do
url = described_class.build_dashboard_url('foo', 'bar', 1)
- expect(url).to match described_class.regex
+ expect(url).to match described_class.metrics_regex
end
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 3d817065963..1e558131dc6 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1622,7 +1622,6 @@ describe Repository do
it 'executes the new Gitaly RPC' do
expect_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rebase)
- expect_any_instance_of(Gitlab::GitalyClient::OperationService).not_to receive(:user_rebase)
repository.rebase(user, merge_request)
end
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb
index 677ea071012..733f0446cf4 100644
--- a/spec/requests/api/internal/base_spec.rb
+++ b/spec/requests/api/internal/base_spec.rb
@@ -313,6 +313,10 @@ describe API::Internal::Base do
end
context "git pull" do
+ before do
+ allow(Feature).to receive(:persisted_names).and_return(%w[gitaly_mep_mep])
+ end
+
it "has the correct payload" do
pull(key, project)
@@ -326,7 +330,7 @@ describe API::Internal::Base do
expect(json_response["gitaly"]["repository"]["relative_path"]).to eq(project.repository.gitaly_repository.relative_path)
expect(json_response["gitaly"]["address"]).to eq(Gitlab::GitalyClient.address(project.repository_storage))
expect(json_response["gitaly"]["token"]).to eq(Gitlab::GitalyClient.token(project.repository_storage))
- expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-inforef-uploadpack-cache' => 'true', 'gitaly-feature-cache-invalidator' => 'true', 'gitaly-feature-commit-without-batch-check' => 'true', 'gitaly-feature-use-core-delta-islands' => 'true', 'gitaly-feature-use-git-protocol-v2' => 'true')
+ expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-mep-mep' => 'true')
expect(user.reload.last_activity_on).to eql(Date.today)
end
end
@@ -346,7 +350,6 @@ describe API::Internal::Base do
expect(json_response["gitaly"]["repository"]["relative_path"]).to eq(project.repository.gitaly_repository.relative_path)
expect(json_response["gitaly"]["address"]).to eq(Gitlab::GitalyClient.address(project.repository_storage))
expect(json_response["gitaly"]["token"]).to eq(Gitlab::GitalyClient.token(project.repository_storage))
- expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-inforef-uploadpack-cache' => 'true', 'gitaly-feature-cache-invalidator' => 'true', 'gitaly-feature-commit-without-batch-check' => 'true', 'gitaly-feature-use-core-delta-islands' => 'true', 'gitaly-feature-use-git-protocol-v2' => 'true')
expect(user.reload.last_activity_on).to be_nil
end
end
@@ -594,7 +597,6 @@ describe API::Internal::Base do
expect(json_response["gitaly"]["repository"]["relative_path"]).to eq(project.repository.gitaly_repository.relative_path)
expect(json_response["gitaly"]["address"]).to eq(Gitlab::GitalyClient.address(project.repository_storage))
expect(json_response["gitaly"]["token"]).to eq(Gitlab::GitalyClient.token(project.repository_storage))
- expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-inforef-uploadpack-cache' => 'true', 'gitaly-feature-cache-invalidator' => 'true', 'gitaly-feature-commit-without-batch-check' => 'true', 'gitaly-feature-use-core-delta-islands' => 'true', 'gitaly-feature-use-git-protocol-v2' => 'true')
end
end
diff --git a/spec/support/shared_examples/metrics/url_shared_examples.rb b/spec/support/shared_examples/metrics/url_shared_examples.rb
new file mode 100644
index 00000000000..67742aecb87
--- /dev/null
+++ b/spec/support/shared_examples/metrics/url_shared_examples.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'regex which matches url when expected' do
+ it { is_expected.to be_a Regexp }
+
+ it 'matches a metrics dashboard link with named params' do
+ expect(subject).to match url
+
+ subject.match(url) do |m|
+ expect(m.named_captures).to eq expected_params
+ end
+ end
+
+ it 'does not match other gitlab urls that contain the term metrics' do
+ url = Gitlab::Routing.url_helpers.active_common_namespace_project_prometheus_metrics_url('foo', 'bar', :json)
+
+ expect(subject).not_to match url
+ end
+
+ it 'does not match other gitlab urls' do
+ url = Gitlab.config.gitlab.url
+
+ expect(subject).not_to match url
+ end
+
+ it 'does not match non-gitlab urls' do
+ url = 'https://www.super_awesome_site.com/'
+
+ expect(subject).not_to match url
+ end
+end
diff --git a/spec/views/shared/projects/_list.html.haml_spec.rb b/spec/views/shared/projects/_list.html.haml_spec.rb
new file mode 100644
index 00000000000..d6043921fc8
--- /dev/null
+++ b/spec/views/shared/projects/_list.html.haml_spec.rb
@@ -0,0 +1,78 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'shared/projects/_list' do
+ let(:group) { create(:group) }
+
+ before do
+ allow(view).to receive(:projects).and_return(projects)
+ allow(view).to receive(:project_list_cache_key).and_return('fake_cache_key')
+ end
+
+ context 'with projects' do
+ let(:projects) { build_stubbed_list(:project, 1) }
+
+ it 'renders the list of projects' do
+ render
+
+ projects.each do |project|
+ expect(rendered).to have_content(project.name)
+ end
+ end
+ end
+
+ context 'without projects' do
+ let(:projects) { [] }
+
+ context 'when @contributed_projects is set' do
+ context 'and is empty' do
+ before do
+ @contributed_projects = []
+ end
+
+ it 'renders a no-content message' do
+ render
+
+ expect(rendered).to have_content(s_('UserProfile|This user hasn\'t contributed to any projects'))
+ end
+ end
+ end
+
+ context 'when @starred_projects is set' do
+ context 'and is empty' do
+ before do
+ @starred_projects = []
+ end
+
+ it 'renders a no-content message' do
+ render
+
+ expect(rendered).to have_content(s_('UserProfile|This user hasn\'t starred any projects'))
+ end
+ end
+ end
+
+ context 'and without a special instance variable' do
+ context 'for an explore_page' do
+ before do
+ allow(view).to receive(:explore_page).and_return(true)
+ end
+
+ it 'renders a no-content message' do
+ render
+
+ expect(rendered).to have_content(s_('UserProfile|Explore public groups to find projects to contribute to.'))
+ end
+ end
+
+ context 'for a non-explore page' do
+ it 'renders a no-content message' do
+ render
+
+ expect(rendered).to have_content(s_('UserProfile|This user doesn\'t have any personal projects'))
+ end
+ end
+ end
+ end
+end