Skip to content

Commit

Permalink
Revert "Return stream object instead of name"
Browse files Browse the repository at this point in the history
This reverts commit a7e2e55.
  • Loading branch information
lukaszreszke committed Jul 25, 2024
1 parent aed52a0 commit 7d86caa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def event_in_stream?(event_id, stream)
end

def search_streams(stream)
@stream_klass.where("stream LIKE ?", "#{stream}%").order("position ASC").pluck(:stream).map { |name| Stream.new(name) }
@stream_klass.where("stream LIKE ?", "#{stream}%").pluck(:stream).uniq
end

private
Expand Down
18 changes: 9 additions & 9 deletions ruby_event_store-active_record/spec/event_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,26 @@ module ActiveRecord
specify "finds streams that match the search phrase" do
repository.append_to_stream(
[SRecord.new(event_id: e1 = SecureRandom.uuid)],
s1 = Stream.new("Dummy$#{e1}"),
Stream.new("Dummy$#{e1}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e2 = SecureRandom.uuid)],
s2 = Stream.new("Dummy$#{e2}"),
Stream.new("Dummy$#{e2}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e3 = SecureRandom.uuid)],
s3 = Stream.new("Dummy$#{e3}"),
Stream.new("Dummy$#{e3}"),
ExpectedVersion.any
)

expect(repository.search_streams("Du")).to eq([s1, s2, s3])
expect(repository.search_streams("du")).to eq([s1, s2, s3])
expect(repository.search_streams("dum")).to eq([s1, s2, s3])
expect(repository.search_streams("dumm")).to eq([s1, s2, s3])
expect(repository.search_streams("dummy")).to eq([s1, s2, s3])
expect(repository.search_streams("Dummy")).to eq([s1, s2, s3])
expect(repository.search_streams("Du")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("du")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dum")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dumm")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dummy")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("Dummy")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
end

specify "finds no streams when search phrase doesn't match anything" do
Expand Down

0 comments on commit 7d86caa

Please sign in to comment.