From c4a159e83c960985f8ab0317014af68331f61b0f Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 29 Jul 2022 14:28:19 -0300 Subject: [PATCH 1/3] Add qualified version to the gem --- lib/meilisearch/rails/version.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/meilisearch/rails/version.rb b/lib/meilisearch/rails/version.rb index bcc94290..1742311e 100644 --- a/lib/meilisearch/rails/version.rb +++ b/lib/meilisearch/rails/version.rb @@ -3,5 +3,9 @@ module MeiliSearch module Rails VERSION = '0.7.0' + + def self.qualified_version + "Meilisearch Rails (v#{VERSION})" + end end end From 9a0b644bb7eae07c2fa169087fa543bf34bdc61e Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 29 Jul 2022 14:28:37 -0300 Subject: [PATCH 2/3] Send qualified name from this gem to Ruby's gem --- lib/meilisearch/rails/configuration.rb | 1 + spec/configuration_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/meilisearch/rails/configuration.rb b/lib/meilisearch/rails/configuration.rb index 14df2d24..19bfad65 100644 --- a/lib/meilisearch/rails/configuration.rb +++ b/lib/meilisearch/rails/configuration.rb @@ -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 diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index c81e5156..b3d9d502 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -21,7 +21,7 @@ expect(MeiliSearch::Client) .to have_received(:new) - .with('http://localhost:7700', 's3cr3tap1k3y', {}) + .with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.7.0)') end context 'without meilisearch_host' do @@ -37,7 +37,7 @@ expect(MeiliSearch::Client) .to have_received(:new) - .with('http://localhost:7700', 's3cr3tap1k3y', {}) + .with('http://localhost:7700', 's3cr3tap1k3y', { client_agents: 'Meilisearch Rails (v0.7.0)' }) end end @@ -56,7 +56,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.7.0)', timeout: 2, max_retries: 1) end end end From 2497d5a1e56f3df69f88adad5f1770daeaa9072c Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Mon, 1 Aug 2022 09:57:31 -0300 Subject: [PATCH 3/3] Stub VERSION const to freeze changes between new versions --- spec/configuration_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index b3d9d502..08fa39d4 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -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', @@ -21,7 +23,7 @@ expect(MeiliSearch::Client) .to have_received(:new) - .with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.7.0)') + .with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.0.1)') end context 'without meilisearch_host' do @@ -37,7 +39,7 @@ expect(MeiliSearch::Client) .to have_received(:new) - .with('http://localhost:7700', 's3cr3tap1k3y', { client_agents: 'Meilisearch Rails (v0.7.0)' }) + .with('http://localhost:7700', 's3cr3tap1k3y', { client_agents: 'Meilisearch Rails (v0.0.1)' }) end end @@ -56,7 +58,7 @@ expect(MeiliSearch::Client) .to have_received(:new) - .with('http://localhost:7700', 's3cr3tap1k3y', client_agents: 'Meilisearch Rails (v0.7.0)', 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