cony 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aff69eb110fb36a9da6b2aa0167e4de8518b150d
4
- data.tar.gz: 2773936eeb01b87e7e6022f16896e074c18ad43c
3
+ metadata.gz: 6d3842111c6f329895cec4c644a89ebe7f3b0f15
4
+ data.tar.gz: 27c16fe6e690804943672252fdf0814d972d2472
5
5
  SHA512:
6
- metadata.gz: cf5593107053e35a49e8ce965392ba8e9f0171d902f6c669adcc6e92851c5a3769f648d5bdca95f3a3e446840c3584829b7d3ef62bb9cb50e396f5b03f00f4c0
7
- data.tar.gz: f6d5e740560db5ad88e46f0b8742bda305a903a673ff91ba6ab00bed5d08820bea843d7da15774d6c781be0f7a3c112cf538b8ab942e739ebdf77d6a8e3d76ab
6
+ metadata.gz: acdbf52d571bd33aad2686708df9c3d973788cfc148adf73e753c95f75a7d9f4bc1580e8aeee854d22dc3d9a10651c244842d26c7043e1910b770577a98e3ec0
7
+ data.tar.gz: bf9f4d1ebfc8fdef33ea46c12d8089d33c194a4bc65cd06e2c8d189da632820b55f8967a4cb5f625f3177adf15d5f9fa21299b4c63fd727a7892f814500990a8
@@ -1,13 +1,32 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 2.1.1
5
- - 2.3.1
4
+ - 2.1.0
5
+ - 2.3.4
6
+ - 2.4.2
6
7
  gemfile:
7
8
  - gemfiles/activesupport-3.2.gemfile
8
9
  - gemfiles/activesupport-4.0.gemfile
9
10
  - gemfiles/activesupport-4.1.gemfile
10
11
  - gemfiles/activesupport-4.2.gemfile
12
+ - gemfiles/activesupport-5.0.gemfile
13
+ - gemfiles/activesupport-5.1.gemfile
14
+ matrix:
15
+ exclude:
16
+ - rvm: 2.0.0
17
+ gemfile: gemfiles/activesupport-5.0.gemfile
18
+ - rvm: 2.0.0
19
+ gemfile: gemfiles/activesupport-5.1.gemfile
20
+ - rvm: 2.1.0
21
+ gemfile: gemfiles/activesupport-5.0.gemfile
22
+ - rvm: 2.1.0
23
+ gemfile: gemfiles/activesupport-5.1.gemfile
24
+ - rvm: 2.4.2
25
+ gemfile: gemfiles/activesupport-3.2.gemfile
26
+ - rvm: 2.4.2
27
+ gemfile: gemfiles/activesupport-4.0.gemfile
28
+ - rvm: 2.4.2
29
+ gemfile: gemfiles/activesupport-4.1.gemfile
11
30
  before_install:
12
31
  - gem install bundler
13
32
  notifications:
@@ -1,25 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cony (2.2.2)
5
- activesupport (>= 3)
4
+ cony (2.2.3)
5
+ activesupport (>= 5.1)
6
6
  bunny (~> 2.6)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (5.0.0.1)
11
+ activemodel (5.1.4)
12
+ activesupport (= 5.1.4)
13
+ activerecord (5.1.4)
14
+ activemodel (= 5.1.4)
15
+ activesupport (= 5.1.4)
16
+ arel (~> 8.0)
17
+ activesupport (5.1.4)
12
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
19
  i18n (~> 0.7)
14
20
  minitest (~> 5.1)
15
21
  tzinfo (~> 1.1)
16
- amq-protocol (2.0.1)
17
- bunny (2.6.1)
18
- amq-protocol (>= 2.0.1)
19
- concurrent-ruby (1.0.2)
22
+ amq-protocol (2.2.0)
23
+ arel (8.0.0)
24
+ bunny (2.7.1)
25
+ amq-protocol (>= 2.2.0)
26
+ concurrent-ruby (1.0.5)
20
27
  diff-lcs (1.2.5)
