Skip to content

Commit 0989784

Browse files
committed
[STORE] Changed that document_type method returns nil when no klass is set
1 parent 5160424 commit 0989784

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: elasticsearch-persistence/lib/elasticsearch/persistence/repository/naming.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def index_name=(name)
2020
end
2121

2222
def document_type
23-
klass.to_s.underscore
23+
klass ? klass.to_s.underscore : nil
2424
end
2525

2626
def __get_klass_from_type(type)

Diff for: elasticsearch-persistence/test/unit/repository_naming_test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ def self.class
8686
end
8787

8888
context "document_type" do
89-
should "default to klass" do
90-
assert_equal '', subject.document_type
89+
should "be nil when no klass is set" do
90+
assert_equal nil, subject.document_type
91+
end
9192

93+
should "default to klass" do
9294
subject.klass Foobar
9395
assert_equal 'foobar', subject.document_type
9496
end

0 commit comments

Comments
 (0)