From ad47b41e893049c7eee2b5d9ab15515ef70d86aa Mon Sep 17 00:00:00 2001 From: Dave Sullivan Date: Wed, 19 May 2021 13:31:58 -0400 Subject: [PATCH 1/4] bumped elasticsearch to 7.x and removed references to ES types which are no longer supported in 7.x+ --- lib/rom/elasticsearch/dataset.rb | 2 +- lib/rom/elasticsearch/gateway.rb | 2 +- lib/rom/elasticsearch/index_name.rb | 16 +++------------- lib/rom/elasticsearch/relation.rb | 5 ++--- lib/rom/elasticsearch/relation/loaded.rb | 2 +- rom-elasticsearch.gemspec | 2 +- spec/unit/rom/elasticsearch/dataset/body_spec.rb | 2 +- .../rom/elasticsearch/dataset/delete_spec.rb | 2 +- .../rom/elasticsearch/dataset/params_spec.rb | 4 ++-- spec/unit/rom/elasticsearch/dataset/put_spec.rb | 2 +- .../elasticsearch/dataset/query_string_spec.rb | 2 +- .../rom/elasticsearch/dataset/scroll_spec.rb | 4 ++-- .../rom/elasticsearch/dataset/search_spec.rb | 2 +- .../rom/elasticsearch/relation/dataset_spec.rb | 4 ---- 14 files changed, 18 insertions(+), 33 deletions(-) diff --git a/lib/rom/elasticsearch/dataset.rb b/lib/rom/elasticsearch/dataset.rb index c0facd7..d7d02ff 100644 --- a/lib/rom/elasticsearch/dataset.rb +++ b/lib/rom/elasticsearch/dataset.rb @@ -96,7 +96,7 @@ def settings # # @api public def mappings - client.indices.get_mapping[index.to_s]['mappings'][type.to_s] + client.indices.get_mapping[index.to_s]['mappings'] end # Delete everything matching configured params and/or body diff --git a/lib/rom/elasticsearch/gateway.rb b/lib/rom/elasticsearch/gateway.rb index 7412de7..9fc0a5d 100644 --- a/lib/rom/elasticsearch/gateway.rb +++ b/lib/rom/elasticsearch/gateway.rb @@ -81,7 +81,7 @@ def dataset?(index) # @api public def dataset(index) idx_name = IndexName[index] - Dataset.new(client, params: { index: idx_name.to_sym, type: idx_name.type }) + Dataset.new(client, params: { index: idx_name.to_sym }) end alias_method :[], :dataset end diff --git a/lib/rom/elasticsearch/index_name.rb b/lib/rom/elasticsearch/index_name.rb index 1be1336..980f6a3 100644 --- a/lib/rom/elasticsearch/index_name.rb +++ b/lib/rom/elasticsearch/index_name.rb @@ -9,34 +9,24 @@ class IndexName # @api private attr_reader :name - # @api private - attr_reader :types - - def self.[](name, types = nil) + def self.[](name) if name.is_a?(self) name else - new(name, types) + new(name) end end # @api private - def initialize(name, types = nil) + def initialize(name) @name = name - @types = types freeze end - # @api private - def type - types ? Array(types).join(',') : Inflector.singularize(name).to_sym - end - # @api private def to_sym name end end - end end diff --git a/lib/rom/elasticsearch/relation.rb b/lib/rom/elasticsearch/relation.rb index 8841c76..67f083d 100644 --- a/lib/rom/elasticsearch/relation.rb +++ b/lib/rom/elasticsearch/relation.rb @@ -148,7 +148,7 @@ class Relation < ROM::Relation # @return [self] def self.schema(dataset = nil, multi: false, **opts, &block) if multi - super(IndexName[:_all, multi_index_types], **opts, &block) + super(IndexName[:_all], **opts, &block) else super(dataset, **opts, &block) end @@ -339,7 +339,6 @@ def refresh def count dataset.client.count( index: dataset.index, - type: dataset.type, body: dataset.body )['count'] end @@ -381,7 +380,7 @@ def index_params { index: name.dataset.to_sym, body: { settings: self.class.index_settings, - mappings: { dataset.type => { properties: schema.to_properties } } } } + mappings: { properties: schema.to_properties } } } end end end diff --git a/lib/rom/elasticsearch/relation/loaded.rb b/lib/rom/elasticsearch/relation/loaded.rb index e7536e2..9c64f1a 100644 --- a/lib/rom/elasticsearch/relation/loaded.rb +++ b/lib/rom/elasticsearch/relation/loaded.rb @@ -13,7 +13,7 @@ class Loaded < ROM::Relation::Loaded # # @api public def total_hits - response['hits']['total'] + response['hits']['total']['value'] end # Return raw response from the ES client diff --git a/rom-elasticsearch.gemspec b/rom-elasticsearch.gemspec index fd12a2d..be4681d 100644 --- a/rom-elasticsearch.gemspec +++ b/rom-elasticsearch.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_runtime_dependency 'rom-core', '~> 5.2', '>= 5.2.5' - spec.add_runtime_dependency 'elasticsearch', '~> 6.0' + spec.add_runtime_dependency 'elasticsearch', '~> 7.0' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' diff --git a/spec/unit/rom/elasticsearch/dataset/body_spec.rb b/spec/unit/rom/elasticsearch/dataset/body_spec.rb index d22904e..dc75c5d 100644 --- a/spec/unit/rom/elasticsearch/dataset/body_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/body_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#body' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'user fixtures' diff --git a/spec/unit/rom/elasticsearch/dataset/delete_spec.rb b/spec/unit/rom/elasticsearch/dataset/delete_spec.rb index 6663595..953b050 100644 --- a/spec/unit/rom/elasticsearch/dataset/delete_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/delete_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#delete' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'user fixtures' diff --git a/spec/unit/rom/elasticsearch/dataset/params_spec.rb b/spec/unit/rom/elasticsearch/dataset/params_spec.rb index f941c20..6e6018c 100644 --- a/spec/unit/rom/elasticsearch/dataset/params_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/params_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#params' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'user fixtures' @@ -8,6 +8,6 @@ it 'returns a new dataset with updated params' do new_ds = dataset.params(size: 100) - expect(new_ds.params).to eql(size: 100, index: :users, type: :user) + expect(new_ds.params).to eql(size: 100, index: :users) end end diff --git a/spec/unit/rom/elasticsearch/dataset/put_spec.rb b/spec/unit/rom/elasticsearch/dataset/put_spec.rb index 601e4f7..3598d4a 100644 --- a/spec/unit/rom/elasticsearch/dataset/put_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/put_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#put' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'setup' diff --git a/spec/unit/rom/elasticsearch/dataset/query_string_spec.rb b/spec/unit/rom/elasticsearch/dataset/query_string_spec.rb index 1c1b719..0f47990 100644 --- a/spec/unit/rom/elasticsearch/dataset/query_string_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/query_string_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#query_string' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'user fixtures' diff --git a/spec/unit/rom/elasticsearch/dataset/scroll_spec.rb b/spec/unit/rom/elasticsearch/dataset/scroll_spec.rb index 268aec1..c8e8648 100644 --- a/spec/unit/rom/elasticsearch/dataset/scroll_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/scroll_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#scroll' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'user fixtures' @@ -8,6 +8,6 @@ it 'returns a new dataset with updated params' do new_ds = dataset.scroll('5m') - expect(new_ds.params).to eql(scroll: '5m', index: :users, type: :user) + expect(new_ds.params).to eql(scroll: '5m', index: :users) end end diff --git a/spec/unit/rom/elasticsearch/dataset/search_spec.rb b/spec/unit/rom/elasticsearch/dataset/search_spec.rb index 4f5e00f..c4687ae 100644 --- a/spec/unit/rom/elasticsearch/dataset/search_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/search_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ROM::Elasticsearch::Dataset, '#search' do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user }) + ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) end include_context 'setup' diff --git a/spec/unit/rom/elasticsearch/relation/dataset_spec.rb b/spec/unit/rom/elasticsearch/relation/dataset_spec.rb index 6b973e9..6509596 100644 --- a/spec/unit/rom/elasticsearch/relation/dataset_spec.rb +++ b/spec/unit/rom/elasticsearch/relation/dataset_spec.rb @@ -18,10 +18,6 @@ it 'sets up correct index name' do expect(relation.dataset.index).to eql(:users) end - - it 'sets up default index type' do - expect(relation.dataset.type).to eql(:user) - end end context 'overridding default dataset object' do From 8a50633502ced8947c4845b83a2bf69f0b22f8df Mon Sep 17 00:00:00 2001 From: Dave Sullivan Date: Tue, 10 Aug 2021 13:55:26 -0400 Subject: [PATCH 2/4] Added support for nested and object fields, which are configured in the schema using blocks passed to the `attribute` method. --- lib/rom/elasticsearch/constants.rb | 7 +++ lib/rom/elasticsearch/relation.rb | 2 + lib/rom/elasticsearch/schema/dsl.rb | 47 ++++++++++++++ lib/rom/elasticsearch/types.rb | 19 ++++++ spec/shared/unit/users.rb | 4 +- .../relation/create_index_spec.rb | 61 +++++++++++++++++++ 6 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 lib/rom/elasticsearch/constants.rb create mode 100644 lib/rom/elasticsearch/schema/dsl.rb diff --git a/lib/rom/elasticsearch/constants.rb b/lib/rom/elasticsearch/constants.rb new file mode 100644 index 0000000..6583e7f --- /dev/null +++ b/lib/rom/elasticsearch/constants.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module ROM + module Elasticsearch + InvalidAttributeError = Class.new(StandardError) + end +end \ No newline at end of file diff --git a/lib/rom/elasticsearch/relation.rb b/lib/rom/elasticsearch/relation.rb index 4aaedf6..2438d1e 100644 --- a/lib/rom/elasticsearch/relation.rb +++ b/lib/rom/elasticsearch/relation.rb @@ -6,6 +6,7 @@ require "rom/elasticsearch/relation/loaded" require "rom/elasticsearch/types" require "rom/elasticsearch/schema" +require "rom/elasticsearch/schema/dsl" require "rom/elasticsearch/attribute" module ROM @@ -113,6 +114,7 @@ class Relation < ROM::Relation # end defines :multi_index_types + schema_dsl Elasticsearch::Schema::DSL schema_class Elasticsearch::Schema schema_attr_class Elasticsearch::Attribute diff --git a/lib/rom/elasticsearch/schema/dsl.rb b/lib/rom/elasticsearch/schema/dsl.rb new file mode 100644 index 0000000..b2e7068 --- /dev/null +++ b/lib/rom/elasticsearch/schema/dsl.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require "rom/schema/dsl" +require "dry/types" + +module ROM + module Elasticsearch + class Schema + class DSL < ROM::Schema::DSL + + # Defines a relation attribute with its type and options. + # + # Optionally, accepts a block to define nested attributes + # for Elasticsearch indices. + # + # @see Relation.schema + # + # @api public + def attribute(name, type_or_options, options = EMPTY_HASH, &block) + if !block.nil? + if !type_or_options.is_a?(::Dry::Types::Hash) + raise ROM::Elasticsearch::InvalidAttributeError, + "You can only specify an attribute block on an object or nested field! " \ + "Attribute #{name} is a #{type_or_options.name}" + end + + nested_schema = self.class.new( + relation, + schema_class: schema_class, + attr_class: attr_class, + inferrer: inferrer, + &block + ).call + + type_or_options = type_or_options.meta(properties: nested_schema.to_properties) + end + + super( + name, + type_or_options, + options + ) + end + end + end + end +end diff --git a/lib/rom/elasticsearch/types.rb b/lib/rom/elasticsearch/types.rb index f78b0f6..19f7a35 100644 --- a/lib/rom/elasticsearch/types.rb +++ b/lib/rom/elasticsearch/types.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "rom/types" +require "rom/elasticsearch/schema" module ROM module Elasticsearch @@ -30,6 +31,24 @@ def self.Keyword(meta = {}) def self.Text(meta = {}) String.meta(type: "text", **meta) end + + # Define a nested attribute type + # + # @return [Dry::Types::Type] + # + # @api public + def self.Nested(meta = {}) + Hash.meta(type: "nested", **meta) + end + + # Define an object attribute type + # + # @return [Dry::Types::Type] + # + # @api public + def self.Object(meta = {}) + Hash.meta(properties: {}, **meta) + end end end end diff --git a/spec/shared/unit/users.rb b/spec/shared/unit/users.rb index 47d4e07..4533148 100644 --- a/spec/shared/unit/users.rb +++ b/spec/shared/unit/users.rb @@ -6,8 +6,8 @@ before do conf.relation(:users) do schema(:users) do - attribute :id, ROM::Types::Integer - attribute :name, ROM::Types::String + attribute :id, ROM::Elasticsearch::Types::ID + attribute :name, ROM::Elasticsearch::Types.Text primary_key :id end diff --git a/spec/unit/rom/elasticsearch/relation/create_index_spec.rb b/spec/unit/rom/elasticsearch/relation/create_index_spec.rb index 1aed537..8342ac8 100644 --- a/spec/unit/rom/elasticsearch/relation/create_index_spec.rb +++ b/spec/unit/rom/elasticsearch/relation/create_index_spec.rb @@ -74,5 +74,66 @@ }) end end + + context "with a nested attribute type" do + before do + conf.relation(:users) do + schema do + attribute :id, ROM::Elasticsearch::Types::ID + attribute :name, ROM::Elasticsearch::Types.Keyword + attribute :profile, ROM::Elasticsearch::Types.Nested do + attribute :email, ROM::Elasticsearch::Types.Text + end + end + end + end + + it "creates an index" do + relation.create_index + + expect(gateway.index?(:users)).to be(true) + + expect(relation.dataset.mappings) + .to eql("properties" => { + "name" => {"type" => "keyword"}, + "profile" => { + "type" => "nested", + "properties" => { + "email" => {"type" => "text"} + } + } + }) + end + end + + context "with an object attribute type" do + before do + conf.relation(:users) do + schema do + attribute :id, ROM::Elasticsearch::Types::ID + attribute :name, ROM::Elasticsearch::Types.Keyword + attribute :profile, ROM::Elasticsearch::Types.Object do + attribute :email, ROM::Elasticsearch::Types.Text + end + end + end + end + + it "creates an index" do + relation.create_index + + expect(gateway.index?(:users)).to be(true) + + expect(relation.dataset.mappings) + .to eql("properties" => { + "name" => {"type" => "keyword"}, + "profile" => { + "properties" => { + "email" => {"type" => "text"} + } + } + }) + end + end end end From 4de3b1e6636139671c2a82f47ec72479e22a7f6b Mon Sep 17 00:00:00 2001 From: Dave Sullivan Date: Tue, 10 Aug 2021 14:02:07 -0400 Subject: [PATCH 3/4] Added spec to test reading/writing of nested fields --- .../rom/elasticsearch/relation/schema_spec.rb | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/spec/integration/rom/elasticsearch/relation/schema_spec.rb b/spec/integration/rom/elasticsearch/relation/schema_spec.rb index 35de61f..9a3cac0 100644 --- a/spec/integration/rom/elasticsearch/relation/schema_spec.rb +++ b/spec/integration/rom/elasticsearch/relation/schema_spec.rb @@ -5,23 +5,56 @@ include_context "setup" - before do - conf.relation(:users) do - schema(:users) do - attribute :id, ROM::Elasticsearch::Types::ID - attribute :name, ROM::Elasticsearch::Types.Text, read: ROM::Types.Constructor(Symbol, &:to_sym) + context "read/write types" do + before do + conf.relation(:users) do + schema(:users) do + attribute :id, ROM::Elasticsearch::Types::ID + attribute :name, ROM::Elasticsearch::Types.Text, read: ROM::Types.Constructor(Symbol, &:to_sym) + end end end + + it "defines read/write types" do + relation.create_index + + relation.command(:create).call(id: 1, name: "Jane") + + user = relation.get(1).one + + expect(user[:id]).to be(1) + expect(user[:name]).to be(:Jane) + end end - it "defines read/write types" do - relation.create_index + context "nested fields" do + before do + conf.relation(:users) do + schema(:users) do + attribute :id, ROM::Elasticsearch::Types::ID + attribute :name, ROM::Elasticsearch::Types.Text + attribute :profile, ROM::Elasticsearch::Types.Nested do + attribute :email, ROM::Elasticsearch::Types.Text + end + end + end + end - relation.command(:create).call(id: 1, name: "Jane") + it "persists and reads nested types" do + relation.create_index - user = relation.get(1).one + relation.command(:create).call( + id: 1, + name: "Jane", + profile: { + email: "jane@sample.com" + } + ) - expect(user[:id]).to be(1) - expect(user[:name]).to be(:Jane) + user = relation.get(1).one + + expect(user[:id]).to be(1) + expect(user[:profile]).to eql({ "email" => "jane@sample.com" }) + end end end From 943847ae1e9bf1223399eb762d6cbdc9e3b807cd Mon Sep 17 00:00:00 2001 From: Dave Sullivan Date: Tue, 10 Aug 2021 14:28:41 -0400 Subject: [PATCH 4/4] clear out the lint --- lib/rom/elasticsearch/constants.rb | 2 +- lib/rom/elasticsearch/dataset.rb | 2 +- lib/rom/elasticsearch/gateway.rb | 2 +- lib/rom/elasticsearch/relation.rb | 9 +++++---- lib/rom/elasticsearch/relation/loaded.rb | 2 +- lib/rom/elasticsearch/schema/dsl.rb | 13 ++++++------- .../rom/elasticsearch/relation/schema_spec.rb | 4 ++-- .../rom/elasticsearch/dataset/delete_spec.rb | 2 +- .../relation/create_index_spec.rb | 18 +++++++++--------- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/rom/elasticsearch/constants.rb b/lib/rom/elasticsearch/constants.rb index 6583e7f..a40b089 100644 --- a/lib/rom/elasticsearch/constants.rb +++ b/lib/rom/elasticsearch/constants.rb @@ -4,4 +4,4 @@ module ROM module Elasticsearch InvalidAttributeError = Class.new(StandardError) end -end \ No newline at end of file +end diff --git a/lib/rom/elasticsearch/dataset.rb b/lib/rom/elasticsearch/dataset.rb index 830aa2e..770e14c 100644 --- a/lib/rom/elasticsearch/dataset.rb +++ b/lib/rom/elasticsearch/dataset.rb @@ -96,7 +96,7 @@ def settings # # @api public def mappings - client.indices.get_mapping[index.to_s]['mappings'] + client.indices.get_mapping[index.to_s]["mappings"] end # Delete everything matching configured params and/or body diff --git a/lib/rom/elasticsearch/gateway.rb b/lib/rom/elasticsearch/gateway.rb index 48ca22a..31cd5a8 100644 --- a/lib/rom/elasticsearch/gateway.rb +++ b/lib/rom/elasticsearch/gateway.rb @@ -81,7 +81,7 @@ def dataset?(index) # @api public def dataset(index) idx_name = IndexName[index] - Dataset.new(client, params: { index: idx_name.to_sym }) + Dataset.new(client, params: {index: idx_name.to_sym}) end alias_method :[], :dataset end diff --git a/lib/rom/elasticsearch/relation.rb b/lib/rom/elasticsearch/relation.rb index 2438d1e..be1c951 100644 --- a/lib/rom/elasticsearch/relation.rb +++ b/lib/rom/elasticsearch/relation.rb @@ -379,10 +379,11 @@ def size(value) # # @api private def index_params - { index: name.dataset.to_sym, - body: { - settings: self.class.index_settings, - mappings: { properties: schema.to_properties } } } + {index: name.dataset.to_sym, + body: { + settings: self.class.index_settings, + mappings: {properties: schema.to_properties} + }} end end end diff --git a/lib/rom/elasticsearch/relation/loaded.rb b/lib/rom/elasticsearch/relation/loaded.rb index 9c64f1a..e76c495 100644 --- a/lib/rom/elasticsearch/relation/loaded.rb +++ b/lib/rom/elasticsearch/relation/loaded.rb @@ -13,7 +13,7 @@ class Loaded < ROM::Relation::Loaded # # @api public def total_hits - response['hits']['total']['value'] + response["hits"]["total"]["value"] end # Return raw response from the ES client diff --git a/lib/rom/elasticsearch/schema/dsl.rb b/lib/rom/elasticsearch/schema/dsl.rb index b2e7068..b6c2270 100644 --- a/lib/rom/elasticsearch/schema/dsl.rb +++ b/lib/rom/elasticsearch/schema/dsl.rb @@ -7,7 +7,6 @@ module ROM module Elasticsearch class Schema class DSL < ROM::Schema::DSL - # Defines a relation attribute with its type and options. # # Optionally, accepts a block to define nested attributes @@ -17,11 +16,11 @@ class DSL < ROM::Schema::DSL # # @api public def attribute(name, type_or_options, options = EMPTY_HASH, &block) - if !block.nil? - if !type_or_options.is_a?(::Dry::Types::Hash) - raise ROM::Elasticsearch::InvalidAttributeError, - "You can only specify an attribute block on an object or nested field! " \ - "Attribute #{name} is a #{type_or_options.name}" + unless block.nil? + unless type_or_options.is_a?(::Dry::Types::Hash) + raise ROM::Elasticsearch::InvalidAttributeError, + "You can only specify an attribute block on an object or nested field! " \ + "Attribute #{name} is a #{type_or_options.name}" end nested_schema = self.class.new( @@ -36,7 +35,7 @@ def attribute(name, type_or_options, options = EMPTY_HASH, &block) end super( - name, + name, type_or_options, options ) diff --git a/spec/integration/rom/elasticsearch/relation/schema_spec.rb b/spec/integration/rom/elasticsearch/relation/schema_spec.rb index 9a3cac0..91fd10c 100644 --- a/spec/integration/rom/elasticsearch/relation/schema_spec.rb +++ b/spec/integration/rom/elasticsearch/relation/schema_spec.rb @@ -44,7 +44,7 @@ relation.create_index relation.command(:create).call( - id: 1, + id: 1, name: "Jane", profile: { email: "jane@sample.com" @@ -54,7 +54,7 @@ user = relation.get(1).one expect(user[:id]).to be(1) - expect(user[:profile]).to eql({ "email" => "jane@sample.com" }) + expect(user[:profile]).to eql({"email" => "jane@sample.com"}) end end end diff --git a/spec/unit/rom/elasticsearch/dataset/delete_spec.rb b/spec/unit/rom/elasticsearch/dataset/delete_spec.rb index 1baddb1..5efd8b1 100644 --- a/spec/unit/rom/elasticsearch/dataset/delete_spec.rb +++ b/spec/unit/rom/elasticsearch/dataset/delete_spec.rb @@ -2,7 +2,7 @@ RSpec.describe ROM::Elasticsearch::Dataset, "#delete" do subject(:dataset) do - ROM::Elasticsearch::Dataset.new(client, params: { index: :users }) + ROM::Elasticsearch::Dataset.new(client, params: {index: :users}) end include_context "user fixtures" diff --git a/spec/unit/rom/elasticsearch/relation/create_index_spec.rb b/spec/unit/rom/elasticsearch/relation/create_index_spec.rb index 8342ac8..582b580 100644 --- a/spec/unit/rom/elasticsearch/relation/create_index_spec.rb +++ b/spec/unit/rom/elasticsearch/relation/create_index_spec.rb @@ -121,18 +121,18 @@ it "creates an index" do relation.create_index - + expect(gateway.index?(:users)).to be(true) expect(relation.dataset.mappings) - .to eql("properties" => { - "name" => {"type" => "keyword"}, - "profile" => { - "properties" => { - "email" => {"type" => "text"} - } - } - }) + .to eql("properties" => { + "name" => {"type" => "keyword"}, + "profile" => { + "properties" => { + "email" => {"type" => "text"} + } + } + }) end end end