Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect RailsEventStore::Browser. #497

Merged
merged 1 commit into from Nov 22, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions rails_event_store-rspec/Gemfile
Expand Up @@ -4,6 +4,7 @@ gemspec
gem 'rails_event_store', path: '../rails_event_store'
gem 'rails_event_store_active_record', path: '../rails_event_store_active_record'
gem 'ruby_event_store', path: '../ruby_event_store'
gem 'ruby_event_store-browser', path: '../ruby_event_store-browser'
gem 'aggregate_root', path: '../aggregate_root'
gem 'bounded_context', path: '../bounded_context'

Expand Down
1 change: 1 addition & 0 deletions rails_event_store/Gemfile
Expand Up @@ -2,6 +2,7 @@ source 'https://rubygems.org'
gemspec

gem 'ruby_event_store', path: '../ruby_event_store'
gem 'ruby_event_store-browser', path: '../ruby_event_store-browser'
gem 'rails_event_store_active_record', path: '../rails_event_store_active_record'
gem 'aggregate_root', path: '../aggregate_root'
gem 'bounded_context', path: '../bounded_context'
Expand Down
1 change: 1 addition & 0 deletions rails_event_store/lib/rails_event_store/all.rb
Expand Up @@ -8,6 +8,7 @@
require 'rails_event_store/client'
require 'rails_event_store/version'
require 'rails_event_store/railtie'
require 'rails_event_store/browser'

module RailsEventStore
Event = RubyEventStore::Event
Expand Down
5 changes: 5 additions & 0 deletions rails_event_store/lib/rails_event_store/browser.rb
@@ -0,0 +1,5 @@
require 'ruby_event_store/browser/app'

module RailsEventStore
Browser = RubyEventStore::Browser::App.for(event_store_locator: -> { Rails.configuration.event_store })
end
1 change: 1 addition & 0 deletions rails_event_store/rails_event_store.gemspec
Expand Up @@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'pry'

spec.add_dependency 'ruby_event_store', '= 0.33.0'
spec.add_dependency 'ruby_event_store-browser', '= 0.33.0'
spec.add_dependency 'rails_event_store_active_record', '= 0.33.0'
spec.add_dependency 'aggregate_root', '= 0.33.0'
spec.add_dependency 'bounded_context', '= 0.33.0'
Expand Down
39 changes: 39 additions & 0 deletions rails_event_store/spec/browser_integration_spec.rb
@@ -0,0 +1,39 @@
require 'spec_helper'
require 'rails_event_store/middleware'
require 'rack/test'
require 'rack/lint'
require 'support/test_application'

module RailsEventStore
RSpec.describe Browser do
specify 'root' do
request = ::Rack::MockRequest.new(app)
response = request.get('/res')

expect(response.body).to match %r{<script type="text/javascript" src="/res/ruby_event_store_browser.js"></script>}
end

specify 'api' do
event_store.publish(events = 21.times.map { DummyEvent.new })
request = ::Rack::MockRequest.new(app)
response = request.get('/res/streams/all')

expect(JSON.parse(response.body)["links"]).to eq({
"last" => "http://example.org/res/streams/all/head/forward/20",
"next" => "http://example.org/res/streams/all/#{events[1].event_id}/backward/20"
})
end

def event_store
Client.new
end

def app
TestApplication.tap do |app|
app.routes.draw { mount Browser => '/res' }
end
end
end
end


2 changes: 0 additions & 2 deletions rails_event_store/spec/middleware_integration_spec.rb
Expand Up @@ -6,8 +6,6 @@

module RailsEventStore
RSpec.describe Middleware do
DummyEvent = Class.new(RailsEventStore::Event)

specify 'works without event store instance' do
event_store = Client.new
request = ::Rack::MockRequest.new(middleware)
Expand Down
4 changes: 3 additions & 1 deletion rails_event_store/spec/spec_helper.rb
Expand Up @@ -22,4 +22,6 @@

$verbose = ENV.has_key?('VERBOSE') ? true : false
ActiveJob::Base.logger = nil unless $verbose
ActiveRecord::Schema.verbose = $verbose
ActiveRecord::Schema.verbose = $verbose

DummyEvent = Class.new(RailsEventStore::Event)
1 change: 1 addition & 0 deletions rails_event_store/spec/support/test_application.rb
Expand Up @@ -5,6 +5,7 @@
class TestApplication < Rails::Application
config.eager_load = false
config.secret_key_base = SecureRandom.hex(16)
config.event_store = RailsEventStore::Client.new
initialize!
routes.default_url_options = { host: 'example.org' }
end
Empty file removed rails_event_store/tmp/.keep
Empty file.
3 changes: 1 addition & 2 deletions ruby_event_store-browser/spec/defaults_spec.rb
Expand Up @@ -3,8 +3,7 @@
module RubyEventStore
RSpec.describe Browser do
it "takes path from request" do
events = 21.times.map { DummyEvent.new }
event_store.publish(events)
event_store.publish(events = 21.times.map { DummyEvent.new })
test_client.get('/res/streams/all')

expect(test_client.parsed_body["links"]).to eq({
Expand Down