diff options
author | Suzanne Selhorn <sselhorn@gitlab.com> | 2022-09-23 18:45:59 +0300 |
---|---|---|
committer | Suzanne Selhorn <sselhorn@gitlab.com> | 2022-09-23 18:45:59 +0300 |
commit | 1eb30e77f647b33b18447f3752049dcd8dfb5ae9 (patch) | |
tree | 2e8595df39e1945ef452ecdb240cc9ac07c7eeed /spec | |
parent | 0424099e5bad12b60aa91c7f087217fb83988fc6 (diff) | |
parent | 9d4f6d4f179ccfb8bf60c14ffdd61e9a67584971 (diff) |
Merge branch '1130-algolia-custom-ranking' into 'main'
Add page ranking capabilities for Algolia search
Closes #1130
See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/2976
Merged-by: Suzanne Selhorn <sselhorn@gitlab.com>
Approved-by: Suzanne Selhorn <sselhorn@gitlab.com>
Approved-by: David O'Regan <doregan@gitlab.com>
Co-authored-by: Sarah German <sgerman@gitlab.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/helpers/algolia_rank_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/helpers/algolia_rank_spec.rb b/spec/lib/helpers/algolia_rank_spec.rb new file mode 100644 index 00000000..7156446d --- /dev/null +++ b/spec/lib/helpers/algolia_rank_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'nanoc' +require 'helpers/algolia_rank' + +RSpec.describe Nanoc::Helpers::AlgoliaRank do + let(:mock_class) { Class.new { extend Nanoc::Helpers::AlgoliaRank } } + let(:identifier) { "/runner/development/reviewing-gitlab-runner.html" } + + let(:mock_item) do + item = Struct.new(:identifier) + item.new(identifier) + end + + subject { mock_class.algolia_rank(mock_item) } + + describe '#algolia_rank' do + using RSpec::Parameterized::TableSyntax + + where(:url_pattern, :identifier, :weight) do + "/ee/api" | "/ee/api/openapi/openapi_interactive.html" | 50 + "/runner/development" | "/runner/development/reviewing-gitlab-runner.html" | 20 + "/ee/development" | "/ee/development/documentation/graphql_styleguide.html" | 20 + "" | "/ee/install/installation.html" | 100 + end + + with_them do + it 'returns correct weight for matched identifier' do + expect(subject).to eq(weight) + end + end + + end +end |