postal 0.1.5 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/postal.rb +5 -2
- data/lib/postal/content.rb +82 -0
- data/lib/postal/lmapi/lmapi.rb +10 -0
- data/lib/postal/lmapi/lmapi_driver.rb +1 -1
- data/lib/postal/mailing.rb +93 -58
- data/lib/postal/member.rb +18 -12
- data/postal.gemspec +10 -3
- data/test/content_test.rb +22 -0
- data/test/mailing_test.rb +15 -1
- data/test/member_test.rb +9 -1
- data/test/postal_suite.rb +1 -0
- metadata +5 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.2
|
data/lib/postal.rb
CHANGED
@@ -8,6 +8,7 @@ require 'postal/lmapi/lmapi.rb'
|
|
8
8
|
require 'postal/lmapi/lmapi_driver.rb'
|
9
9
|
require 'postal/lmapi/lmapi_mapping_registry.rb'
|
10
10
|
require 'postal/base'
|
11
|
+
require 'postal/content'
|
11
12
|
require 'postal/list'
|
12
13
|
require 'postal/member'
|
13
14
|
require 'postal/mailing'
|
@@ -20,14 +21,15 @@ module Postal
|
|
20
21
|
class CouldNotSendMailing < StandardError; end;
|
21
22
|
class WouldDeleteAllMembers < StandardError; end;
|
22
23
|
|
23
|
-
VERSION = '0.
|
24
|
+
VERSION = '0.2.2'
|
24
25
|
LOGGER = Logger.new(STDOUT)
|
25
26
|
|
26
27
|
DEFAULT_OPTIONS = { :debug => false }
|
27
28
|
|
28
29
|
@options = { :wsdl => nil,
|
29
30
|
:username => nil,
|
30
|
-
:password => nil
|
31
|
+
:password => nil,
|
32
|
+
:proxy => nil }
|
31
33
|
@driver = nil
|
32
34
|
|
33
35
|
attr_accessor :options
|
@@ -37,6 +39,7 @@ module Postal
|
|
37
39
|
unless @driver
|
38
40
|
@driver = Postal::Lmapi::Soap.new(@options[:wsdl])
|
39
41
|
@driver.options['protocol.http.basic_auth'] << [@options[:wsdl], @options[:username], @options[:password]]
|
42
|
+
@driver.options['protocol.http.proxy'] = @options[:proxy]
|
40
43
|
end
|
41
44
|
return @driver
|
42
45
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Postal
|
2
|
+
class Content
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def find_by_filter(*args)
|
7
|
+
unless args.find { |arg| arg.match(/ListName/) }
|
8
|
+
args << "ListName=#{Postal.options[:list_name]}"
|
9
|
+
end
|
10
|
+
if soap_contents = Postal.driver.selectContent(args)
|
11
|
+
contents = soap_contents.collect do |content|
|
12
|
+
puts content.inspect
|
13
|
+
Content.new(:content_id => content.contentID,
|
14
|
+
:date_created => content.dateCreated,
|
15
|
+
:description => content.description,
|
16
|
+
:doc_parts => content.docParts,
|
17
|
+
:doc_type => content.docType,
|
18
|
+
:header_from => content.headerFrom,
|
19
|
+
:header_to => content.headerTo,
|
20
|
+
:is_read_only => content.isReadOnly,
|
21
|
+
:is_template => content.isTemplate,
|
22
|
+
:list_name => content.listName,
|
23
|
+
:native_title => content.nativeTitle,
|
24
|
+
:site_name => content.siteName,
|
25
|
+
:title => content.title)
|
26
|
+
end
|
27
|
+
if contents.size == 1
|
28
|
+
return contents.first
|
29
|
+
else
|
30
|
+
return contents
|
31
|
+
end
|
32
|
+
else
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# really just an alias for find_by_filter but with no options
|
39
|
+
def find_all
|
40
|
+
find_by_filter
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
DEFAULT_ATTRIBUTES = {:content_id => nil,
|
47
|
+
:date_created => nil,
|
48
|
+
:description => nil,
|
49
|
+
:doc_parts => nil,
|
50
|
+
:doc_type => nil,
|
51
|
+
:header_from => nil,
|
52
|
+
:header_to => nil,
|
53
|
+
:is_read_only => nil,
|
54
|
+
:is_template => nil,
|
55
|
+
:list_name => nil,
|
56
|
+
:native_title => nil,
|
57
|
+
:site_name => nil,
|
58
|
+
:title => nil}
|
59
|
+
|
60
|
+
attr_accessor :content_id ,:date_created ,:description ,:doc_parts ,:doc_type ,:header_from ,:header_to ,:is_read_only ,:is_template ,:list_name ,:native_title ,:site_name ,:title
|
61
|
+
|
62
|
+
|
63
|
+
# Create a new member instance
|
64
|
+
def initialize(attributes={})
|
65
|
+
attributes = DEFAULT_ATTRIBUTES.merge(attributes)
|
66
|
+
@content_id = attributes[:content_id]
|
67
|
+
@date_created = attributes[:date_created]
|
68
|
+
@description = attributes[:description]
|
69
|
+
@doc_parts = attributes[:doc_parts]
|
70
|
+
@doc_type = attributes[:doc_type]
|
71
|
+
@header_from = attributes[:header_from]
|
72
|
+
@header_to = attributes[:header_to]
|
73
|
+
@is_read_only = attributes[:is_read_only]
|
74
|
+
@is_template = attributes[:is_template]
|
75
|
+
@list_name = attributes[:list_name]
|
76
|
+
@native_title = attributes[:native_title]
|
77
|
+
@site_name = attributes[:site_name]
|
78
|
+
@title = attributes[:title]
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
data/lib/postal/lmapi/lmapi.rb
CHANGED
@@ -48,6 +48,16 @@ module Postal
|
|
48
48
|
@from = from
|
49
49
|
@additionalHeaders = additionalHeaders
|
50
50
|
end
|
51
|
+
|
52
|
+
# This lets us initialize a new MailingStruct by passing in a SimpleMailingStruct
|
53
|
+
# mail = Postal::Lmapi::MailingStruct.new(content)
|
54
|
+
def [](method)
|
55
|
+
begin
|
56
|
+
self.send(method)
|
57
|
+
rescue
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
end
|
51
61
|
end
|
52
62
|
|
53
63
|
# {http://tempuri.org/ns1.xsd}MessageStruct
|
data/lib/postal/mailing.rb
CHANGED
@@ -3,6 +3,11 @@ module Postal
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
+
def import(content_id)
|
7
|
+
mail = Postal.driver.importContent(content_id)
|
8
|
+
return mail
|
9
|
+
end
|
10
|
+
|
6
11
|
end
|
7
12
|
|
8
13
|
|
@@ -32,7 +37,8 @@ module Postal
|
|
32
37
|
:title => nil,
|
33
38
|
:to => nil,
|
34
39
|
:track_opens => nil,
|
35
|
-
:rewrite_date_when_sent => nil
|
40
|
+
:rewrite_date_when_sent => nil,
|
41
|
+
:mailing => nil }
|
36
42
|
|
37
43
|
attr_accessor :additional_headers,
|
38
44
|
:attachments,
|
@@ -60,71 +66,65 @@ module Postal
|
|
60
66
|
:title,
|
61
67
|
:to,
|
62
68
|
:track_opens,
|
63
|
-
:rewrite_date_when_sent
|
69
|
+
:rewrite_date_when_sent,
|
70
|
+
:mailing
|
64
71
|
|
65
72
|
# Create a new mailing ready to send
|
66
73
|
def initialize(args={})
|
67
74
|
args = DEFAULT_ATTRIBUTES.merge(args)
|
68
|
-
|
69
|
-
@additional_headers = args[:additional_headers]
|
70
|
-
@attachments = args[:attachments]
|
71
|
-
@bypass_moderation = args[:bypass_moderation]
|
72
|
-
@campaign = args[:campaign]
|
73
|
-
@char_set_id = args[:char_set_id]
|
74
|
-
@detect_html = args[:detect_html]
|
75
|
-
@dont_attempt_after_date = args[:dont_attempt_after_date]
|
76
|
-
@enable_recovery = args[:enable_recovery]
|
77
|
-
@from = args[:from]
|
78
|
-
@html_message = args[:html_message]
|
79
|
-
@html_section_encoding = args[:html_section_encoding]
|
80
|
-
@is_html_section_encoded = args[:is_html_section_encoded]
|
81
|
-
@is_text_section_encoded = args[:is_text_section_encoded]
|
75
|
+
|
82
76
|
@list_name = args[:list_name] || Postal.options[:list_name]
|
83
|
-
@
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
77
|
+
@to = args[:to]
|
78
|
+
|
79
|
+
if args[:mailing].nil?
|
80
|
+
@additional_headers = args[:additional_headers]
|
81
|
+
@attachments = args[:attachments]
|
82
|
+
@bypass_moderation = args[:bypass_moderation]
|
83
|
+
@campaign = args[:campaign]
|
84
|
+
@char_set_id = args[:char_set_id]
|
85
|
+
@detect_html = args[:detect_html]
|
86
|
+
@dont_attempt_after_date = args[:dont_attempt_after_date]
|
87
|
+
@enable_recovery = args[:enable_recovery]
|
88
|
+
@from = args[:from]
|
89
|
+
@html_message = args[:html_message]
|
90
|
+
@html_section_encoding = args[:html_section_encoding]
|
91
|
+
@is_html_section_encoded = args[:is_html_section_encoded]
|
92
|
+
@is_text_section_encoded = args[:is_text_section_encoded]
|
93
|
+
@recency_number_of_mailings = args[:recency_number_of_mailings]
|
94
|
+
@recency_which = args[:recency_which]
|
95
|
+
@reply_to = args[:reply_to]
|
96
|
+
@resend_after_days = args[:resend_after_days]
|
97
|
+
@sample_size = args[:sample_size]
|
98
|
+
@scheduled_mailing_date = args[:scheduled_mailing_date]
|
99
|
+
@subject = args[:subject]
|
100
|
+
@text_message = args[:text_message]
|
101
|
+
@text_section_encoding = args[:text_section_encoding]
|
102
|
+
@title = args[:title]
|
103
|
+
@to = args[:to]
|
104
|
+
@track_opens = args[:track_opens]
|
105
|
+
@rewrite_date_when_sent = args[:rewrite_date_when_sent]
|
106
|
+
@mailing = args[:mailing]
|
107
|
+
else
|
108
|
+
@subject = args[:mailing].subject
|
109
|
+
@is_html_section_encoded = args[:mailing].isHtmlSectionEncoded
|
110
|
+
@html_section_encoding = args[:mailing].htmlSectionEncoding
|
111
|
+
@html_message = args[:mailing].htmlMessage
|
112
|
+
@char_set_id = args[:mailing].charSetID
|
113
|
+
@is_text_section_encoded = args[:mailing].isTextSectionEncoded
|
114
|
+
@text_section_encoding = args[:mailing].textSectionEncoding
|
115
|
+
@title = args[:mailing].title
|
116
|
+
@text_message = args[:mailing].textMessage
|
117
|
+
@attachments = args[:mailing].attachments
|
118
|
+
@from = args[:mailing].from
|
119
|
+
@additional_headers = args[:mailing].additionalHeaders
|
120
|
+
@mailing = args[:mailing]
|
121
|
+
end
|
96
122
|
end
|
97
123
|
|
98
124
|
|
99
125
|
# Send the mailing
|
100
126
|
def send
|
101
127
|
if valid?
|
102
|
-
mail = Postal::Lmapi::MailingStruct.new(:additionalHeaders => @additional_headers,
|
103
|
-
:attachments => @attachments,
|
104
|
-
:bypassModeration => @bypass_moderation,
|
105
|
-
:campaign => @campaign,
|
106
|
-
:charSetID => @char_set_id,
|
107
|
-
:detectHtml => @detect_html,
|
108
|
-
:dontAttemptAfterDate => @dont_attempt_after_date,
|
109
|
-
:enableRecovery => @enable_recovery,
|
110
|
-
:from => @from,
|
111
|
-
:htmlMessage => @html_message,
|
112
|
-
:htmlSectionEncoding => @html_section_encoding,
|
113
|
-
:isHtmlSectionEncoded => @is_html_section_encoded,
|
114
|
-
:isTextSectionEncoded => @is_text_section_encoded,
|
115
|
-
:listName => @list_name,
|
116
|
-
:recencyNumberOfMailings => @recency_number_of_mailings,
|
117
|
-
:recencyWhich => @recency_which,
|
118
|
-
:replyTo => @reply_to,
|
119
|
-
:resendAfterDays => @resend_after_days,
|
120
|
-
:sampleSize => @sample_size,
|
121
|
-
:scheduledMailingDate => @scheduled_mailing_date,
|
122
|
-
:subject => @subject,
|
123
|
-
:textMessage => @text_message,
|
124
|
-
:textSectionEncoding => @text_section_encoding,
|
125
|
-
:title => @title,
|
126
|
-
:trackOpens => @track_opens,
|
127
|
-
:rewriteDateWhenSent => @rewrite_date_when_sent )
|
128
128
|
|
129
129
|
# are we sending to a list of email addresses or member ids
|
130
130
|
case @to.to_a.first
|
@@ -135,9 +135,44 @@ module Postal
|
|
135
135
|
emails = []
|
136
136
|
member_ids = @to.to_a
|
137
137
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
|
139
|
+
if @mailing.nil?
|
140
|
+
mail = Postal::Lmapi::MailingStruct.new(:additionalHeaders => @additional_headers,
|
141
|
+
:attachments => @attachments,
|
142
|
+
:bypassModeration => @bypass_moderation,
|
143
|
+
:campaign => @campaign,
|
144
|
+
:charSetID => @char_set_id,
|
145
|
+
:detectHtml => @detect_html,
|
146
|
+
:dontAttemptAfterDate => @dont_attempt_after_date,
|
147
|
+
:enableRecovery => @enable_recovery,
|
148
|
+
:from => @from,
|
149
|
+
:htmlMessage => @html_message,
|
150
|
+
:htmlSectionEncoding => @html_section_encoding,
|
151
|
+
:isHtmlSectionEncoded => @is_html_section_encoded,
|
152
|
+
:isTextSectionEncoded => @is_text_section_encoded,
|
153
|
+
:listName => @list_name,
|
154
|
+
:recencyNumberOfMailings => @recency_number_of_mailings,
|
155
|
+
:recencyWhich => @recency_which,
|
156
|
+
:replyTo => @reply_to,
|
157
|
+
:resendAfterDays => @resend_after_days,
|
158
|
+
:sampleSize => @sample_size,
|
159
|
+
:scheduledMailingDate => @scheduled_mailing_date,
|
160
|
+
:subject => @subject,
|
161
|
+
:textMessage => @text_message,
|
162
|
+
:textSectionEncoding => @text_section_encoding,
|
163
|
+
:title => @title,
|
164
|
+
# :to => @to,
|
165
|
+
:trackOpens => @track_opens,
|
166
|
+
:rewriteDateWhenSent => @rewrite_date_when_sent )
|
167
|
+
|
168
|
+
return Postal.driver.sendMailingDirect(emails,member_ids,mail)
|
169
|
+
else
|
170
|
+
mail = Postal::Lmapi::MailingStruct.new(@mailing)
|
171
|
+
mail.listName = @list_name || Postal.options[:list_name]
|
172
|
+
return Postal.driver.sendMailingDirect(emails,member_ids,mail)
|
173
|
+
end
|
174
|
+
|
175
|
+
else # mail wasn't valid
|
141
176
|
return false
|
142
177
|
end
|
143
178
|
end
|
data/lib/postal/member.rb
CHANGED
@@ -8,16 +8,7 @@ module Postal
|
|
8
8
|
args << "ListName=#{Postal.options[:list_name]}"
|
9
9
|
end
|
10
10
|
if soap_members = Postal.driver.selectMembers(args)
|
11
|
-
|
12
|
-
demographics = {}
|
13
|
-
member.demographics.each { |demo| demographics.merge!({ demo.name.to_sym => demo.value }) }
|
14
|
-
Member.new(:email => member.emailAddress, :name => member.fullName, :id => member.memberID, :list_name => member.listName, :demographics => demographics)
|
15
|
-
end
|
16
|
-
if members.size == 1
|
17
|
-
return members.first
|
18
|
-
else
|
19
|
-
return members
|
20
|
-
end
|
11
|
+
return parse_members(soap_members)
|
21
12
|
else
|
22
13
|
return nil
|
23
14
|
end
|
@@ -52,7 +43,8 @@ module Postal
|
|
52
43
|
member_id = 0
|
53
44
|
|
54
45
|
begin
|
55
|
-
return
|
46
|
+
return find_by_filter("EmailAddress=#{email}")
|
47
|
+
# return Postal.driver.getMemberID(Postal::Lmapi::SimpleMemberStruct.new(list_name,member_id,email))
|
56
48
|
rescue SOAP::FaultError
|
57
49
|
return nil
|
58
50
|
end
|
@@ -61,7 +53,8 @@ module Postal
|
|
61
53
|
|
62
54
|
def find_by_id(args,options)
|
63
55
|
member_id = args.first
|
64
|
-
return
|
56
|
+
return find_by_filter("MemberID=#{member_id}")
|
57
|
+
# return Postal.driver.getEmailFromMemberID(member_id)
|
65
58
|
end
|
66
59
|
|
67
60
|
|
@@ -77,6 +70,19 @@ module Postal
|
|
77
70
|
end
|
78
71
|
end
|
79
72
|
|
73
|
+
def parse_members(raw)
|
74
|
+
members = raw.collect do |member|
|
75
|
+
demographics = {}
|
76
|
+
member.demographics.each { |demo| demographics.merge!({ demo.name.to_sym => demo.value }) }
|
77
|
+
Member.new(:email => member.emailAddress, :name => member.fullName, :id => member.memberID, :list_name => member.listName, :demographics => demographics)
|
78
|
+
end
|
79
|
+
if members.size == 1
|
80
|
+
return members.first
|
81
|
+
else
|
82
|
+
return members
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
80
86
|
end
|
81
87
|
|
82
88
|
DEFAULT_ATTRIBUTES = { :id => nil, :email => nil, :name => nil, :list_name => nil, :demographics => {} }
|
data/postal.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{postal}
|
5
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.2"
|
6
9
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Rob Cameron"]
|
9
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-11-19}
|
10
13
|
s.description = %q{Lyris is an enterprise email service. Postal makes it easy for Ruby to talk to Lyris's API.}
|
11
14
|
s.email = %q{cannikinn@gmail.com}
|
12
15
|
s.extra_rdoc_files = [
|
@@ -22,6 +25,7 @@ Gem::Specification.new do |s|
|
|
22
25
|
"VERSION",
|
23
26
|
"lib/postal.rb",
|
24
27
|
"lib/postal/base.rb",
|
28
|
+
"lib/postal/content.rb",
|
25
29
|
"lib/postal/list.rb",
|
26
30
|
"lib/postal/lmapi/lmapi.rb",
|
27
31
|
"lib/postal/lmapi/lmapi_driver.rb",
|
@@ -29,6 +33,7 @@ Gem::Specification.new do |s|
|
|
29
33
|
"lib/postal/mailing.rb",
|
30
34
|
"lib/postal/member.rb",
|
31
35
|
"postal.gemspec",
|
36
|
+
"test/content_test.rb",
|
32
37
|
"test/list_test.rb",
|
33
38
|
"test/lmapiClient.rb",
|
34
39
|
"test/lyris_sample.yml",
|
@@ -43,7 +48,8 @@ Gem::Specification.new do |s|
|
|
43
48
|
s.rubygems_version = %q{1.3.5}
|
44
49
|
s.summary = %q{Gem for talking to the Lyris API}
|
45
50
|
s.test_files = [
|
46
|
-
"test/
|
51
|
+
"test/content_test.rb",
|
52
|
+
"test/list_test.rb",
|
47
53
|
"test/lmapiClient.rb",
|
48
54
|
"test/mailing_test.rb",
|
49
55
|
"test/member_test.rb",
|
@@ -64,3 +70,4 @@ Gem::Specification.new do |s|
|
|
64
70
|
s.add_dependency(%q<soap4r>, [">= 1.5.8"])
|
65
71
|
end
|
66
72
|
end
|
73
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ContentTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
@config = nil
|
6
|
+
|
7
|
+
def setup
|
8
|
+
load_config
|
9
|
+
Postal.options[:list_name] = 'active-casting'
|
10
|
+
Postal.options[:proxy] = "http://localhost:8888/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_selecting_all_content
|
14
|
+
content = Postal::Content.find_all
|
15
|
+
assert_not_nil content
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_finding_content_by_filter
|
19
|
+
assert_not_nil content = Postal::Content.find_by_filter()
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/test/mailing_test.rb
CHANGED
@@ -6,6 +6,7 @@ class MailingTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
load_config
|
9
|
+
Postal.options[:proxy] = "http://localhost:8888/"
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_can_send_valid_mailing
|
@@ -49,7 +50,7 @@ class MailingTest < Test::Unit::TestCase
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def test_cannot_send_invalid_mailing
|
52
|
-
mail = Postal::Mailing.new( :to => @config['
|
53
|
+
mail = Postal::Mailing.new( :to => @config['email_in_list'],
|
53
54
|
:html_message => "<p>Test from Postal at #{Time.now.to_s}</p>",
|
54
55
|
:from => @config['from'] )
|
55
56
|
assert !mail.valid?
|
@@ -57,4 +58,17 @@ class MailingTest < Test::Unit::TestCase
|
|
57
58
|
assert_raises(Postal::CouldNotSendMailing) { mail.send! }
|
58
59
|
end
|
59
60
|
|
61
|
+
def test_can_import_content
|
62
|
+
assert mail = Postal::Mailing.import(@config['content_id'])
|
63
|
+
assert_equal @config['content_subject'], mail.subject
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_can_send_mailing_from_import
|
67
|
+
content = Postal::Mailing.import(@config['content_id'])
|
68
|
+
mailing = Postal::Mailing.new(:to => @config['email_in_list'],
|
69
|
+
:mailing => content)
|
70
|
+
assert mailing.valid?
|
71
|
+
assert mailing.send!
|
72
|
+
end
|
73
|
+
|
60
74
|
end
|
data/test/member_test.rb
CHANGED
@@ -40,6 +40,7 @@ class MemberTest < Test::Unit::TestCase
|
|
40
40
|
def test_can_update_user_demographics_after_creation
|
41
41
|
new_member = Postal::Member.create(:email => "john.doe#{rand(1000000)}@anonymous.com", :name => "John Doe")
|
42
42
|
assert new_member.update_attributes(:field_0 => 'Baseball')
|
43
|
+
assert updated_user = Postal::Member.find(new_member.email)
|
43
44
|
end
|
44
45
|
|
45
46
|
def test_can_create_user_and_demographics_at_creation
|
@@ -79,11 +80,18 @@ class MemberTest < Test::Unit::TestCase
|
|
79
80
|
assert !Postal::Member.find(new_member.email)
|
80
81
|
end
|
81
82
|
|
82
|
-
def
|
83
|
+
def test_can_create_find_and_update_member_by_filter
|
83
84
|
Postal::Member.create(:email => "john.doe#{rand(1000000)}@anonymous.com", :name => "John Doe")
|
84
85
|
assert member = Postal::Member.find_by_filter('EmailAddress like john.doe%')
|
85
86
|
assert member.update_attributes(:field_0 => 'Baseball')
|
86
87
|
assert_equal Postal::Member.find_by_filter('EmailAddress like john.doe%').demographics[:field_0], 'Baseball'
|
87
88
|
end
|
88
89
|
|
90
|
+
def test_can_create_find_and_update_member_by_id
|
91
|
+
new_member = Postal::Member.create(:email => "john.doe#{rand(1000000)}@anonymous.com", :name => "John Doe")
|
92
|
+
assert member = Postal::Member.find(new_member.id)
|
93
|
+
assert member.update_attributes(:field_0 => 'Baseball')
|
94
|
+
assert_equal Postal::Member.find(new_member.email).demographics[:field_0], 'Baseball'
|
95
|
+
end
|
96
|
+
|
89
97
|
end
|
data/test/postal_suite.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Cameron
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- VERSION
|
41
41
|
- lib/postal.rb
|
42
42
|
- lib/postal/base.rb
|
43
|
+
- lib/postal/content.rb
|
43
44
|
- lib/postal/list.rb
|
44
45
|
- lib/postal/lmapi/lmapi.rb
|
45
46
|
- lib/postal/lmapi/lmapi_driver.rb
|
@@ -47,6 +48,7 @@ files:
|
|
47
48
|
- lib/postal/mailing.rb
|
48
49
|
- lib/postal/member.rb
|
49
50
|
- postal.gemspec
|
51
|
+
- test/content_test.rb
|
50
52
|
- test/list_test.rb
|
51
53
|
- test/lmapiClient.rb
|
52
54
|
- test/lyris_sample.yml
|
@@ -83,6 +85,7 @@ signing_key:
|
|
83
85
|
specification_version: 3
|
84
86
|
summary: Gem for talking to the Lyris API
|
85
87
|
test_files:
|
88
|
+
- test/content_test.rb
|
86
89
|
- test/list_test.rb
|
87
90
|
- test/lmapiClient.rb
|
88
91
|
- test/mailing_test.rb
|