entity_store_sequel 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c54d5f2d683652de593397dd494b7ed9611330ce1acaa1e89c91ef2c3dfc4fb8
4
- data.tar.gz: 96ae48acc1032bab451454dd2a5c9daf4242945ba7f7b0d4c80a16b2dafa9eaf
3
+ metadata.gz: c42131de7211c31322b1b2756dffc2d4618bc4f7acdedea190613e6838b42eef
4
+ data.tar.gz: 389dcf4874fb1469e58533dbbee84839b628c91409611342e17f93177305ed96
5
5
  SHA512:
6
- metadata.gz: 67f837bbd81799168de29d1208bfbe0c81ac322814c7d6d26bd313d733ce12f7b28ce084aeefcc663bb53659fd8a97de381cf0668031d1d7c9d0aab9abb0e9b3
7
- data.tar.gz: 5edaa860647605032d7cf3db1b84e4c8bdbcf70e8f09765af038c745b379266a783be45ef6d7b66c2813d735747502538caa32c08f5e35877e5c314b1ff28024
6
+ metadata.gz: c3a3b060c3098f60d88991fb7282506a1aa54a82e3ddb967388bfcbcd0530f5c10305d2c13cc72848fc7553f8c91fc671a818db771c8512a75dbfbb5cec6e56b
7
+ data.tar.gz: 9eb6147831a2e4ff174d6b0b30ab52d5231e9642b7bb4f900cc3f0964134598bdaa2727ad446a3c46892f45fe31ab23bf8dfe237a6535188b0fc233c97b1e116
@@ -37,12 +37,19 @@ module EntityStoreSequel
37
37
 
38
38
  def init
39
39
  migration_path = File.expand_path("../../sequel/migrations", __FILE__)
40
- Sequel::Migrator.run(self.database, migration_path, :table=>:entity_store_schema_migration)
40
+ Sequel::Migrator.run(self.database, migration_path, table: :entity_store_schema_migration)
41
41
  end
42
42
  end
43
43
 
44
+ def initialize(database_connection = nil)
45
+ return unless database_connection
46
+
47
+ @database_connection = database_connection
48
+ @database_connection.extension :pg_json
49
+ end
50
+
44
51
  def open
45
- PostgresEntityStore.database
52
+ @database_connection || PostgresEntityStore.database
46
53
  end
47
54
 
48
55
  def entities
@@ -1,3 +1,3 @@
1
1
  module EntityStoreSequel
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.2.2".freeze
3
3
  end
@@ -58,6 +58,35 @@ describe "end to end" do
58
58
  end
59
59
  end
60
60
 
61
+ describe "setting connection per instance" do
62
+ before(:each) do
63
+ PostgresEntityStore.connection_string = 'FAKE_CONNECTION_STRING'
64
+
65
+ EntityStore::Config.setup do |config|
66
+ config.store = PostgresEntityStore.new(Sequel.connect('postgres://localhost/cronofy_test'))
67
+ config.event_subscribers << DummyEntitySubscriber
68
+ end
69
+
70
+ PostgresEntityStore.init
71
+ end
72
+
73
+ context "when save entity" do
74
+ let(:name) { random_string }
75
+ before(:each) do
76
+ @entity = DummyEntity.new
77
+ @entity.set_name name
78
+ @id = Store.new.save @entity
79
+ end
80
+
81
+ it "publishes event to the subscriber" do
82
+ expect(DummyEntitySubscriber.event_name).to eq(name)
83
+ end
84
+ it "is retrievable with the events applied" do
85
+ expect(EntityStore::Store.new.get(@entity.id).name).to eq(name)
86
+ end
87
+ end
88
+ end
89
+
61
90
  describe "setting connection from existing" do
62
91
  before(:each) do
63
92
  PostgresEntityStore.database = Sequel.connect('postgres://localhost/cronofy_test')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_store_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Binns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel