Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/meilisearch/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def client
configuration[:meilisearch_host] || 'http://localhost:7700',
configuration[:meilisearch_api_key],
configuration.slice(:timeout, :max_retries)
.merge(client_agents: MeiliSearch::Rails.qualified_version)
)
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/meilisearch/rails/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
module MeiliSearch
module Rails
VERSION = '0.7.0'

def self.qualified_version
"Meilisearch Rails (v#{VERSION})"
end
end
end
8 changes: 5 additions & 3 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe MeiliSearch::Rails::Configuration do
before { stub_const('MeiliSearch::Rails::VERSION', '0.0.1') }

let(:configuration) do
{
meilisearch_host: 'http://localhost:7700',
Expand All @@ -21,7 +23,7 @@

expect(MeiliSearch::Client)
.to have_received(:new)
.with('http://localhost:7700', 's3cr3tap1k3y', {})
.with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.0.1)')
end

context 'without meilisearch_host' do
Expand All @@ -37,7 +39,7 @@

expect(MeiliSearch::Client)
.to have_received(:new)
.with('http://localhost:7700', 's3cr3tap1k3y', {})
.with('http://localhost:7700', 's3cr3tap1k3y', { client_agents: 'Meilisearch Rails (v0.0.1)' })
end
end

Expand All @@ -56,7 +58,7 @@

expect(MeiliSearch::Client)
.to have_received(:new)
.with('http://localhost:7700', 's3cr3tap1k3y', timeout: 2, max_retries: 1)
.with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.0.1)', timeout: 2, max_retries: 1)
end
end
end
Expand Down