subscribed_to 0.2.0 → 0.3.0

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.
Files changed (63) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +2 -0
  3. data/README.rdoc +32 -0
  4. data/app/controllers/subscribed_to/mail_chimp_web_hooks_controller.rb +19 -0
  5. data/config/routes.rb +5 -0
  6. data/lib/active_record_extensions.rb +10 -0
  7. data/lib/generators/subscribed_to/templates/migration.rb +8 -0
  8. data/lib/generators/subscribed_to/templates/subscribed_to.rb +4 -0
  9. data/lib/subscribed_to/engine.rb +7 -0
  10. data/lib/subscribed_to/mail_chimp/config.rb +5 -3
  11. data/lib/subscribed_to/mail_chimp/web_hook.rb +136 -0
  12. data/lib/subscribed_to/mail_chimp.rb +3 -2
  13. data/lib/subscribed_to/version.rb +1 -1
  14. data/lib/subscribed_to.rb +9 -0
  15. data/spec/app/controllers/subscribed_to/mail_chimp_web_hooks_spec.rb +147 -0
  16. data/spec/dummy/Rakefile +7 -0
  17. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/models/user.rb +3 -0
  20. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/spec/dummy/config/application.rb +45 -0
  22. data/spec/dummy/config/boot.rb +10 -0
  23. data/spec/dummy/config/database.yml +22 -0
  24. data/spec/dummy/config/environment.rb +5 -0
  25. data/spec/dummy/config/environments/development.rb +26 -0
  26. data/spec/dummy/config/environments/production.rb +49 -0
  27. data/spec/dummy/config/environments/test.rb +35 -0
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/spec/dummy/config/initializers/inflections.rb +10 -0
  30. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  31. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  32. data/spec/dummy/config/initializers/session_store.rb +8 -0
  33. data/spec/dummy/config/initializers/subscribed_to.rb +21 -0
  34. data/spec/dummy/config/locales/en.yml +5 -0
  35. data/spec/dummy/config/routes.rb +2 -0
  36. data/spec/dummy/config.ru +4 -0
  37. data/spec/dummy/db/migrate/1_create_users.rb +18 -0
  38. data/spec/dummy/db/schema.rb +26 -0
  39. data/spec/dummy/public/404.html +26 -0
  40. data/spec/dummy/public/422.html +26 -0
  41. data/spec/dummy/public/500.html +26 -0
  42. data/spec/dummy/public/favicon.ico +0 -0
  43. data/spec/dummy/public/javascripts/application.js +2 -0
  44. data/spec/dummy/public/javascripts/controls.js +965 -0
  45. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  46. data/spec/dummy/public/javascripts/effects.js +1123 -0
  47. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  48. data/spec/dummy/public/javascripts/rails.js +191 -0
  49. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  50. data/spec/dummy/script/rails +6 -0
  51. data/spec/factories/users.rb +1 -0
  52. data/spec/{generators → lib/generators}/install_generator_spec.rb +0 -0
  53. data/spec/{subscribed_to → lib/subscribed_to}/mail_chimp/config_spec.rb +0 -0
  54. data/spec/lib/subscribed_to/mail_chimp/web_hook_spec.rb +158 -0
  55. data/spec/lib/subscribed_to/mail_chimp_spec.rb +74 -0
  56. data/spec/{subscribed_to_spec.rb → lib/subscribed_to_spec.rb} +0 -0
  57. data/spec/spec_helper.rb +70 -28
  58. data/subscribed_to.gemspec +136 -0
  59. metadata +77 -26
  60. data/spec/app/models/user.rb +0 -43
  61. data/spec/database.yml.example +0 -17
  62. data/spec/schema.rb +0 -9
  63. data/spec/subscribed_to/mail_chimp_spec.rb +0 -53