21
- i18n (0.7.0)
22
- minitest (5.10.1)
28
+ i18n (0.9.0)
29
+ concurrent-ruby (~> 1.0)
30
+ minitest (5.10.3)
23
31
  rake (11.3.0)
24
32
  rspec (3.5.0)
25
33
  rspec-core (~> 3.5.0)
@@ -34,17 +42,20 @@ GEM
34
42
  diff-lcs (>= 1.2.0, < 2.0)
35
43
  rspec-support (~> 3.5.0)
36
44
  rspec-support (3.5.0)
37
- thread_safe (0.3.5)
38
- tzinfo (1.2.2)
45
+ sqlite3 (1.3.13)
46
+ thread_safe (0.3.6)
47
+ tzinfo (1.2.3)
39
48
  thread_safe (~> 0.1)
40
49
 
41
50
  PLATFORMS
42
51
  ruby
43
52
 
44
53
  DEPENDENCIES
54
+ activerecord (>= 5.1)
45
55
  cony!
46
56
  rake (~> 11.0)
47
57
  rspec (~> 3.0)
58
+ sqlite3
48
59
 
49
60
  BUNDLED WITH
50
61
  1.12.5
data/README.md CHANGED
@@ -5,9 +5,9 @@ Cony sends notifications about the lifecycle of your models via AMQP.
5
5
 
6
6
  ## Setup
7
7
 
8
- ### Rails 3 & 4
8
+ ### Rails 3, 4 & 5
9
9
 
10
- In Rails 3 and 4, add this to your Gemfile and run the bundle command.
10
+ In Rails 3, 4 and 5.0, add this to your Gemfile and run the bundle command.
11
11
 
