diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
commit | 40254b9ace2a74a3c9f1cc51a1b1d5e3e78c1ae9 (patch) | |
tree | 9b735ef933178be36d35088f3acab2d9b75dbbad /spec/lib/gitlab/application_context_spec.rb | |
parent | 22a0d312ae82e7dda3073d5d1a5a766d7641738d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/application_context_spec.rb')
-rw-r--r-- | spec/lib/gitlab/application_context_spec.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/lib/gitlab/application_context_spec.rb b/spec/lib/gitlab/application_context_spec.rb index 1c8fcb8d737..482bf0dc192 100644 --- a/spec/lib/gitlab/application_context_spec.rb +++ b/spec/lib/gitlab/application_context_spec.rb @@ -28,7 +28,7 @@ describe Gitlab::ApplicationContext do describe '.push' do it 'passes the expected context on to labkit' do fake_proc = duck_type(:call) - expected_context = hash_including(user: fake_proc, project: fake_proc, root_namespace: fake_proc) + expected_context = { user: fake_proc } expect(Labkit::Context).to receive(:push).with(expected_context) @@ -78,5 +78,27 @@ describe Gitlab::ApplicationContext do expect(result(context)) .to include(project: project.full_path, root_namespace: project.full_path_components.first) end + + context 'only include values for which an option was specified' do + using RSpec::Parameterized::TableSyntax + + where(:provided_options, :expected_context_keys) do + [:user, :namespace, :project] | [:user, :project, :root_namespace] + [:user, :project] | [:user, :project, :root_namespace] + [:user, :namespace] | [:user, :root_namespace] + [:user] | [:user] + [] | [] + end + + with_them do + it do + # Build a hash that has all `provided_options` as keys, and `nil` as value + provided_values = provided_options.map { |key| [key, nil] }.to_h + context = described_class.new(provided_values) + + expect(context.to_lazy_hash.keys).to contain_exactly(*expected_context_keys) + end + end + end end end |