@@ -0,0 +1,136 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{subscribed_to}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["whtt-eric"]
12
+ s.date = %q{2011-05-20}
13
+ s.description = %q{Abstract layer for managing mailing list subscriptions}
14
+ s.email = %q{eric@wehaventthetime.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "app/controllers/subscribed_to/mail_chimp_web_hooks_controller.rb",
28
+ "config/routes.rb",
29
+ "lib/active_record_extensions.rb",
30
+ "lib/generators/subscribed_to/USAGE",
31
+ "lib/generators/subscribed_to/install_generator.rb",
32
+ "lib/generators/subscribed_to/templates/migration.rb",
33
+ "lib/generators/subscribed_to/templates/subscribed_to.rb",
34
+ "lib/subscribed_to.rb",
35
+ "lib/subscribed_to/engine.rb",
36
+ "lib/subscribed_to/mail_chimp.rb",
37
+ "lib/subscribed_to/mail_chimp/config.rb",
38
+ "lib/subscribed_to/mail_chimp/web_hook.rb",
39
+ "lib/subscribed_to/version.rb",
40
+ "spec/app/controllers/subscribed_to/mail_chimp_web_hooks_spec.rb",
41
+ "spec/dummy/Rakefile",
42
+ "spec/dummy/app/controllers/application_controller.rb",
43
+ "spec/dummy/app/helpers/application_helper.rb",
44
+ "spec/dummy/app/models/user.rb",
45
+ "spec/dummy/app/views/layouts/application.html.erb",
46
+ "spec/dummy/config.ru",
47
+ "spec/dummy/config/application.rb",
48
+ "spec/dummy/config/boot.rb",
49
+ "spec/dummy/config/database.yml",
50
+ "spec/dummy/config/environment.rb",
51
+ "spec/dummy/config/environments/development.rb",
52
+ "spec/dummy/config/environments/production.rb",
53
+ "spec/dummy/config/environments/test.rb",
54
+ "spec/dummy/config/initializers/backtrace_silencers.rb",
55
+ "spec/dummy/config/initializers/inflections.rb",
56
+ "spec/dummy/config/initializers/mime_types.rb",
57
+ "spec/dummy/config/initializers/secret_token.rb",
58
+ "spec/dummy/config/initializers/session_store.rb",
59
+ "spec/dummy/config/initializers/subscribed_to.rb",
60
+ "spec/dummy/config/locales/en.yml",
61
+ "spec/dummy/config/routes.rb",
62
+ "spec/dummy/db/migrate/1_create_users.rb",
63
+ "spec/dummy/db/schema.rb",
64
+ "spec/dummy/public/404.html",
65
+ "spec/dummy/public/422.html",
66
+ "spec/dummy/public/500.html",
67
+ "spec/dummy/public/favicon.ico",
68
+ "spec/dummy/public/javascripts/application.js",
69
+ "spec/dummy/public/javascripts/controls.js",
70
+ "spec/dummy/public/javascripts/dragdrop.js",
71
+ "spec/dummy/public/javascripts/effects.js",
72
+ "spec/dummy/public/javascripts/prototype.js",
73
+ "spec/dummy/public/javascripts/rails.js",
74
+ "spec/dummy/public/stylesheets/.gitkeep",
75
+ "spec/dummy/script/rails",
76
+ "spec/factories/users.rb",
77
+ "spec/lib/generators/install_generator_spec.rb",
78
+ "spec/lib/subscribed_to/mail_chimp/config_spec.rb",
79
+ "spec/lib/subscribed_to/mail_chimp/web_hook_spec.rb",
80
+ "spec/lib/subscribed_to/mail_chimp_spec.rb",
81
+ "spec/lib/subscribed_to_spec.rb",
82
+ "spec/spec_helper.rb",
83
+ "subscribed_to.gemspec"
84
+ ]
85
+ s.homepage = %q{http://github.com/whtt-eric/subscribed_to}
86
+ s.licenses = ["MIT"]
87
+ s.require_paths = ["lib"]
88
+ s.rubygems_version = %q{1.6.2}
89
+ s.summary = %q{Abstract layer for managing mailing list subscriptions}
90
+
91
+ if s.respond_to? :specification_version then
92
+ s.specification_version = 3
93
+
94
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
96
+ s.add_runtime_dependency(%q<hominid>, [">= 3.0.2"])
97
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
98
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
99
+ s.add_development_dependency(%q<factory_girl_rails>, ["= 1.0.1"])
100
+ s.add_development_dependency(%q<mocha>, ["= 0.9.12"])
101
+ s.add_development_dependency(%q<rspec-rails>, ["= 2.5.0"])
102
+ s.add_development_dependency(%q<generator_spec>, [">= 0"])
103
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
104
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
105
+ s.add_development_dependency(%q<simplecov>, [">= 0.4.0"])
106
+ s.add_development_dependency(%q<hanna>, [">= 0"])
107
+ else
108
+ s.add_dependency(%q<activerecord>, [">= 0"])
109
+ s.add_dependency(%q<hominid>, [">= 3.0.2"])
110
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
111
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
112
+ s.add_dependency(%q<factory_girl_rails>, ["= 1.0.1"])
113
+ s.add_dependency(%q<mocha>, ["= 0.9.12"])
114
+ s.add_dependency(%q<rspec-rails>, ["= 2.5.0"])
115
+ s.add_dependency(%q<generator_spec>, [">= 0"])
116
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
117
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
118
+ s.add_dependency(%q<simplecov>, [">= 0.4.0"])
119
+ s.add_dependency(%q<hanna>, [">= 0"])
120
+ end
121
+ else
122
+ s.add_dependency(%q<activerecord>, [">= 0"])
123
+ s.add_dependency(%q<hominid>, [">= 3.0.2"])
124
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
125
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
126
+ s.add_dependency(%q<factory_girl_rails>, ["= 1.0.1"])
127
+ s.add_dependency(%q<mocha>, ["= 0.9.12"])
128
+ s.add_dependency(%q<rspec-rails>, ["= 2.5.0"])
129
+ s.add_dependency(%q<generator_spec>, [">= 0"])
130
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
131
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
132
+ s.add_dependency(%q<simplecov>, [">= 0.4.0"])
133
+ s.add_dependency(%q<hanna>, [">= 0"])
134
+ end
135
+ end
136
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: subscribed_to
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - whtt-eric
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-18 00:00:00 -04:00
13
+ date: 2011-05-20 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -47,8 +47,19 @@ dependencies:
47
47
  prerelease: false
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: factory_girl_rails
50
+ name: database_cleaner
51
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: factory_girl_rails
62
+ requirement: &id005 !ruby/object:Gem::Requirement
52
63
  none: false
53
64
  requirements:
54
65
  - - "="
@@ -56,10 +67,10 @@ dependencies:
56
67
  version: 1.0.1
57
68
  type: :development
58
69
  prerelease: false
59
- version_requirements: *id004
70
+ version_requirements: *id005
60
71
  - !ruby/object:Gem::Dependency
61
72
  name: mocha
62
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
63
74
  none: false
64
75
  requirements:
65
76
  - - "="
@@ -67,10 +78,10 @@ dependencies:
67
78
  version: 0.9.12
68
79
  type: :development
69
80
  prerelease: false
70
- version_requirements: *id005
81
+ version_requirements: *id006
71
82
  - !ruby/object:Gem::Dependency
72
83
  name: rspec-rails
73
- requirement: &id006 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
74
85
  none: false
75
86
  requirements:
76
87
  - - "="
@@ -78,10 +89,10 @@ dependencies:
78
89
  version: 2.5.0
79
90
  type: :development
80
91
  prerelease: false
81
- version_requirements: *id006
92
+ version_requirements: *id007
82
93
  - !ruby/object:Gem::Dependency
83
94
  name: generator_spec
84
- requirement: &id007 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
85
96
  none: false
86
97
  requirements:
87
98
  - - ">="
@@ -89,10 +100,10 @@ dependencies:
89
100
  version: "0"
90
101
  type: :development
91
102
  prerelease: false
92
- version_requirements: *id007
103
+ version_requirements: *id008
93
104
  - !ruby/object:Gem::Dependency
94
105
  name: bundler
95
- requirement: &id008 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
96
107
  none: false
97
108
  requirements:
98
109
  - - ~>
@@ -100,10 +111,10 @@ dependencies:
100
111
  version: 1.0.0
101
112
  type: :development
102
113
  prerelease: false
103
- version_requirements: *id008
114
+ version_requirements: *id009
104
115
  - !ruby/object:Gem::Dependency
105
116
  name: jeweler
106
- requirement: &id009 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
107
118
  none: false
108
119
  requirements:
109
120
  - - ~>
@@ -111,10 +122,10 @@ dependencies:
111
122
  version: 1.6.0
112
123
  type: :development
113
124
  prerelease: false
114
- version_requirements: *id009
125
+ version_requirements: *id010
115
126
  - !ruby/object:Gem::Dependency
116
127
  name: simplecov
117
- requirement: &id010 !ruby/object:Gem::Requirement
128
+ requirement: &id011 !ruby/object:Gem::Requirement
118
129
  none: false
119
130
  requirements:
120
131
  - - ">="
@@ -122,10 +133,10 @@ dependencies:
122
133
  version: 0.4.0
123
134
  type: :development
124
135
  prerelease: false
125
- version_requirements: *id010
136
+ version_requirements: *id011
126
137
  - !ruby/object:Gem::Dependency
127
138
  name: hanna
128
- requirement: &id011 !ruby/object:Gem::Requirement
139
+ requirement: &id012 !ruby/object:Gem::Requirement
129
140
  none: false
130
141
  requirements:
131
142
  - - ">="
@@ -133,7 +144,7 @@ dependencies:
133
144
  version: "0"
134
145
  type: :development
135
146
  prerelease: false
136
- version_requirements: *id011
147
+ version_requirements: *id012
137
148
  description: Abstract layer for managing mailing list subscriptions
138
149
  email: eric@wehaventthetime.com
139
150
  executables: []
@@ -151,23 +162,63 @@ files:
151
162
  - LICENSE.txt
152
163
  - README.rdoc
153
164
  - Rakefile
165
+ - app/controllers/subscribed_to/mail_chimp_web_hooks_controller.rb
166
+ - config/routes.rb
167
+ - lib/active_record_extensions.rb
154
168
  - lib/generators/subscribed_to/USAGE
155
169
  - lib/generators/subscribed_to/install_generator.rb
156
170
  - lib/generators/subscribed_to/templates/migration.rb
157
171
  - lib/generators/subscribed_to/templates/subscribed_to.rb
158
172
  - lib/subscribed_to.rb
173
+ - lib/subscribed_to/engine.rb
159
174
  - lib/subscribed_to/mail_chimp.rb
160
175
  - lib/subscribed_to/mail_chimp/config.rb
176
+ - lib/subscribed_to/mail_chimp/web_hook.rb
161
177
  - lib/subscribed_to/version.rb
162
- - spec/app/models/user.rb
163
- - spec/database.yml.example
178
+ - spec/app/controllers/subscribed_to/mail_chimp_web_hooks_spec.rb
179
+ - spec/dummy/Rakefile
180
+ - spec/dummy/app/controllers/application_controller.rb
181
+ - spec/dummy/app/helpers/application_helper.rb
182
+ - spec/dummy/app/models/user.rb
183
+ - spec/dummy/app/views/layouts/application.html.erb
184
+ - spec/dummy/config.ru
185
+ - spec/dummy/config/application.rb
186
+ - spec/dummy/config/boot.rb
187
+ - spec/dummy/config/database.yml
188
+ - spec/dummy/config/environment.rb
189
+ - spec/dummy/config/environments/development.rb
190
+ - spec/dummy/config/environments/production.rb
191
+ - spec/dummy/config/environments/test.rb
192
+ - spec/dummy/config/initializers/backtrace_silencers.rb
193
+ - spec/dummy/config/initializers/inflections.rb
194
+ - spec/dummy/config/initializers/mime_types.rb
195
+ - spec/dummy/config/initializers/secret_token.rb
196
+ - spec/dummy/config/initializers/session_store.rb
197
+ - spec/dummy/config/initializers/subscribed_to.rb
198
+ - spec/dummy/config/locales/en.yml
199
+ - spec/dummy/config/routes.rb
200
+ - spec/dummy/db/migrate/1_create_users.rb
201
+ - spec/dummy/db/schema.rb
202
+ - spec/dummy/public/404.html
203
+ - spec/dummy/public/422.html
204
+ - spec/dummy/public/500.html
205
+ - spec/dummy/public/favicon.ico
206
+ - spec/dummy/public/javascripts/application.js
207
+ - spec/dummy/public/javascripts/controls.js
208
+ - spec/dummy/public/javascripts/dragdrop.js
209
+ - spec/dummy/public/javascripts/effects.js
210
+ - spec/dummy/public/javascripts/prototype.js
211
+ - spec/dummy/public/javascripts/rails.js
212
+ - spec/dummy/public/stylesheets/.gitkeep
213
+ - spec/dummy/script/rails
164
214
  - spec/factories/users.rb
165
- - spec/generators/install_generator_spec.rb
166
- - spec/schema.rb
215
+ - spec/lib/generators/install_generator_spec.rb
216
+ - spec/lib/subscribed_to/mail_chimp/config_spec.rb
217
+ - spec/lib/subscribed_to/mail_chimp/web_hook_spec.rb
218
+ - spec/lib/subscribed_to/mail_chimp_spec.rb
219
+ - spec/lib/subscribed_to_spec.rb
167
220
  - spec/spec_helper.rb
168
- - spec/subscribed_to/mail_chimp/config_spec.rb
169
- - spec/subscribed_to/mail_chimp_spec.rb
170
- - spec/subscribed_to_spec.rb
221
+ - subscribed_to.gemspec
171
222
  has_rdoc: true
172
223
  homepage: http://github.com/whtt-eric/subscribed_to
173
224
  licenses:
@@ -182,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
233
  requirements:
183
234
  - - ">="
184
235
  - !ruby/object:Gem::Version
185
- hash: 1335917726808869519
236
+ hash: 4004874530137465166
186
237
  segments:
187
238
  - 0
188
239
  version: "0"
@@ -1,43 +0,0 @@
1
- class User < ActiveRecord::Base
2
- subscribed_to :mailing_list
3
- end
4
-
5
- class MailChimpUser < User
6
- subscribed_to :mailing_list
7
-
8
- attr_accessor :callback_result
9
-
10
- # Stubbed for testing
11
- def subscribe_to_list
12
- if subscribed_to_list
13
- merge_vars = self.class.merge_vars.dup
14
-
15
- # use hominid to subscribe user
16
- self.callback_result = "Subscribed with: #{merge_vars.each { |key, method| merge_vars[key] = self.send(method.to_sym) }.values.join(", ")}"
17
- else # mocked for test -- subscribed_to_list normally doesn't do anything if !subscribed_to_list
18
- self.callback_result = "Not Subscribed"
19
- end
20
- end
21
-
22
- # Stubbed for testing
23
- def update_list_member
24
- merge_vars = self.class.merge_vars.dup
25
-
26
- if !(self.changed & merge_vars.collect { |key, method| method.to_s }.push("subscribed_to_list")).empty?
27
- if self.changed.include?("subscribed_to_list")
28
- if !subscribed_to_list
29
- # use hominid to unsubscribe user
30
- self.callback_result = "Unsubscribed"
31
- else
32
- # use hominid to subscribe user
33
- self.callback_result = "Subscribed with: #{merge_vars.each { |key, method| merge_vars[key] = self.send(method.to_sym) }.values.join(", ")}"
34
- end
35
- elsif subscribed_to_list && !(self.changed & merge_vars.collect { |key, method| method.to_s }).empty?
36
- # use hominid to update user
37
- self.callback_result = "Updated with: #{merge_vars.each { |key, method| merge_vars[key] = self.send(method.to_sym) }.values.join(", ")}"
38
- end
39
- else # mocked for test -- update_list_member normally doesn't do anything in this case
40
- self.callback_result = "Nothing updated"
41
- end
42
- end
43
- end
@@ -1,17 +0,0 @@
1
- sqlite3:
2
- adapter: sqlite3
3
- database: subscribed_to.sqlite3
4
-
5
- mysql:
6
- adapter: mysql
7
- hostname: localhost
8
- username: root
9
- password:
10
- database: subscribed_to
11
-
12
- postgresql:
13
- adapter: postgresql
14
- hostname: localhost
15
- username: postgres
16
- password:
17
- database: subscribed_to
data/spec/schema.rb DELETED
@@ -1,9 +0,0 @@
1
- ActiveRecord::Schema.define :version => 0 do
2
- create_table :users, :force => true do |t|
3
- t.string :first_name
4
- t.string :last_name
5
- t.string :email
6
- t.boolean :subscribed_to_list
7
- t.string :password
8
- end
9
- end
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
- require 'hominid'
3
-
4
- describe SubscribedTo::MailChimp do
5
- before(:each) do
6
- SubscribedTo.mail_chimp do |config|
7
- config.api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us1"
8
- config.lists = {:mailing_list => {:id => "123456", :merge_vars => {"FNAME" => :first_name, "LNAME" => :last_name, "EMAIL" => :email}}}
9
- end
10
- end
11
-
12
- context "for a new user" do
13
- it "should subscribe the user" do
14
- @user = MailChimpUser.create(Factory.attributes_for(:subscribed_user))
15
- @user.callback_result.should eq "Subscribed with: Eric, Salczynski, eric@wehaventthetime.com"
16
- end
17
-
18
- it "should not subscribe the user" do
19
- @user = MailChimpUser.create(Factory.attributes_for(:non_subscribed_user))
20
- @user.callback_result.should eq "Not Subscribed"
21
- end
22
- end
23
-
24
- context "for an existing user" do
25
- context "who is not subscribed to the mailing list" do
26
- before { @user = MailChimpUser.create(Factory.attributes_for(:non_subscribed_user)) }
27
-
28
- it "should subscribe the user" do
29
- @user.update_attributes({:subscribed_to_list => true})
30
- @user.callback_result.should eq "Subscribed with: #{[@user.first_name, @user.last_name, @user.email].join(", ")}"
31
- end
32
- end
33
-
34
- context "who is subscribed to the mailing list" do
35
- before(:each) { @user = MailChimpUser.create(Factory.attributes_for(:subscribed_user)) }
36
-
37
- it "should unsubscribe the user" do
38
- @user.update_attributes({:subscribed_to_list => false})
39
- @user.callback_result.should eq "Unsubscribed"
40
- end
41
-
42
- it "should update list member attributes for the user" do
43
- @user.update_attributes({:first_name => "Ed", :last_name => "Salczynski", :email => "ed@whtt.me"})
44
- @user.callback_result.should eq "Updated with: Ed, Salczynski, ed@whtt.me"
45
- end
46
-
47
- it "should not update list member when attributes not defined in merge vars are changed" do
48
- @user.update_attributes({:password => "zyx321"})
49
- @user.callback_result.should eq "Nothing updated"
50
- end
51
- end
52
- end
53
- end