12
12
  ```ruby
13
13
  gem 'cony'
@@ -108,8 +108,6 @@ The sent JSON structure will look like this:
108
108
 
109
109
  ## About
110
110
 
111
- This gem is currently maintained and funded by [nine.ch](https://nine.ch).
111
+ This gem is currently maintained and funded by [nine](https://nine.ch).
112
112
 
113
- [![nine.ch](https://blog.nine.ch/assets/logo.png)](https://nine.ch)
114
-
115
- We run your Linux server infrastructure – without interruptions, around the clock.
113
+ [![logo of the company 'nine'](https://logo.apps.at-nine.ch/Dmqied_eSaoBMQwk3vVgn4UIgDo=/trim/500x0/logo_claim.png)](https://www.nine.ch)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.4
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_development_dependency 'rake', '~> 11.0'
23
23
  s.add_development_dependency 'rspec', '~> 3.0'
24
+ s.add_development_dependency 'activerecord', '>= 3'
25
+ s.add_development_dependency 'sqlite3'
24
26
 
25
27
  s.add_runtime_dependency 'activesupport', '>= 3'
26
28
  s.add_runtime_dependency 'bunny', '~> 2.6'
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activesupport', '~> 5.0.0'
4
+
5
+ gemspec path: '../'
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activesupport', '~> 5.1.0'
4
+ gem 'activerecord', '~> 5.1.0'
5
+
6
+ gemspec path: '../'
@@ -48,8 +48,13 @@ module Cony
48
48
  @cony_amqp_connection ||= Cony::AMQPConnectionHandler.new(Cony.config.amqp)
49
49
  end
50
50
 
51
+ def cony_changes
52
+ return saved_changes if respond_to? :saved_changes
53
+ changes
54
+ end
55
+
51
56
  def cony_mapped_changes
52
- changes.map do |name, change|
57
+ cony_changes.map do |name, change|
53
58
  { name => { old: change.first, new: change.last } }
54
59
  end
55
60
  end
@@ -26,7 +26,7 @@ describe Cony::ActiveRecord do
26
26
  def self.after_commit(callback); end
27
27
  def self.name; "Anonymaus::Klass"; end
28
28
  def id; #{id}; end
29
- def changes; #{active_record_changes}; end
29
+ def saved_changes; #{active_record_changes}; end
30
30
  def attributes; #{active_record_attributes}; end
31
31
 
32
32
  include Cony::ActiveRecord
@@ -0,0 +1,203 @@
1
+ require 'spec_helper'
2
+
3
+ require "active_record"
4
+ require 'cony/active_record'
5
+
6
+ class MyModel < ActiveRecord::Base
7
+ include Cony::ActiveRecord
8
+ end
9
+
10
+ describe 'Integration' do
11
+ describe Cony::ActiveRecord do
12
+ before do
13
+ ActiveRecord::Base.establish_connection(
14
+ adapter: "sqlite3",
15
+ database: ":memory:"
16
+ )
17
+
18
+ ActiveRecord::Schema.verbose = false
19
+ ActiveRecord::Schema.define do
20
+ create_table :my_models do |table|
21
+ table.column :title, :string
22
+ table.column :num, :integer
23
+ end
24
+ end
25
+
26
+ allow(Cony::AMQPConnectionHandler).to receive(:new).and_return(amqp_connection)
27
+ allow(amqp_connection).to receive(:publish)
28
+ end
29
+
30
+ let(:amqp_connection) { double('Cony::AMQPConnectionHandler') }
31
+
32
+ let(:title) { 'Sansibar' }
33
+ let(:num) { 21 }
34
+
35
+ subject { MyModel.new title: title, num: num }
36
+
37
+ describe 'Create new MyModel' do
38
+ let(:event) { :created }
39
+
40
+ it 'sends a message' do
41
+ expect(amqp_connection).to receive(:publish)
42
+ subject.save
43
+ end
44
+
45
+ it 'sets the routing_key' do
46
+ expect(amqp_connection).to receive(:publish) do |payload, key|
47
+ expect(key).to eq("my_model.mutation.#{event}")
48
+ end
49
+
50
+ subject.save
51
+ end
52
+
53
+ it 'sets the correct id' do
54
+ expect(amqp_connection).to receive(:publish) do |payload, key|
55
+ expect(payload[:id]).to eq(subject.id)
56
+ end
57
+
58
+ subject.save
59
+ end
60
+
61
+ it 'sets the correct model' do
62
+ expect(amqp_connection).to receive(:publish) do |payload, key|
63
+ expect(payload[:model]).to eq(subject.class.name)
64
+ end
65
+
66
+ subject.save
67
+ end
68
+
69
+ it 'sets the correct event type' do
70
+ expect(amqp_connection).to receive(:publish) do |payload, key|
71
+ expect(payload[:event]).to eq(event)
72
+ end
73
+
74
+ subject.save
75
+ end
76
+
77
+ it 'contains the changes' do
78
+ expect(amqp_connection).to receive(:publish) do |payload, key|
79
+ expect(payload[:changes]).to match_array([
80
+ {"id"=>{old: nil, new: subject.id}},
81
+ {"title"=>{old: nil, new: title}},
82
+ {"num"=>{old: nil, new: num}}
83
+ ])
84
+ end
85
+
86
+ subject.save
87
+ end
88
+ end
89
+
90
+ describe 'Update a MyModel' do
91
+ before { subject.save }
92
+
93
+ let(:event) { :updated }
94
+ let(:new_title) { 'Tristan da Cunha' }
95
+
96
+ it 'sends a message' do
97
+ expect(amqp_connection).to receive(:publish)
98
+ subject.title = new_title
99
+ subject.save
100
+ end
101
+
102
+ it 'sets the routing_key' do
103
+ expect(amqp_connection).to receive(:publish) do |payload, key|
104
+ expect(key).to eq("my_model.mutation.#{event}")
105
+ end
106
+
107
+ subject.title = new_title
108
+ subject.save
109
+ end
110
+
111
+ it 'sets the correct id' do
112
+ expect(amqp_connection).to receive(:publish) do |payload, key|
113
+ expect(payload[:id]).to eq(subject.id)
114
+ end
115
+
116
+ subject.title = new_title
117
+ subject.save
118
+ end
119
+
120
+ it 'sets the correct model' do
121
+ expect(amqp_connection).to receive(:publish) do |payload, key|
122
+ expect(payload[:model]).to eq(subject.class.name)
123
+ end
124
+
125
+ subject.title = new_title
126
+ subject.save
127
+ end
128
+
129
+ it 'sets the correct event type' do
130
+ expect(amqp_connection).to receive(:publish) do |payload, key|
131
+ expect(payload[:event]).to eq(event)
132
+ end
133
+
134
+ subject.title = new_title
135
+ subject.save
136
+ end
137
+
138
+ it 'contains the changes' do
139
+ expect(amqp_connection).to receive(:publish) do |payload, key|
140
+ expect(payload[:changes]).to match_array([{"title"=>{old: title, new: new_title}}])
141
+ end
142
+
143
+ subject.title = new_title
144
+ subject.save
145
+ end
146
+ end
147
+
148
+ describe 'Delete a MyModel' do
149
+ before { subject.save }
150
+
151
+ let(:event) { :destroyed }
152
+
153
+ it 'sends a message' do
154
+ expect(amqp_connection).to receive(:publish)
155
+ subject.destroy
156
+ end
157
+
158
+ it 'sets the routing_key' do
159
+ expect(amqp_connection).to receive(:publish) do |payload, key|
160
+ expect(key).to eq("my_model.mutation.#{event}")
161
+ end
162
+
163
+ subject.destroy
164
+ end
165
+
166
+ it 'sets the correct id' do
167
+ expect(amqp_connection).to receive(:publish) do |payload, key|
168
+ expect(payload[:id]).to eq(subject.id)
169
+ end
170
+
171
+ subject.destroy
172
+ end
173
+
174
+ it 'sets the correct model' do
175
+ expect(amqp_connection).to receive(:publish) do |payload, key|
176
+ expect(payload[:model]).to eq(subject.class.name)
177
+ end
178
+
179
+ subject.destroy
180
+ end
181
+
182
+ it 'sets the correct event type' do
183
+ expect(amqp_connection).to receive(:publish) do |payload, key|
184
+ expect(payload[:event]).to eq(event)
185
+ end
186
+
187
+ subject.destroy
188
+ end
189
+
190
+ it 'contains the changes' do
191
+ expect(amqp_connection).to receive(:publish) do |payload, key|
192
+ expect(payload[:changes]).to match_array([
193
+ {"id"=>{old: subject.id, new: nil}},
194
+ {"title"=>{old: title, new: nil}},
195
+ {"num"=>{old: num, new: nil}}
196
+ ])
197
+ end
198
+
199
+ subject.destroy
200
+ end
201
+ end
202
+ end
203
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nine.ch Development-Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: activesupport
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -91,11 +119,14 @@ files:
91
119
  - gemfiles/activesupport-4.0.gemfile
92
120
  - gemfiles/activesupport-4.1.gemfile
93
121
  - gemfiles/activesupport-4.2.gemfile
122
+ - gemfiles/activesupport-5.0.gemfile
123
+ - gemfiles/activesupport-5.1.gemfile
94
124
  - lib/cony.rb
95
125
  - lib/cony/active_record.rb
96
126
  - lib/cony/amqp_connection_handler.rb
97
127
  - spec/cony/active_record_spec.rb
98
128
  - spec/cony/amqp_connection_handler_spec.rb
129
+ - spec/integration/active_record_spec.rb
99
130
  - spec/spec_helper.rb
100
131
  homepage: http://github.com/ninech/
101
132
  licenses:
@@ -117,11 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
148
  version: '0'
118
149
  requirements: []
119
150
  rubyforge_project:
120
- rubygems_version: 2.5.2
151
+ rubygems_version: 2.5.1
121
152
  signing_key:
122
153
  specification_version: 4
123
154
  summary: Automatically sends notifications via AMQP when a model has been changed.
124
- test_files:
125
- - spec/cony/active_record_spec.rb
126
- - spec/cony/amqp_connection_handler_spec.rb
127
- - spec/spec_helper.rb
155
+ test_files: []