Skip to content

Commit ce8a253

Browse files
Merge #179
179: Feature/Analytics r=brunoocasali a=brunoocasali Merge after meilisearch/meilisearch-ruby#354 With both PRs, we can send a custom header with the name of this gem according to meilisearch/integration-guides#150. Co-authored-by: Bruno Casali <[email protected]>
2 parents 9790a66 + 2497d5a commit ce8a253

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lib/meilisearch/rails/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def client
1616
configuration[:meilisearch_host] || 'http://localhost:7700',
1717
configuration[:meilisearch_api_key],
1818
configuration.slice(:timeout, :max_retries)
19+
.merge(client_agents: MeiliSearch::Rails.qualified_version)
1920
)
2021
end
2122
end

lib/meilisearch/rails/version.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
module MeiliSearch
44
module Rails
55
VERSION = '0.7.0'
6+
7+
def self.qualified_version
8+
"Meilisearch Rails (v#{VERSION})"
9+
end
610
end
711
end

spec/configuration_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require 'spec_helper'
22

33
describe MeiliSearch::Rails::Configuration do
4+
before { stub_const('MeiliSearch::Rails::VERSION', '0.0.1') }
5+
46
let(:configuration) do
57
{
68
meilisearch_host: 'http://localhost:7700',
@@ -21,7 +23,7 @@
2123

2224
expect(MeiliSearch::Client)
2325
.to have_received(:new)
24-
.with('http://localhost:7700', 's3cr3tap1k3y', {})
26+
.with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.0.1)')
2527
end
2628

2729
context 'without meilisearch_host' do
@@ -37,7 +39,7 @@
3739

3840
expect(MeiliSearch::Client)
3941
.to have_received(:new)
40-
.with('http://localhost:7700', 's3cr3tap1k3y', {})
42+
.with('http://localhost:7700', 's3cr3tap1k3y', { client_agents: 'Meilisearch Rails (v0.0.1)' })
4143
end
4244
end
4345

@@ -56,7 +58,7 @@
5658

5759
expect(MeiliSearch::Client)
5860
.to have_received(:new)
59-
.with('http://localhost:7700', 's3cr3tap1k3y', timeout: 2, max_retries: 1)
61+
.with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.0.1)', timeout: 2, max_retries: 1)
6062
end
6163
end
6264
end

0 commit comments

Comments
 (0)