devise-vero 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: d28d275a1f7ccfb1c2e28a71d76ef26b3be90856
4
- data.tar.gz: 4787b8c509eee0cf7d81049593085a953e692792
3
+ metadata.gz: 7b12f5fdf1200df0ffb3af6a77487e47fd17ef76
4
+ data.tar.gz: 50f64f75c77c9ab7a0471f22857da1d1c77c26ad
5
5
  SHA512:
6
- metadata.gz: 6500af0f868ba1eac81eb4dd27094b1bde33ce35c780d93b99c912b0ffb7929f3d27a31c9c31c5b72c8e1622c462984302570720224d683faafe914ff5e77dfb
7
- data.tar.gz: 749d244440057bdf0fd6859799299b27a7d7956f94dacfcb17bef787d3927ee36f777cb221a884b6f14308eac92e5ab405316e0aa23e03f5b6feda29514d4f5a
6
+ metadata.gz: 9f39fedfdc4233fc51995a9ac9ac20008a9bfe1e1bcce2911fe5520d7c3c52526750c58cc2d7f81392833c970aa2d3b0645b677f5ca870f148cfb9982ec5f141
7
+ data.tar.gz: 908549be3d58e8db7cdfe7bd988a2b71035ed0472ecb55d8232d524583f8cc385d9bf5561f3e8ceda160f7d3ea92155c4de8c7d77d790a11c19834401e9f8058
data/.travis.yml CHANGED
@@ -1,16 +1,26 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1
7
- - 2.2
8
- - ruby-head
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - 2.2
8
+ - ruby-head
9
9
  git:
10
10
  depth: 1
11
11
  script:
12
- - bundle exec rspec
13
- - bundle exec rubocop
12
+ - bundle exec rspec
13
+ - bundle exec rubocop
14
14
  addons:
15
15
  code_climate:
16
- repo_token: 51a6e0e84ef782cfb3ebebcdab36d9caeec07af803477d948f9c23efbf058c43
16
+ repo_token:
17
+ secure: "SLy9NKyJIytObIBzNckKlihcyrQR1XuV32l0m2aSsMFXIAHJsjoRrsR/Q0UUlG6oEZG3fgTax5Zj1SQRigYvz1pGQltRVMyOD7GONpFyGDBZ7OYNgG97JzExnt8Il6IMADNHXhp3q/iY+3GU18rHKI6aUa9A1Ut5NjxhSczSprU="
18
+ deploy:
19
+ provider: rubygems
20
+ api_key:
21
+ secure: UgZ3RapfHOWwLrtc4kdsHGhQ0bXDluxVDcdRU9qjSSrqEaWLPV0PtBUyMuDipmSGiVGcO68l0hEfSdSistXxNqXLN2daG7kRN7nBEX2nuIDSsCLPR7auz09XlYkTk5BN9xQoCm/WYTRFItAPkKTKXLC43RhiA4c5zyFisGoCAIg=
22
+ gem: devise-vero
23
+ on:
24
+ tags: true
25
+ repo: LoveMondays/devise-vero
26
+ branch: master
data/README.md CHANGED
@@ -5,7 +5,9 @@
5
5
  [![Test Coverage](https://codeclimate.com/github/LoveMondays/devise-vero/badges/coverage.svg)](https://codeclimate.com/github/LoveMondays/devise-vero)
6
6
  [![Dependency Status](https://gemnasium.com/LoveMondays/devise-vero.svg)](https://gemnasium.com/LoveMondays/devise-vero)
7
7
 
8
- Replace transaction emails sent by [Devise](https://github.com/plataformatec/devise) with [Vero](http://www.getvero.com) events.
8
+ Add Vero support for an ActiveRecord object.
9
+ - Replace transaction emails sent by [Devise](https://github.com/plataformatec/devise) with [Vero](http://www.getvero.com) events.
10
+ - Unsubscribe the user once it's deleted from application.
9
11
 
10
12
  Tested with devise ~3.4
11
13
 
data/devise-vero.gemspec CHANGED
@@ -10,12 +10,14 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = [
11
11
  'Estevão Mascarenhas',
12
12
  'Vinicius Negrisolo',
13
- "Shane O'Grady"
13
+ "Shane O'Grady",
14
+ 'Rubens Minoru Andako Bueno'
14
15
  ]
15
16
  spec.email = [
16
17
  'estevao.am@gmail.com',
17
18
  'vinicius.negrisolo@gmail.com',
18
- 'shane@ogrady.ie'
19
+ 'shane@ogrady.ie',
20
+ 'rubensmabueno@hotmail.com'
19
21
  ]
20
22
  spec.summary = 'Replace Devise transactional emails with Vero events.'
21
23
  spec.description = 'Replace Devise transactional emails with Vero events.'
@@ -1,9 +1,15 @@
1
+ require 'vero'
2
+
1
3
  module Devise
2
4
  module Models
3
5
  # VeroNotification module
4
6
  module Vero
5
7
  extend ActiveSupport::Concern
6
8
 
9
+ included do
10
+ before_destroy :unsubscribe_user
11
+ end
12
+
7
13
  protected
8
14
 
9
15
  # This method overwrites devise's own `send_devise_notification`
@@ -37,8 +43,16 @@ module Devise
37
43
  @devise_pending_notifications ||= []
38
44
  end
39
45
 
46
+ def unsubscribe_user
47
+ vero_sender.unsubscribe
48
+ end
49
+
40
50
  def send_to_vero(notification, *args)
41
- Devise::Vero::Sender.new(notification, self, *args).deliver
51
+ vero_sender.deliver(notification, *args)
52
+ end
53
+
54
+ def vero_sender
55
+ @vero_sender ||= Devise::Vero::Sender.new(self)
42
56
  end
43
57
  end
44
58
  end
@@ -2,19 +2,22 @@ module Devise
2
2
  module Vero
3
3
  # Sender class
4
4
  class Sender
5
- attr_reader :notification, :instance, :token, :args
5
+ attr_reader :instance
6
6
 
7
- def initialize(notification, instance, *args)
8
- @notification = notification
7
+ def initialize(instance)
9
8
  @instance = instance
10
- @token = args[0] if args.any?
11
- @args = args
12
9
  end
13
10
 
14
11
  # Actually send the event to Vero
15
- def deliver
12
+ def deliver(notification, *args)
13
+ token = args[0] if args.any?
14
+
16
15
  instance.track!(notification, token: token, data: args)
17
16
  end
17
+
18
+ def unsubscribe
19
+ instance.with_default_vero_context.unsubscribe!
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -1,6 +1,6 @@
1
1
  module Devise
2
2
  # Vero module to define VERSION
3
3
  module Vero
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
@@ -5,6 +5,7 @@ describe Devise::Models::Vero do
5
5
  let(:klass) do
6
6
  Class.new do
7
7
  include ActiveModel::Dirty
8
+ include ActiveRecord::Callbacks
8
9
  include Devise::Models::Vero
9
10
  end
10
11
  end
@@ -1,25 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Devise::Vero::Sender do
4
- context 'initializing' do
5
- it 'populate the token attribute with the first arg' do
6
- instance = described_class.new(:test, nil, 2, 3, 4)
7
- expect(instance.token).to eq(2)
8
- end
9
- end
10
-
11
4
  describe '#deliver' do
12
5
  let(:instance) { (Class.new).new }
13
6
  let(:token) { SecureRandom.hex }
14
7
  let(:notification) { :confirmation_instructions }
15
8
 
16
- subject { described_class.new(:confirmation_instructions, instance, token) }
9
+ subject { described_class.new(instance) }
17
10
 
18
11
  it 'calls the track method' do
19
12
  allow(instance).to receive(:track!)
20
- subject.deliver
13
+ subject.deliver(notification, token)
21
14
  expect(instance).to have_received(:track!)
22
15
  .with(notification, token: token, data: [token])
23
16
  end
24
17
  end
18
+
19
+ describe '#unsubscribe' do
20
+ let(:instance) { (Class.new).new }
21
+ let(:vero_context) { Vero::Context.new }
22
+
23
+ subject { described_class.new(instance) }
24
+
25
+ it 'calls the unsubscribe method from vero_context' do
26
+ expect(vero_context).to receive(:unsubscribe!) {}
27
+
28
+ allow(instance).to receive(:with_default_vero_context) { vero_context }
29
+ subject.unsubscribe
30
+ end
31
+ end
25
32
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-vero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Estevão Mascarenhas
8
8
  - Vinicius Negrisolo
9
9
  - Shane O'Grady
10
+ - Rubens Minoru Andako Bueno
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-03-17 00:00:00.000000000 Z
14
+ date: 2015-06-24 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rails
@@ -143,6 +144,7 @@ email:
143
144
  - estevao.am@gmail.com
144
145
  - vinicius.negrisolo@gmail.com
145
146
  - shane@ogrady.ie
147
+ - rubensmabueno@hotmail.com
146
148
  executables: []
147
149
  extensions: []
148
150
  extra_rdoc_files: []
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
188
  version: '0'
187
189
  requirements: []
188
190
  rubyforge_project:
189
- rubygems_version: 2.4.5
191
+ rubygems_version: 2.4.7
190
192
  signing_key:
191
193
  specification_version: 4
192
194
  summary: Replace Devise transactional emails with Vero events.