chimpmunk 0.0.4 → 0.0.5

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: c60fcdbf6b7dfda454a5d0061d798af3c67d8973
4
- data.tar.gz: 305e8d6ea4982a9dd33b117c6c0ee8e7bfd6ffac
3
+ metadata.gz: a980ab3ac42186d0fe40586f7cbded021271d44f
4
+ data.tar.gz: 383c24bcdcbf03f459f5a6ca33cde42c19e15516
5
5
  SHA512:
6
- metadata.gz: 0f45bdfb37ae8b43fa769e396c57459cef38d1a5f065361a8318cc203a2cd532500556343dd09881556b5d221655c8bacc5790cdb4eccbcf91e879038a54e563
7
- data.tar.gz: 7552591f37ca4ba7e9648429999f8c8ae943f50a4f1432d883106e60a5d627c5faaa533812fc6530247944554824e8004d23e1d52b62442e1ae5e19dc0cb0b59
6
+ metadata.gz: 8123420f18835fc092dee804515bf778eb1c5146e423f074e944b3bc95120f6eeb9d23cee70a34dd00c329a5826b45bb3d5fb2d51b8aec8ce434eb427d8edf3a
7
+ data.tar.gz: 68c2147e4611ef3c6e865cbb550028b1eeed9fb5d237995148100ef6c1fbc854fbedc76cb83f70f26e8d11618a6206bc037ac6dd60486a5b319f5193ce486649
data/README.md CHANGED
@@ -78,14 +78,6 @@ in `app/models` :
78
78
  associated :one, :user # will have one :email_campaign_comment
79
79
  editable_areas :posts
80
80
 
81
- #
82
- # must have a content method
83
- #
84
- def content
85
- sections = {}
86
- {sections: sections}
87
- end
88
-
89
81
  rails_admin do
90
82
  edit do
91
83
  field :title
@@ -111,7 +103,7 @@ in `app/models` :
111
103
  in `app/views/chimpmunk/_posts.html.haml`, you should have an `mc:edit` somewhere in your template called 'posts'
112
104
 
