devise_campaignable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +100 -0
- data/Rakefile +1 -0
- data/devise_campaignable.gemspec +27 -0
- data/lib/devise_campaignable.rb +43 -0
- data/lib/devise_campaignable/adapters/adapter.rb +64 -0
- data/lib/devise_campaignable/adapters/mailchimp.rb +74 -0
- data/lib/devise_campaignable/model.rb +80 -0
- data/lib/devise_campaignable/version.rb +3 -0
- data/spec/adapters/mailchimp_spec.rb +25 -0
- data/spec/devise_campaignable_spec.rb +9 -0
- data/spec/model_spec.rb +24 -0
- data/spec/spec_helper.rb +95 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 645a0547f4056aac9bf4d5c8dd299f6abec8ecfe
|
4
|
+
data.tar.gz: f1b2a04c6b0d1175308fdd19fe9f8d878ef0e243
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 290cf519304217f76bd77b37760a3cc74045a5a0a010af5768fbe3dd30b59754579dc615e9c2d522c59dcacad432974b1fd11929e35139eeced22983ca38f855
|
7
|
+
data.tar.gz: 7e94eab1ffbf16520fb51815641460c1a9e686904ae1a174bd646aa9700f4c386098008ef0caec59ab520c94e78ef4231b1b4dc7ca676ca86372316ef64559e1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Robert Rawlins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# DeviseCampaignable
|
2
|
+
|
3
|
+
Have your users automatically added to and removed from your favourite mail campaign tool. Currently supports [MailChimp](http://mailchimp.com/).
|
4
|
+
|
5
|
+
Inspired by the now slightly out of date [devise_mailchimp](https://github.com/jcnnghm/devise_mailchimp), this gem works in a similar fashion but with a focus on multi-vendor support, rather than exclusively MailChimp.
|
6
|
+
|
7
|
+
It is directly extracted from [Sorry™](http://www.sorryapp.com/) where we use MailChimp to stay in touch with customers about our product development.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Simply add DeviseCampaignable to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'devise'
|
14
|
+
gem 'devise_campaignable'
|
15
|
+
|
16
|
+
## Devise Configuration
|
17
|
+
|
18
|
+
DeviseCampaignable adds a few configuration variables which you'll need to add to your devise initilizer.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Devise.setup do |config|
|
22
|
+
# ==> Configuration for :campaignable
|
23
|
+
config.campaignable_vendor = :vendor_name
|
24
|
+
config.campaignable_api_key = 'your_service_api_key'
|
25
|
+
config.campaignable_list_id = 'the_id_of_the_list_to_which_we_subscribe'
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
#### config.campaignable_vendor (optional)
|
30
|
+
|
31
|
+
A symbol which represents which mail campaign vendor you wish to use. Defaults to `:mailchimp`. Yet to support any other options but future plans for CampaignMonitor etc.
|
32
|
+
|
33
|
+
#### config.campaignable_api_key (required)
|
34
|
+
|
35
|
+
A API key for your chosen vendor. How you aqcuire this will depend from vendor to vendor. We also recommend for security that you store this in an environment variable instead of directly in the initializer.
|
36
|
+
|
37
|
+
#### config.campaignable_list_id (required)
|
38
|
+
|
39
|
+
The unique ID of the list to which you want your users to be subscribed. Again, how you get this will vary from vendor to vendor.
|
40
|
+
|
41
|
+
## Model Configuration
|
42
|
+
|
43
|
+
Add :campaignable to the **devise** call in your model (we’re assuming here you already have a User model with some Devise modules):
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class User < ActiveRecord::Base
|
47
|
+
devise :database_authenticatable, :confirmable, :campaignable
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
### Automatic subscribe / unsubscribe
|
54
|
+
|
55
|
+
Once configured this gem will ensure any users which are created by Devise will be automaticaly subscribed to your mailing list. They will also be unsubscribed when they are deleted.
|
56
|
+
|
57
|
+
### Manual subscribe / unsubscribe
|
58
|
+
|
59
|
+
Should you wish to manually subscribe or unsubscribe any of your users, we have added some new methods to your user model to help you do this.
|
60
|
+
|
61
|
+
#### Individual subscriptions
|
62
|
+
|
63
|
+
Instance methods `User.find(1).subscribe` and `User.find(1).unsubscribe` perform an action on a particular user.
|
64
|
+
|
65
|
+
#### Batch subscriptions
|
66
|
+
|
67
|
+
Class methods `User.subscribe_all()` and `User.unsubscribe_all()` add or remove all users in your system to your mailing list of choice.
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
|
72
|
+
|
73
|
+
Once you are happy that your contribution is ready for production please send us a pull request, at which point we'll review the code and merge it in.
|
74
|
+
|
75
|
+
## Versioning
|
76
|
+
|
77
|
+
For transparency and insight into our release cycle, and for striving to maintain backward compatibility, This project will be maintained under the Semantic Versioning guidelines as much as possible.
|
78
|
+
|
79
|
+
Releases will be numbered with the following format:
|
80
|
+
|
81
|
+
`<major>.<minor>.<patch>`
|
82
|
+
|
83
|
+
And constructed with the following guidelines:
|
84
|
+
|
85
|
+
* Breaking backward compatibility bumps the major (and resets the minor and patch)
|
86
|
+
* New additions without breaking backward compatibility bumps the minor (and resets the patch)
|
87
|
+
* Bug fixes and misc changes bumps the patch
|
88
|
+
|
89
|
+
For more information on SemVer, please visit <http://semver.org/>.
|
90
|
+
|
91
|
+
## Authors & Contributors
|
92
|
+
|
93
|
+
**Robert Rawlins**
|
94
|
+
|
95
|
+
+ <http://twitter.com/sirrawlins>
|
96
|
+
+ <https://github.com/SirRawlins>
|
97
|
+
|
98
|
+
## Copyright
|
99
|
+
|
100
|
+
© Copyright 2015 - See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devise_campaignable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devise_campaignable"
|
8
|
+
spec.version = DeviseCampaignable::VERSION
|
9
|
+
spec.authors = ["Robert Rawlins"]
|
10
|
+
spec.email = ["robert@weboffins.com"]
|
11
|
+
spec.summary = "A multi-vendor mailing list extension for Devise. Have your users automatically added to a mailing list."
|
12
|
+
spec.description = "Inspired by the now slightly out of date devise_mailchimp this gem works in a similar fashion but with a focus on multi-vendor support, rather than exclusively MailChimp."
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "devise", ">= 3.2.0"
|
26
|
+
spec.add_runtime_dependency "gibbon", ">= 1.1.5"
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Require the core devise module.
|
2
|
+
require 'devise'
|
3
|
+
|
4
|
+
module Devise
|
5
|
+
# Extend the configuration options of the core devise
|
6
|
+
# module with our required proprties for the campaignable
|
7
|
+
# extsntion, such as vendor choice, api keys and lists.
|
8
|
+
|
9
|
+
# Public: Default mailing list vendor choice.
|
10
|
+
# By default this is set to Mailchimp as it's the only supported vendor at the
|
11
|
+
# moment until we get around to adding some addiitional vendor adaptors.
|
12
|
+
#
|
13
|
+
# Set campaignable_vendor in the Devise configuration file (config/initializers/devise.rb)
|
14
|
+
#
|
15
|
+
# Devise.campaignable_vendor = :mailchimp
|
16
|
+
mattr_accessor :campaignable_vendor
|
17
|
+
@@campaignable_vendor = :mailchimp
|
18
|
+
|
19
|
+
# Public: Default mailing list for user to join. This can be an array of strings, or just one string.
|
20
|
+
# By default, this is "Site List". If this will be configurable for each user, override
|
21
|
+
# mailchimp_lists_to_join returning the list name or an array of list names for the user to
|
22
|
+
# join.
|
23
|
+
#
|
24
|
+
# Set campaignable_list_name in the Devise configuration file (config/initializers/devise.rb)
|
25
|
+
#
|
26
|
+
# Devise.campaignable_list_id = "12345"
|
27
|
+
#
|
28
|
+
# TODO: Should we allow friendly list names here like devise_mailchimp does?
|
29
|
+
mattr_accessor :campaignable_list_id
|
30
|
+
@@campaignable_list_id = "12345"
|
31
|
+
|
32
|
+
# Public: The API key for accessing the mailchimp service. To generate a new API key, go to the
|
33
|
+
# account tab in your MailChimp account and select API Keys & Authorized Apps, then add
|
34
|
+
# a key. This defaults to 'your_api_key'
|
35
|
+
#
|
36
|
+
# Set subsribable_api_key in the Devise configuration file (config/initializers/devise.rb)
|
37
|
+
#
|
38
|
+
# Devise.subsribable_api_key = "your_api_key"
|
39
|
+
mattr_accessor :campaignable_api_key
|
40
|
+
@@campaignable_api_key = 'your_api_key'
|
41
|
+
end
|
42
|
+
|
43
|
+
Devise.add_module :campaignable, :model => 'devise_campaignable/model'
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module Campaignable
|
4
|
+
module Adapters
|
5
|
+
class Adapter
|
6
|
+
|
7
|
+
# Create a new list manager adapter.
|
8
|
+
def initialize(campaignable_api_key, campaignable_list_id)
|
9
|
+
# Set the basic properties for an adapter.
|
10
|
+
@campaignable_api_key = campaignable_api_key
|
11
|
+
@campaignable_list_id = campaignable_list_id
|
12
|
+
end
|
13
|
+
|
14
|
+
# Placeholder methods for the adapter, these should be implemented
|
15
|
+
# in the parent class but not on the base adapter.
|
16
|
+
#
|
17
|
+
# Accepts single email address to subscribe.
|
18
|
+
def subscribe(email)
|
19
|
+
# Raise an error to warn it isn't implemented.
|
20
|
+
raise NotImplementedError.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# Placeholder methods for the adapter, these should be implemented
|
24
|
+
# in the parent class but not on the base adapter.
|
25
|
+
#
|
26
|
+
# Accepts single email address to subscribe.
|
27
|
+
def unsubscribe(email)
|
28
|
+
# Raise an error to warn it isn't implemented.
|
29
|
+
raise NotImplementedError.new
|
30
|
+
end
|
31
|
+
|
32
|
+
# Placeholder methods for the adapter, these should be implemented
|
33
|
+
# in the parent class but not on the base adapter.
|
34
|
+
#
|
35
|
+
# Accepts single email address to subscribe.
|
36
|
+
def batch_subscribe(email)
|
37
|
+
# Raise an error to warn it isn't implemented.
|
38
|
+
raise NotImplementedError.new
|
39
|
+
end
|
40
|
+
|
41
|
+
# Placeholder methods for the adapter, these should be implemented
|
42
|
+
# in the parent class but not on the base adapter.
|
43
|
+
#
|
44
|
+
# Accepts single email address to subscribe.
|
45
|
+
def batch_unsubscribe(email)
|
46
|
+
# Raise an error to warn it isn't implemented.
|
47
|
+
raise NotImplementedError.new
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Get the API for this adaper. i.e. Mailchimp, CampaignMonitor.
|
53
|
+
def api
|
54
|
+
# Should return an instance of the API instantiated
|
55
|
+
# with the credentials passed into the initialized.
|
56
|
+
# Raise an error to warn it isn't implemented.
|
57
|
+
raise NotImplementedError.new
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module Campaignable
|
4
|
+
module Adapters
|
5
|
+
class Mailchimp < Adapter
|
6
|
+
|
7
|
+
# Subscribe an email to the instantiated list.
|
8
|
+
def subscribe(email)
|
9
|
+
# Logic for mailchimp subcription.
|
10
|
+
api.subscribe({
|
11
|
+
:id => @campaignable_list_id,
|
12
|
+
:email => {
|
13
|
+
:email => email
|
14
|
+
},
|
15
|
+
:double_optin => false, # Don't require email authorization.
|
16
|
+
:update_existing => true, # Don't error if adding existing subscriber.
|
17
|
+
:send_welcome => false # Don't send a welcome email when they're added to the list.
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
# Method to unsubscribe the user from the configured mailing list.
|
22
|
+
# This method is available for API Keys belonging to users with the following roles: manager, admin, owner
|
23
|
+
def unsubscribe(email)
|
24
|
+
# Logic for mailchimp unsubscription.
|
25
|
+
# TODO: Move this into some form of adaptor for Mailchimp so this
|
26
|
+
# TODO: Should this check they are subscribed before attemoting to delete?
|
27
|
+
# class becomes more generic.
|
28
|
+
api.unsubscribe({
|
29
|
+
:id => @campaignable_list_id,
|
30
|
+
:email => {
|
31
|
+
:email => email
|
32
|
+
},
|
33
|
+
:send_goodbye => false, # Don't send a goodbye email.
|
34
|
+
:send_notify => false # Don't notify the user of the unsubscription.
|
35
|
+
})
|
36
|
+
end
|
37
|
+
|
38
|
+
# Subscribe all users as a batch.
|
39
|
+
def batch_subscribe(emails=[])
|
40
|
+
# Do this using a batch call to the MailChimp API for performance rather than lots of single API calls.
|
41
|
+
api.batch_subscribe({
|
42
|
+
:id => @campaignable_list_id,
|
43
|
+
:batch => emails.map {|email| {:email => { :email => email }} }, # Map all users in the system into a mailchimp collcation.
|
44
|
+
:double_optin => false, # Don't require email authorization.
|
45
|
+
:update_existing => true, # Don't error if adding existing subscriber.
|
46
|
+
:replace_interests => false # Don't send a welcome email when they're added to the list.
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
# Unsubscribe all users as a batch.
|
51
|
+
def batch_unsubscribe(emails=[])
|
52
|
+
# Do this using a batch call to the MailChimp API for performance rather than lots of single API calls.
|
53
|
+
api.batch_unsubscribe({
|
54
|
+
:id => @campaignable_list_id,
|
55
|
+
:batch => emails.map {|email| {:email => { :email => email }} }, # Map all users in the system into a mailchimp collcation.
|
56
|
+
:send_goodbye => false, # Don't send a goodbye email.
|
57
|
+
:send_notify => false # Don't notify the user of the unsubscription.
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
# Get an instance of the MailChimp API.
|
64
|
+
def api
|
65
|
+
# Instantiate an instance of Gibbon with the API key provided to this adapter.
|
66
|
+
# We only work with the lists api here, so namespace into that.
|
67
|
+
Gibbon::API.new(@campaignable_api_key).lists
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Require the various adapters.
|
2
|
+
require 'devise_campaignable/adapters/adapter'
|
3
|
+
require 'devise_campaignable/adapters/mailchimp'
|
4
|
+
# NOTE: Add other adapters here as and when they're created.
|
5
|
+
|
6
|
+
module Devise
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Campaignable adds callbacks to your devise model which automaticaly subscribes
|
10
|
+
# them to a mailing list when they create their account, and also updates
|
11
|
+
# their mailing list profile when they edit their personal details.
|
12
|
+
#
|
13
|
+
# This is a multi-vendor libarary which will hopefully support a variety of campaign
|
14
|
+
# tools from Mailchimp to Campaign Monitor.
|
15
|
+
#
|
16
|
+
module Campaignable
|
17
|
+
# This modules are injected as concerms.
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
|
20
|
+
# Add the callbacks to the user model.
|
21
|
+
included do
|
22
|
+
# Callback to subscribe the user whenever the record is saved.
|
23
|
+
after_save :subscribe
|
24
|
+
# Callback to unsubscribe the user when they are destroyed.
|
25
|
+
after_destroy :unsubscribe
|
26
|
+
end
|
27
|
+
|
28
|
+
# Method to subscibe the user to the configrued mailing list.
|
29
|
+
def subscribe
|
30
|
+
# Ask the list manager to subscribe this devise models email.
|
31
|
+
self.class.list_manager.subscribe(self.email)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Method to unsubscribe the user from the configured mailing list.
|
35
|
+
def unsubscribe
|
36
|
+
# Ask the list manager to unsubscribe this devise models email.
|
37
|
+
self.class.list_manager.unsubscribe(self.email)
|
38
|
+
end
|
39
|
+
|
40
|
+
module ClassMethods
|
41
|
+
|
42
|
+
# Get the list subscriber library.
|
43
|
+
def list_manager
|
44
|
+
# For this initial mockup let's us the mailchimp adapter.
|
45
|
+
# TODO: Wrap this in a try/catch with a useful error if not adapter is found.
|
46
|
+
manager = Devise::Models::Campaignable::Adapters.const_get(campaignable_vendor.to_s.camelize).new(campaignable_api_key, campaignable_list_id)
|
47
|
+
|
48
|
+
# Proxy the manager with delayed job if it's available for us to use.
|
49
|
+
# This will mean tasks are managed in the background where possible.
|
50
|
+
#
|
51
|
+
# If class responds to delayed job then return the delayed instance
|
52
|
+
# but if it doesn't look like delayed job implemented just return the
|
53
|
+
# underlying manager object directly.
|
54
|
+
respond_to?(:delay) ? manager.delay(:queue => 'devise_campaignable') : manager
|
55
|
+
end
|
56
|
+
|
57
|
+
# Subscribe all users as a batch.
|
58
|
+
def subscribe_all
|
59
|
+
# Get an array of all the email addresses accociated with this devise class.
|
60
|
+
emails = all.map(&:email)
|
61
|
+
|
62
|
+
# Ask the list managed to subscibe all of these emails.
|
63
|
+
list_manager.batch_subscribe(emails)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Unsubscribe all users as a batch.
|
67
|
+
def unsubscribe_all
|
68
|
+
# Get an array of all the email addresses accociated with this devise class.
|
69
|
+
emails = all.map(&:email)
|
70
|
+
|
71
|
+
# Ask the list managed to subscibe all of these emails.
|
72
|
+
list_manager.batch_unsubscribe(emails)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Set the configuration variables for the modeule.
|
76
|
+
Devise::Models.config(self, :campaignable_api_key, :campaignable_list_id, :campaignable_vendor)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Devise::Models::Campaignable::Adapters::Mailchimp do
|
4
|
+
it "is a subclass of Adapter"
|
5
|
+
|
6
|
+
describe "#api" do
|
7
|
+
it "returns an instance of gibbon"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#subscribe" do
|
11
|
+
it "makes a valid subscribe request to the gibbon api"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#unsubscribe" do
|
15
|
+
it "makes a valid subscribe request to the gibbon api"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#batch_subscribe" do
|
19
|
+
it "makes a valid subscribe request to the gibbon api"
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#batch_unsubscribe" do
|
23
|
+
it "makes a valid subscribe request to the gibbon api"
|
24
|
+
end
|
25
|
+
end
|
data/spec/model_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Devise::Models::Campaignable do
|
4
|
+
describe "callbacks" do
|
5
|
+
it "subscribes the user after save"
|
6
|
+
it "unsubscribes the user after destroy"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "instance methods" do
|
10
|
+
it "Subscribes the user using their email"
|
11
|
+
it "Unsubscribes the user using their email"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "class methods" do
|
15
|
+
describe "#list_manager" do
|
16
|
+
it "provides an instance of the list manager"
|
17
|
+
it "throws an error if asked for an unknown adapter"
|
18
|
+
it "wrap the instance with delayed job"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "Subscribes all users using their email"
|
22
|
+
it "Unsubscribes all users using their email"
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Require rspec, and the lib we're planning to test.
|
2
|
+
require 'rspec'
|
3
|
+
require 'devise_campaignable'
|
4
|
+
|
5
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
8
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
9
|
+
# files.
|
10
|
+
#
|
11
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
12
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
13
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
14
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
15
|
+
# a separate helper file that requires the additional dependencies and performs
|
16
|
+
# the additional setup, and require it from the spec files that actually need
|
17
|
+
# it.
|
18
|
+
#
|
19
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
20
|
+
# users commonly want.
|
21
|
+
#
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# rspec-expectations config goes here. You can use an alternate
|
25
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
+
# assertions if you prefer.
|
27
|
+
config.expect_with :rspec do |expectations|
|
28
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
+
# and `failure_message` of custom matchers include text for helper methods
|
30
|
+
# defined using `chain`, e.g.:
|
31
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
+
# # => "be bigger than 2 and smaller than 4"
|
33
|
+
# ...rather than:
|
34
|
+
# # => "be bigger than 2"
|
35
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
+
end
|
37
|
+
|
38
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
+
config.mock_with :rspec do |mocks|
|
41
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
+
# a real object. This is generally recommended, and will default to
|
43
|
+
# `true` in RSpec 4.
|
44
|
+
mocks.verify_partial_doubles = true
|
45
|
+
end
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# These two settings work together to allow you to limit a spec run
|
51
|
+
# to individual examples or groups you care about by tagging them with
|
52
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
53
|
+
# get run.
|
54
|
+
config.filter_run :focus
|
55
|
+
config.run_all_when_everything_filtered = true
|
56
|
+
|
57
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
58
|
+
# recommended. For more details, see:
|
59
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
60
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
61
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
62
|
+
config.disable_monkey_patching!
|
63
|
+
|
64
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
65
|
+
# be too noisy due to issues in dependencies.
|
66
|
+
config.warnings = true
|
67
|
+
|
68
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
69
|
+
# file, and it's useful to allow more verbose output when running an
|
70
|
+
# individual spec file.
|
71
|
+
if config.files_to_run.one?
|
72
|
+
# Use the documentation formatter for detailed output,
|
73
|
+
# unless a formatter has already been configured
|
74
|
+
# (e.g. via a command-line flag).
|
75
|
+
config.default_formatter = 'doc'
|
76
|
+
end
|
77
|
+
|
78
|
+
# Print the 10 slowest examples and example groups at the
|
79
|
+
# end of the spec run, to help surface which specs are running
|
80
|
+
# particularly slow.
|
81
|
+
config.profile_examples = 10
|
82
|
+
|
83
|
+
# Run specs in random order to surface order dependencies. If you find an
|
84
|
+
# order dependency and want to debug it, you can fix the order by providing
|
85
|
+
# the seed, which is printed after each run.
|
86
|
+
# --seed 1234
|
87
|
+
config.order = :random
|
88
|
+
|
89
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
90
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
91
|
+
# test failures related to randomization by passing the same `--seed` value
|
92
|
+
# as the one that triggered the failure.
|
93
|
+
Kernel.srand config.seed
|
94
|
+
=end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_campaignable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Rawlins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: devise
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gibbon
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.5
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.5
|
83
|
+
description: Inspired by the now slightly out of date devise_mailchimp this gem works
|
84
|
+
in a similar fashion but with a focus on multi-vendor support, rather than exclusively
|
85
|
+
MailChimp.
|
86
|
+
email:
|
87
|
+
- robert@weboffins.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- devise_campaignable.gemspec
|
99
|
+
- lib/devise_campaignable.rb
|
100
|
+
- lib/devise_campaignable/adapters/adapter.rb
|
101
|
+
- lib/devise_campaignable/adapters/mailchimp.rb
|
102
|
+
- lib/devise_campaignable/model.rb
|
103
|
+
- lib/devise_campaignable/version.rb
|
104
|
+
- spec/adapters/mailchimp_spec.rb
|
105
|
+
- spec/devise_campaignable_spec.rb
|
106
|
+
- spec/model_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
homepage: ''
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.2.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: A multi-vendor mailing list extension for Devise. Have your users automatically
|
132
|
+
added to a mailing list.
|
133
|
+
test_files:
|
134
|
+
- spec/adapters/mailchimp_spec.rb
|
135
|
+
- spec/devise_campaignable_spec.rb
|
136
|
+
- spec/model_spec.rb
|
137
|
+
- spec/spec_helper.rb
|