113
105
  ```
114
- - campaign.email_campaign_posts.map(&:post).each do |post|
106
+ - posts.each do |post|
115
107
  .post.span-6
116
108
  %h1= post.name
117
109
  %p= post.body
data/chimpmunk.gemspec CHANGED
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'activerecord', ['>= 3.2', '< 5']
22
22
  spec.add_dependency 'gibbon', '>= 1.1'
23
- spec.add_dependency 'paperclip', '>= 4.1'
23
+ spec.add_dependency 'paperclip', '>= 3.4'
24
+ spec.add_development_dependency 'rspec-rails'
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.6"
26
27
  spec.add_development_dependency "rake"
@@ -43,6 +43,7 @@ class ChimpmunkMigration < ActiveRecord::Migration
43
43
  t.string :campaign_kind
44
44
  t.integer :template_id
45
45
  t.references :email_list_group, index: true
46
+ t.string :type
46
47
 
47
48
  t.timestamps
48
49
  end
@@ -3,17 +3,6 @@ module Chimpmunk
3
3
  class EmailCampaign < ::ActiveRecord::Base
4
4
  attr_accessor :skip_update_callbacks, :skip_create_callbacks
5
5
 
6
- #
7
- # dynamic class methods for all mc_edit types
8
- #
9
- [:tags, :headers, :texts, :images].each do |mc_edit_type|
10
- self.class_eval <<-EOF
11
- def self.mc_edit_#{mc_edit_type}
12
- @@mc_edit_#{mc_edit_type}
13
- end
14
- EOF
15
- end
16
-
17
6
  # rails 3
18
7
  attr_accessible :title, :from_email, :from_name, :email_list_id, :subject, :email_template_id, :mailchimp_list_id, :send_date,
19
8
  :mailchimp_campaign_id, :emails_sent, :clicked, :opened, :status, :hard_bounces, :soft_bounces, :unsubscribes, :forwards,
@@ -46,9 +35,16 @@ module Chimpmunk
46
35
  # create header associations
47
36
  #
48
37
  def self.headers(*headers)
49
- @@mc_edit_headers = headers
38
+ class << self; attr_accessor :mc_edit_headers; end
39
+ @mc_edit_headers = headers
40
+
50
41
  headers.each do |header|
51
- has_one header.to_sym, -> { where(name: header.to_s) }, class_name: 'Chimpmunk::EmailCampaignHeader', foreign_key: :email_campaign_id
42
+ if Rails::VERSION::MAJOR == 4
43
+ has_one header.to_sym, -> { where(name: header.to_s) }, class_name: 'Chimpmunk::EmailCampaignHeader', foreign_key: :email_campaign_id, dependent: :destroy
44
+ else
45
+ attr_accessible[:default] << "#{header}_attributes"
46
+ has_one header.to_sym, conditions: { name: header.to_s }, class_name: 'Chimpmunk::EmailCampaignHeader', foreign_key: :email_campaign_id, dependent: :destroy
47
+ end
52
48
  accepts_nested_attributes_for header.to_sym, allow_destroy: true
53
49
  end
54
50
  end
@@ -57,9 +53,16 @@ module Chimpmunk
57
53
  # create text associations
58
54
  #
59
55
  def self.texts(*texts)
60
- @@mc_edit_texts = texts
56
+ class << self; attr_accessor :mc_edit_texts; end
57
+ @mc_edit_texts = texts
58
+
61
59
  texts.each do |text|
62
- has_one text.to_sym, -> { where(name: text.to_s) }, class_name: 'Chimpmunk::EmailCampaignText', foreign_key: :email_campaign_id
60
+ if Rails::VERSION::MAJOR == 4
61
+ has_one text.to_sym, -> { where(name: text.to_s) }, class_name: 'Chimpmunk::EmailCampaignText', foreign_key: :email_campaign_id, dependent: :destroy
62
+ else
63
+ attr_accessible[:default] << "#{text}_attributes"
64
+ has_one text.to_sym, conditions: { name: text.to_s }, class_name: 'Chimpmunk::EmailCampaignText', foreign_key: :email_campaign_id, dependent: :destroy
65
+ end
63
66
  accepts_nested_attributes_for text.to_sym, allow_destroy: true
64
67
  end
65
68
  end
@@ -68,9 +71,16 @@ module Chimpmunk
68
71
  # create image associations
69
72
  #
70
73
  def self.images(*images)
71
- @@mc_edit_images = images
74
+ class << self; attr_accessor :mc_edit_images; end
75
+ @mc_edit_images = images
76
+
72
77
  images.each do |image|
73
- has_one image.to_sym, -> { where(name: image.to_s) }, class_name: 'Chimpmunk::EmailCampaignImage', foreign_key: :email_campaign_id
78
+ if Rails::VERSION::MAJOR == 4
79
+ has_one image.to_sym, -> { where(name: image.to_s) }, class_name: 'Chimpmunk::EmailCampaignImage', foreign_key: :email_campaign_id, dependent: :destroy
80
+ else
81
+ attr_accessible[:default] << "#{image}_attributes"
82
+ has_one image.to_sym, conditions: { name: image.to_s }, class_name: 'Chimpmunk::EmailCampaignImage', foreign_key: :email_campaign_id, dependent: :destroy
83
+ end
74
84
  accepts_nested_attributes_for image.to_sym, allow_destroy: true
75
85
  end
76
86
  end
@@ -79,16 +89,57 @@ module Chimpmunk
79
89
  # store mc:edit tag names
80
90
  #
81
91
  def self.editable_areas(*mc_edit_tags)
82
- @@mc_edit_tags = mc_edit_tags
92
+ class << self; attr_accessor :mc_edit_editable_areas; end
93
+ @mc_edit_editable_areas = mc_edit_tags
83
94
  end
84
95
 
85
96
  #
86
97
  # create has_many associations
87
98
  #
88
99
  def self.associated(association_type, *associations)
100
+ if association_type == :many
101
+ class << self; attr_accessor :mc_edit_has_many; end
102
+ @mc_edit_has_many = associations
103
+ else
104
+ class << self; attr_accessor :mc_edit_has_one; end
105
+ @mc_edit_has_one = associations
106
+ end
107
+
89
108
  associations.each do |association|
109
+ # TODO: figure out has_one attr_accessible
110
+ # TODO: test relations in rails 4
111
+ if association_type == :many
112
+ if Rails::VERSION::MAJOR == 3
113
+ attr_accessible[:default] << "#{association.to_s.singularize}_ids"
114
+
115
+ self.class_eval <<-EOF
116
+ after_save do
117
+ self.email_campaign_#{association}.destroy_all
118
+ self.#{association.to_s.singularize}_ids.each{|xid| self.email_campaign_#{association}.create(#{association.to_s.singularize}_id: xid)}
119
+ end
120
+ EOF
121
+ end
122
+ else
123
+ if Rails::VERSION::MAJOR == 3
124
+ singular = association.to_s.singularize
125
+ singular_id = "#{singular}_id"
126
+ attr_accessible[:default] << singular_id
127
+ attr_accessor singular_id.to_sym
128
+ self.class_eval <<-EOF
129
+ after_save do
130
+ if self.property_id
131
+ e = EmailCampaign#{singular.titleize}.where(email_campaign_id: self.id).first_or_initialize
132
+ e.#{singular_id} = self.#{singular_id}
133
+ e.save
134
+ end
135
+ end
136
+ EOF
137
+ end
138
+ end
139
+
90
140
  association_name = "email_campaign_#{association}".to_sym
91
- send("has_#{association_type}", association_name, foreign_key: 'email_campaign_id')
141
+ send("has_#{association_type}", association_name, foreign_key: 'email_campaign_id', dependent: :destroy)
142
+ send("has_#{association_type}", association, through: association_name )
92
143
  accepts_nested_attributes_for association_name, allow_destroy: true
93
144
  end
94
145
  end
@@ -198,24 +249,50 @@ module Chimpmunk
198
249
  sections = {}
199
250
 
200
251
  # headers
201
- @@mc_edit_headers.each do |tag|
202
- sections[tag] = self.send(tag).text
252
+ if headers = self.class.instance_variable_get('@mc_edit_headers')
253
+ headers.each do |tag|
254
+ sections[tag] = self.send(tag).text
255
+ end
203
256
  end
204
257
 
205
258
  # texts
206
- @@mc_edit_texts.each do |tag|
207
- sections[tag] = self.send(tag).text
259
+ if texts = self.class.instance_variable_get('@mc_edit_texts')
260
+ texts.each do |tag|
261
+ sections[tag] = self.send(tag).text
262
+ end
208
263
  end
209
264
 
210
265
  # images
211
- @@mc_edit_images.each do |tag|
212
- sections[tag] = "<img src='http://#{Chimpmunk.domain_name}#{self.send(tag).image.url}' />"
266
+ if images = self.class.instance_variable_get('@mc_edit_images')
267
+ images.each do |tag|
268
+ sections[tag] = "<img src='http://#{Chimpmunk.domain_name}#{self.send(tag).image.url}' />"
269
+ end
270
+ end
271
+
272
+ # has_many
273
+ if has_many = self.class.instance_variable_get('@mc_edit_has_many')
274
+ has_many.each do |tag|
275
+ if File.directory?("app/views/chimpmunk") && !Dir["app/views/chimpmunk/_#{tag}**"].empty?
276
+ sections[tag] = action_view.render "chimpmunk/#{tag}", campaign: self, tag.to_sym => self.send(tag)
277
+ end
278
+ end
279
+ end
280
+
281
+ # has_one
282
+ if has_one = self.class.instance_variable_get('@mc_edit_has_one')
283
+ has_one.each do |tag|
284
+ if File.directory?("app/views/chimpmunk") && !Dir["app/views/chimpmunk/_#{tag}**"].empty?
285
+ sections[tag] = action_view.render "chimpmunk/#{tag}", campaign: self, tag.to_sym => self.send(tag)
286
+ end
287
+ end
213
288
  end
214
289
 
215
290
  # editable areas (partials)
216
- @@mc_edit_tags.each do |tag|
217
- if File.directory?("app/views/chimpmunk") && !Dir["app/views/chimpmunk/_#{tag}**"].empty?
218
- sections[tag] = action_view.render "chimpmunk/#{tag}", campaign: self
291
+ if editable_areas = self.class.instance_variable_get('@mc_edit_editable_areas')
292
+ editable_areas.each do |tag|
293
+ if File.directory?("app/views/chimpmunk") && !Dir["app/views/chimpmunk/_#{tag}**"].empty?
294
+ sections[tag] = action_view.render "chimpmunk/#{tag}", campaign: self
295
+ end
219
296
  end
220
297
  end
221
298
 
@@ -328,7 +405,7 @@ module Chimpmunk
328
405
  else
329
406
  opts[:options][:list_id] = self.email_list.try(:mailchimp_id)
330
407
  end
331
-
408
+
332
409
  response = Chimpmunk.mailchimp.campaigns.create(opts)
333
410
  if response["errors"].nil?
334
411
  self.skip_update_callbacks = true
@@ -338,48 +415,46 @@ module Chimpmunk
338
415
  end
339
416
  end
340
417
 
341
- if defined?(RailsAdmin)
342
-
343
- rails_admin do
344
- navigation_label 'Mailchimp'
418
+ rails_admin do
419
+ navigation_label 'Mailchimp'
345
420
 
346
- list do
347
- field :title
348
- field :email_list
349
- field :status
350
- field :emails_sent
351
- field :opened_percentage do
352
- label "Opened"
353
- end
354
- field :clicked_percentage do
355
- label "Clicked"
356
- end
357
- field :subject
358
- field :from_email
359
- field :from_name
421
+ list do
422
+ field :title
423
+ field :email_list
424
+ field :status
425
+ field :emails_sent
426
+ field :opened_percentage do
427
+ label "Opened"
360
428
  end
429
+ field :clicked_percentage do
430
+ label "Clicked"
431
+ end
432
+ field :subject
433
+ field :from_email
434
+ field :from_name
435
+ end
361
436
 
362
- edit do
363
- field :title
364
- field :email_list do
365
- inline_add false
366
- inline_edit false
367
- end
368
- field :email_list_group
369
- field :email_template do
370
- inline_add false
371
- inline_edit false
372
- end
373
- field :subject
374
- field :from_name do
375
- default_value 'FIXME'
376
- end
377
- field :from_email do
378
- default_value 'FIXME'
379
- end
380
- field :send_date
437
+ edit do
438
+ field :title
439
+ field :email_list do
440
+ inline_add false
441
+ inline_edit false
381
442
  end
443
+ field :email_list_group
444
+ field :email_template do
445
+ inline_add false
446
+ inline_edit false
447
+ end
448
+ field :subject
449
+ field :from_name do
450
+ default_value 'FIXME'
451
+ end
452
+ field :from_email do
453
+ default_value 'FIXME'
454
+ end
455
+ field :send_date
382
456
  end
383
- end
457
+ end if defined?(RailsAdmin)
458
+
384
459
  end
385
460
  end
@@ -14,6 +14,6 @@ module Chimpmunk
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end if defined?(RailsAdmin)
18
18
  end
19
19
  end
@@ -5,11 +5,17 @@ module Chimpmunk
5
5
  has_attached_file :image, styles: {original: '1000x1000>'}
6
6
  validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
7
7
 
8
+ attr_accessible :image if defined?(ActiveModel::MassAssignmentSecurity)
9
+
8
10
  rails_admin do
9
11
  visible false
10
12
  edit do
11
- field :image
13
+ field :image do
14
+ label do
15
+ bindings[:object].name
16
+ end
17
+ end
12
18
  end
13
- end
19
+ end if defined?(RailsAdmin)
14
20
  end
15
21
  end
@@ -3,6 +3,8 @@ module Chimpmunk
3
3
  class EmailCampaignText < ::ActiveRecord::Base
4
4
  belongs_to :email_campaign
5
5
 
6
+ attr_accessible :text if defined?(ActiveModel::MassAssignmentSecurity)
7
+
6
8
  rails_admin do
7
9
  visible false
8
10
  edit do
@@ -12,6 +14,6 @@ module Chimpmunk
12
14
  end
13
15
  end
14
16
  end
15
- end
17
+ end if defined?(RailsAdmin)
16
18
  end
17
19
  end
@@ -37,33 +37,29 @@ module Chimpmunk
37
37
 
38
38
  private
39
39
 
40
- if defined?(RailsAdmin)
40
+ rails_admin do
41
+ navigation_label 'Mailchimp'
41
42
 
42
- rails_admin do
43
- navigation_label 'Mailchimp'
44
-
45
- edit do
46
- field :mailchimp_id do
47
- label 'Mailchimp ID'
48
- read_only true
49
- end
50
- field :name do
51
- read_only true
52
- end
53
- field :default_from_name do
54
- read_only true
55
- end
56
- field :default_from_email do
57
- read_only true
58
- end
59
- field :default_subject do
60
- read_only true
61
- end
62
- field :email_list_groupings
43
+ edit do
44
+ field :mailchimp_id do
45
+ label 'Mailchimp ID'
46
+ read_only true
47
+ end
48
+ field :name do
49
+ read_only true
50
+ end
51
+ field :default_from_name do
52
+ read_only true
53
+ end
54
+ field :default_from_email do
55
+ read_only true
63
56
  end
57
+ field :default_subject do
58
+ read_only true
59
+ end
60
+ field :email_list_groupings
64
61
  end
65
-
66
- end
62
+ end if defined?(RailsAdmin)
67
63
 
68
64
  end
69
65
  end
@@ -69,30 +69,29 @@ module Chimpmunk
69
69
  )
70
70
  end
71
71
 
72
- if defined?(RailsAdmin)
73
- rails_admin do
74
- navigation_label 'Mailchimp'
75
- visible false
76
- edit do
77
- field :name
78
- field :email_subscribers do
79
- column_width 1200
80
- associated_collection_scope do
81
- form = bindings[:form]
82
- binding_object = bindings[:object]
83
- list = if form
84
- bindings[:form].options[:parent_builder].options[:parent_builder].object
85
- elsif binding_object
86
- binding_object.email_list_grouping.email_list
87
- end
88
-
89
- Proc.new { |scope|
90
- scope = scope.where(email_list_id: list.id, subscribed: true)
91
- } if list
72
+ rails_admin do
73
+ navigation_label 'Mailchimp'
74
+ visible false
75
+ edit do
76
+ field :name
77
+ field :email_subscribers do
78
+ column_width 1200
79
+ associated_collection_scope do
80
+ form = bindings[:form]
81
+ binding_object = bindings[:object]
82
+ list = if form
83
+ bindings[:form].options[:parent_builder].options[:parent_builder].object
84
+ elsif binding_object
85
+ binding_object.email_list_grouping.email_list
92
86
  end
87
+
88
+ Proc.new { |scope|
89
+ scope = scope.where(email_list_id: list.id, subscribed: true)
90
+ } if list
93
91
  end
94
92
  end
95
93
  end
96
- end
94
+ end if defined?(RailsAdmin)
95
+
97
96
  end
98
97
  end
@@ -86,17 +86,16 @@ module Chimpmunk
86
86
  end
87
87
  end
88
88
 
89
- if defined?(RailsAdmin)
90
- rails_admin do
91
- navigation_label 'Mailchimp'
92
- visible false
93
-
94
- edit do
95
- field :email_list
96
- field :name
97
- field :email_list_groups
98
- end
89
+ rails_admin do
90
+ navigation_label 'Mailchimp'
91
+ visible false
92
+
93
+ edit do
94
+ field :email_list
95
+ field :name
96
+ field :email_list_groups
99
97
  end
100
- end
98
+ end if defined?(RailsAdmin)
99
+
101
100
  end
102
101
  end
@@ -44,31 +44,30 @@ module Chimpmunk
44
44
 
45
45
  private
46
46
 
47
- if defined?(RailsAdmin)
48
- rails_admin do
49
- navigation_label 'Mailchimp'
50
- list do
51
- field :mailchimp_id
52
- field :first_name
53
- field :last_name
54
- field :email
55
- field :subscribed
56
- field :email_list
47
+ rails_admin do
48
+ navigation_label 'Mailchimp'
49
+ list do
50
+ field :mailchimp_id
51
+ field :first_name
52
+ field :last_name
53
+ field :email
54
+ field :subscribed
55
+ field :email_list
56
+ end
57
+ edit do
58
+ field :email_list do
59
+ inline_add false
60
+ inline_edit false
57
61
  end
58
- edit do
59
- field :email_list do
60
- inline_add false
61
- inline_edit false
62
- end
63
- field :mailchimp_id do
64
- label "Mailchimp ID"
65
- read_only true
66
- end
67
- field :first_name
68
- field :last_name
69
- field :email
62
+ field :mailchimp_id do
63
+ label "Mailchimp ID"
64
+ read_only true
70
65
  end
66
+ field :first_name
67
+ field :last_name
68
+ field :email
71
69
  end
72
- end
70
+ end if defined?(RailsAdmin)
71
+
73
72
  end
74
73
  end
@@ -13,42 +13,41 @@ module Chimpmunk
13
13
  #
14
14
  def self.refresh_email_templates
15
15
  Chimpmunk.mailchimp.templates.list()["user"].each do |template|
16
- EmailTemplate.find_or_create_by(
16
+ EmailTemplate.where(
17
17
  mailchimp_id: "#{template["id"]}",
18
18
  name: template["name"],
19
19
  layout: template["layout"],
20
20
  preview_image: template["preview_image"]
21
- )
21
+ ).first_or_create
22
22
  end
23
23
  end
24
24
 
25
25
  private
26
26
 
27
- if defined?(RailsAdmin)
28
- rails_admin do
29
- navigation_label 'Mailchimp'
30
- # visible false
31
- show do
32
- field :name
33
- field :layout
34
- field :preview_image do
35
- pretty_value do
36
- "<img src='#{value}' />".html_safe
37
- end
27
+ rails_admin do
28
+ navigation_label 'Mailchimp'
29
+ # visible false
30
+ show do
31
+ field :name
32
+ field :layout
33
+ field :preview_image do
34
+ pretty_value do
35
+ "<img src='#{value}' />".html_safe
38
36
  end
39
37
  end
40
- edit do
41
- field :mailchimp_id do
42
- read_only true
43
- end
44
- field :name do
45
- read_only true
46
- end
47
- field :preview_image do
48
- read_only :true
49
- end
38
+ end
39
+ edit do
40
+ field :mailchimp_id do
41
+ read_only true
42
+ end
43
+ field :name do
44
+ read_only true
45
+ end
46
+ field :preview_image do
47
+ read_only :true
50
48
  end
51
49
  end
52
- end
50
+ end if defined?(RailsAdmin)
51
+
53
52
  end
54
53
  end
@@ -1,3 +1,3 @@
1
1
  module Chimpmunk
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -134,7 +134,7 @@ describe Chimpmunk::EmailCampaign do
134
134
 
135
135
  describe 'editable areas' do
136
136
  it 'should have the correct editable areas' do
137
- expect(TestEmailCampaign.mc_edit_tags).to include(:first)
137
+ expect(TestEmailCampaign.mc_edit_editable_areas).to include(:first)
138
138
  end
139
139
  end
140
140
 
@@ -156,9 +156,22 @@ describe Chimpmunk::EmailCampaign do
156
156
  end
157
157
 
158
158
  describe 'refresh_email_campaign_stats' do
159
-
159
+ it 'should update the email campaign with the stats' do
160
+ @email_campaign.mailchimp_campaign_id = "1"
161
+ Chimpmunk::EmailCampaign.texts
162
+ Chimpmunk::EmailCampaign.headers
163
+ Chimpmunk::EmailCampaign.images
164
+ @email_campaign.save
165
+ expect{Chimpmunk::EmailCampaign.refresh_email_campaign_stats}.to change{@email_campaign.reload.emails_sent}.from(nil).to(100)
166
+ end
160
167
  end
161
168
  end
162
169
 
170
+ describe 'instance methods' do
171
+
172
+ end
173
+ describe 'send_campaign' do
174
+
175
+ end
163
176
  end
164
177
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH << '.' unless $LOAD_PATH.include?('.')
2
2
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
3
3
  require 'logger'
4
4
 
5
+ require 'rails'
5
6
  require 'active_record'
6
7
  require 'gibbon'
7
8
 
@@ -22,6 +23,10 @@ module Chimpmunk
22
23
  def self.mailchimp
23
24
  @mailchimp ||= ::Gibbon::API.new
24
25
  end
26
+
27
+ def self.domain_name
28
+ 'test.com'
29
+ end
25
30
  end
26
31
 
27
32
  # require 'rails'
@@ -24,16 +24,25 @@ def gibbon_stubs
24
24
  )
25
25
  allow_any_instance_of(Gibbon::APICategory).to receive(:list).with({status:"sent"}).and_return(
26
26
  {'data' => [
27
+ 'id' => '1',
28
+ 'summary' =>
27
29
  {
28
- 'title' => 'refreshed',
29
- 'type' => 'test',
30
- 'list_id' => 1,
31
- 'subject' => 'test subject',
32
- 'from_email' => 'new@from.test',
33
- 'from_name' => 'test name',
34
- 'template_id' => 1,
35
- 'id' => 99999
36
- }
37
- ]}
30
+ 'emails_sent' => 100,
31
+ 'unique_opens' => 100,
32
+ 'unique_clicked' => 100,
33
+ 'hard_bounces' => 100,
34
+ 'soft_bounces' => 100,
35
+ 'unsubscribes' => 100,
36
+ 'forwards' => 100,
37
+ 'forwards_opens' => 100,
38
+ 'opens' => 100,
39
+ 'last_open' => Time.now,
40
+ 'unique_opens' => 100,
41
+ 'non_unique_clicks' => 100,
42
+ 'users_who_clicked' => 100,
43
+ 'unique_likes' => 100,
44
+ 'facebook_likes' => 100
45
+ }]
46
+ }
38
47
  )
39
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chimpmunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Franken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -50,14 +50,28 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '4.1'
53
+ version: '3.4'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '4.1'
60
+ version: '3.4'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: bundler
63
77
  requirement: !ruby/object:Gem::Requirement