contactology 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -2
- data/.rspec +0 -1
- data/.rvmrc +34 -23
- data/.travis.yml +9 -3
- data/CHANGELOG.markdown +46 -0
- data/Gemfile +0 -7
- data/README.markdown +5 -3
- data/contactology.gemspec +10 -10
- data/lib/contactology/version.rb +1 -1
- data/spec/cassettes/campaign/destroy.yml +293 -0
- data/spec/cassettes/campaign/find/failure.yml +45 -0
- data/spec/cassettes/campaign/find/success.yml +252 -0
- data/spec/cassettes/campaign/find_by_name/failure.yml +44 -0
- data/spec/cassettes/campaign/find_by_name/success.yml +252 -0
- data/spec/cassettes/campaign/preview.yml +135 -0
- data/spec/cassettes/campaigns/standard/create/failure.yml +127 -0
- data/spec/cassettes/campaigns/standard/create/invalid.yml +169 -0
- data/spec/cassettes/campaigns/standard/create/success.yml +209 -0
- data/spec/cassettes/campaigns/standard/send_campaign/failure.yml +374 -0
- data/spec/cassettes/campaigns/standard/send_campaign/failure_missing_attributes.yml +373 -0
- data/spec/cassettes/campaigns/standard/send_campaign/success.yml +374 -0
- data/spec/cassettes/campaigns/transactional/create/failure.yml +44 -0
- data/spec/cassettes/campaigns/transactional/create/success.yml +85 -0
- data/spec/cassettes/campaigns/transactional/send_campaign/failure.yml +127 -0
- data/spec/cassettes/campaigns/transactional/send_campaign/success.yml +208 -0
- data/spec/cassettes/contact/active.yml +127 -0
- data/spec/cassettes/contact/change_email/success.yml +210 -0
- data/spec/cassettes/contact/change_email/unknown.yml +45 -0
- data/spec/cassettes/contact/create.yml +127 -0
- data/spec/cassettes/contact/destroy.yml +85 -0
- data/spec/cassettes/contact/find/active.yml +127 -0
- data/spec/cassettes/contact/find/suppressed.yml +168 -0
- data/spec/cassettes/contact/find/unknown.yml +44 -0
- data/spec/cassettes/contact/lists/empty.yml +126 -0
- data/spec/cassettes/contact/lists/full.yml +333 -0
- data/spec/cassettes/contact/lists/unknown.yml +86 -0
- data/spec/cassettes/contact/suppress.yml +168 -0
- data/spec/cassettes/list/all.yml +168 -0
- data/spec/cassettes/list/create.yml +127 -0
- data/spec/cassettes/list/destroy.yml +210 -0
- data/spec/cassettes/list/find/success.yml +169 -0
- data/spec/cassettes/list/find/unknown.yml +45 -0
- data/spec/cassettes/list/import/success.yml +251 -0
- data/spec/cassettes/list/subscribe/success.yml +250 -0
- data/spec/cassettes/list/unsubscribe/success.yml +291 -0
- data/spec/cassettes/transactional_message/send_message/failure.yml +209 -0
- data/spec/cassettes/transactional_message/send_message/success.yml +208 -0
- data/spec/factories/campaigns.rb +18 -16
- data/spec/factories/contacts.rb +6 -2
- data/spec/factories/issues.rb +12 -8
- data/spec/factories/lists.rb +6 -2
- data/spec/factories/transactional_messages.rb +8 -4
- data/spec/models/contactology/campaign_spec.rb +16 -22
- data/spec/models/contactology/campaigns/standard_spec.rb +31 -27
- data/spec/models/contactology/campaigns/transactional_spec.rb +26 -16
- data/spec/models/contactology/contact_spec.rb +28 -35
- data/spec/models/contactology/issues_spec.rb +2 -2
- data/spec/models/contactology/list_spec.rb +12 -20
- data/spec/models/contactology/transactional_message_spec.rb +13 -15
- data/spec/spec_helper.rb +9 -5
- data/spec/support/factory_girl.rb +4 -18
- data/spec/support/vcr.rb +9 -6
- metadata +208 -177
- data/.infinity_test +0 -16
- data/.watchr +0 -36
- data/Changelog.markdown +0 -30
- data/spec/fixtures/net/campaign/destroy.yml +0 -248
- data/spec/fixtures/net/campaign/find/failure.yml +0 -36
- data/spec/fixtures/net/campaign/find/success.yml +0 -283
- data/spec/fixtures/net/campaign/find_by_name/failure.yml +0 -36
- data/spec/fixtures/net/campaign/find_by_name/success.yml +0 -283
- data/spec/fixtures/net/campaign/preview.yml +0 -181
- data/spec/fixtures/net/campaigns/standard/create/failure.yml +0 -106
- data/spec/fixtures/net/campaigns/standard/create/invalid.yml +0 -141
- data/spec/fixtures/net/campaigns/standard/create/success.yml +0 -176
- data/spec/fixtures/net/campaigns/standard/send_campaign/failure.yml +0 -316
- data/spec/fixtures/net/campaigns/standard/send_campaign/failure_missing_attributes.yml +0 -316
- data/spec/fixtures/net/campaigns/standard/send_campaign/success.yml +0 -316
- data/spec/fixtures/net/campaigns/transactional/create/failure.yml +0 -36
- data/spec/fixtures/net/campaigns/transactional/create/success.yml +0 -71
- data/spec/fixtures/net/campaigns/transactional/send_campaign/failure.yml +0 -106
- data/spec/fixtures/net/campaigns/transactional/send_campaign/success.yml +0 -176
- data/spec/fixtures/net/contact/active.yml +0 -106
- data/spec/fixtures/net/contact/change_email/success.yml +0 -176
- data/spec/fixtures/net/contact/change_email/unknown.yml +0 -36
- data/spec/fixtures/net/contact/create.yml +0 -106
- data/spec/fixtures/net/contact/destroy.yml +0 -141
- data/spec/fixtures/net/contact/find/active.yml +0 -106
- data/spec/fixtures/net/contact/find/suppressed.yml +0 -141
- data/spec/fixtures/net/contact/find/unknown.yml +0 -36
- data/spec/fixtures/net/contact/lists/empty.yml +0 -106
- data/spec/fixtures/net/contact/lists/full.yml +0 -246
- data/spec/fixtures/net/contact/lists/unknown.yml +0 -71
- data/spec/fixtures/net/contact/suppress.yml +0 -141
- data/spec/fixtures/net/list/all.yml +0 -141
- data/spec/fixtures/net/list/create.yml +0 -106
- data/spec/fixtures/net/list/destroy.yml +0 -176
- data/spec/fixtures/net/list/find/success.yml +0 -141
- data/spec/fixtures/net/list/find/unknown.yml +0 -36
- data/spec/fixtures/net/list/import/success.yml +0 -351
- data/spec/fixtures/net/list/subscribe/success.yml +0 -211
- data/spec/fixtures/net/list/unsubscribe/success.yml +0 -246
- data/spec/fixtures/net/transactional_message/send_message/failure.yml +0 -176
- data/spec/fixtures/net/transactional_message/send_message/success.yml +0 -176
- data/spec/requests/contacts_spec.rb +0 -6
data/spec/factories/contacts.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :contact, :class => Contactology::Contact do
|
5
|
+
email 'factory-contact@example.com'
|
6
|
+
|
7
|
+
initialize_with { new(attributes) }
|
8
|
+
end
|
5
9
|
end
|
data/spec/factories/issues.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :issue, :class => Contactology::Issue do
|
5
|
+
level ''
|
6
|
+
type 'SPAM'
|
7
|
+
text 'BODY: TVD_SPACE_RATIO'
|
8
|
+
message ''
|
9
|
+
context ''
|
10
|
+
col ''
|
11
|
+
deduction 29
|
12
|
+
|
13
|
+
initialize_with { new(attributes) }
|
14
|
+
end
|
11
15
|
end
|
data/spec/factories/lists.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :transactional_message, :class => Contactology::TransactionalMessage do
|
5
|
+
association :campaign, :factory => :transactional_campaign
|
6
|
+
contact { FactoryGirl.attributes_for :contact }
|
7
|
+
source 'Factory Created'
|
8
|
+
|
9
|
+
initialize_with { new(attributes) }
|
10
|
+
end
|
7
11
|
end
|
@@ -10,18 +10,16 @@ describe Contactology::Campaign do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context '.find' do
|
13
|
-
context 'for a known campaign' do
|
14
|
-
|
15
|
-
let(:
|
16
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list }
|
13
|
+
context 'for a known campaign', :vcr => {:cassette_name => 'campaign/find/success'} do
|
14
|
+
let(:list) { create :list }
|
15
|
+
let(:campaign) { create :standard_campaign, :recipients => list }
|
17
16
|
subject { Contactology::Campaign.find campaign.id }
|
18
17
|
after(:each) { list.destroy; campaign.destroy }
|
19
18
|
|
20
19
|
it { should be_a Contactology::Campaign }
|
21
20
|
end
|
22
21
|
|
23
|
-
context 'for an unknown campaign' do
|
24
|
-
use_vcr_cassette 'campaign/find/failure'
|
22
|
+
context 'for an unknown campaign', :vcr => {:cassette_name => 'campaign/find/failure'} do
|
25
23
|
subject { Contactology::Campaign.find 123456789 }
|
26
24
|
|
27
25
|
it { should be_nil }
|
@@ -29,10 +27,9 @@ describe Contactology::Campaign do
|
|
29
27
|
end
|
30
28
|
|
31
29
|
context '.find_by_name' do
|
32
|
-
context 'for a known campaign' do
|
33
|
-
|
34
|
-
let(:
|
35
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list, :name => 'test-find-by-name' }
|
30
|
+
context 'for a known campaign', :vcr => {:cassette_name => 'campaign/find_by_name/success'} do
|
31
|
+
let(:list) { create :list }
|
32
|
+
let(:campaign) { create :standard_campaign, :recipients => list, :name => 'test-find-by-name' }
|
36
33
|
after(:each) { list.destroy; campaign.destroy }
|
37
34
|
subject { Contactology::Campaign.find_by_name campaign.name }
|
38
35
|
|
@@ -40,32 +37,29 @@ describe Contactology::Campaign do
|
|
40
37
|
its(:name) { should == campaign.name }
|
41
38
|
end
|
42
39
|
|
43
|
-
context 'for an unknown campaign' do
|
44
|
-
use_vcr_cassette 'campaign/find_by_name/failure'
|
40
|
+
context 'for an unknown campaign', :vcr => {:cassette_name => 'campaign/find_by_name/failure'} do
|
45
41
|
subject { Contactology::Campaign.find_by_name 'unknown' }
|
46
42
|
|
47
43
|
it { should be_nil }
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
51
|
-
context '#destroy' do
|
52
|
-
|
53
|
-
let(:
|
54
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list }
|
47
|
+
context '#destroy', :vcr => {:cassette_name => 'campaign/destroy'} do
|
48
|
+
let(:list) { create :list }
|
49
|
+
let(:campaign) { create :standard_campaign, :recipients => list }
|
55
50
|
after(:each) { list.destroy }
|
56
51
|
|
57
52
|
subject { campaign.destroy }
|
58
53
|
|
59
|
-
it 'removes the campaign from Contactology' do
|
54
|
+
it 'removes the campaign from Contactology and returns true' do
|
55
|
+
# Combined specs for VCR recording consistency
|
60
56
|
expect { subject }.to change { Contactology::Campaign.find campaign.id }.to(nil)
|
57
|
+
should be_true
|
61
58
|
end
|
62
|
-
|
63
|
-
it { should be_true }
|
64
59
|
end
|
65
60
|
|
66
|
-
context '#preview' do
|
67
|
-
|
68
|
-
let(:campaign) { Factory :transactional_campaign }
|
61
|
+
context '#preview', :vcr => {:cassette_name => 'campaign/preview'} do
|
62
|
+
let(:campaign) { create :transactional_campaign }
|
69
63
|
after(:each) { campaign.destroy }
|
70
64
|
|
71
65
|
subject { campaign.preview }
|
@@ -4,9 +4,8 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Contactology::Campaigns::Standard do
|
6
6
|
context '.create' do
|
7
|
-
context 'when successful' do
|
8
|
-
|
9
|
-
let(:list) { Factory :list, :name => 'campaign-standard-create-success' }
|
7
|
+
context 'when successful', :vcr => {:cassette_name => 'campaigns/standard/create/success'} do
|
8
|
+
let(:list) { create :list, :name => 'campaign-standard-create-success' }
|
10
9
|
let(:campaign) { create_campaign :recipients => list }
|
11
10
|
after(:each) { list.destroy; campaign.destroy }
|
12
11
|
|
@@ -16,9 +15,8 @@ describe Contactology::Campaigns::Standard do
|
|
16
15
|
its(:id) { should_not be_nil }
|
17
16
|
end
|
18
17
|
|
19
|
-
context 'with invalid data' do
|
20
|
-
|
21
|
-
let(:list) { Factory :list, :name => 'campaign-standard-create-invalid' }
|
18
|
+
context 'with invalid data', :vcr => {:cassette_name => 'campaigns/standard/create/invalid'} do
|
19
|
+
let(:list) { create :list, :name => 'campaign-standard-create-invalid' }
|
22
20
|
let(:campaign) { create_campaign :sender_email => 'bad@example', :recipients => list }
|
23
21
|
after(:each) { list.destroy }
|
24
22
|
|
@@ -27,9 +25,8 @@ describe Contactology::Campaigns::Standard do
|
|
27
25
|
it { should be_false }
|
28
26
|
end
|
29
27
|
|
30
|
-
context 'with required attributes missing' do
|
31
|
-
|
32
|
-
let(:list) { Factory :list, :name => 'campaign-standard-create-failure' }
|
28
|
+
context 'with required attributes missing', :vcr => {:cassette_name => 'campaigns/standard/create/failure'} do
|
29
|
+
let(:list) { create :list, :name => 'campaign-standard-create-failure' }
|
33
30
|
let(:campaign) { create_campaign :name => nil, :recipients => list }
|
34
31
|
after(:each) { list.destroy }
|
35
32
|
|
@@ -42,11 +39,10 @@ describe Contactology::Campaigns::Standard do
|
|
42
39
|
end
|
43
40
|
|
44
41
|
context '#send_campaign' do
|
45
|
-
context 'when successful' do
|
46
|
-
|
47
|
-
let(:
|
48
|
-
let(:
|
49
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list }
|
42
|
+
context 'when successful', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/success'} do
|
43
|
+
let(:list) { create :list, :name => 'send-standard-campaign-success' }
|
44
|
+
let(:contact) { create :contact }
|
45
|
+
let(:campaign) { create :standard_campaign, :recipients => list }
|
50
46
|
|
51
47
|
before(:each) { list.subscribe contact }
|
52
48
|
after(:each) { list.destroy; contact.destroy; campaign.destroy }
|
@@ -58,11 +54,10 @@ describe Contactology::Campaigns::Standard do
|
|
58
54
|
its(:issues) { should be_empty }
|
59
55
|
end
|
60
56
|
|
61
|
-
context 'when unsuccessful (high spam score)' do
|
62
|
-
|
63
|
-
let(:
|
64
|
-
let(:
|
65
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list, :content => {'text' => 'OMG BUY VIAGRA'} }
|
57
|
+
context 'when unsuccessful (high spam score)', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/failure'} do
|
58
|
+
let(:list) { create :list, :name => 'send-standard-campaign-failure' }
|
59
|
+
let(:contact) { create :contact }
|
60
|
+
let(:campaign) { create :standard_campaign, :recipients => list, :content => {'text' => 'OMG BUY VIAGRA'} }
|
66
61
|
|
67
62
|
before(:each) { list.subscribe(contact) }
|
68
63
|
after(:each) { list.destroy; contact.destroy; campaign.destroy }
|
@@ -70,16 +65,25 @@ describe Contactology::Campaigns::Standard do
|
|
70
65
|
subject { campaign.send_campaign }
|
71
66
|
|
72
67
|
it { should be_instance_of Contactology::SendResult }
|
73
|
-
it { should_not be_successful }
|
74
|
-
its(:issues) { should_not be_empty }
|
75
68
|
its(:score) { should be < 100 }
|
69
|
+
|
70
|
+
it 'should not be successful' do
|
71
|
+
pending('This is incorrectly passing successfully on Contactology.') do
|
72
|
+
should_not be_successful
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should have reported issues' do
|
77
|
+
pending('This is incorrectly passing successfully on Contactology.') do
|
78
|
+
subject.issues.should_not be_empty
|
79
|
+
end
|
80
|
+
end
|
76
81
|
end
|
77
82
|
|
78
|
-
context 'when unsuccessful (attributes missing)' do
|
79
|
-
|
80
|
-
let(:
|
81
|
-
let(:
|
82
|
-
let(:campaign) { Factory :standard_campaign, :recipients => list }
|
83
|
+
context 'when unsuccessful (attributes missing)', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/failure_missing_attributes'} do
|
84
|
+
let(:list) { create :list, :name => 'send-standard-campaign-failure' }
|
85
|
+
let(:contact) { create :contact }
|
86
|
+
let(:campaign) { create :standard_campaign, :recipients => list }
|
83
87
|
|
84
88
|
before(:each) { list.subscribe(contact); campaign.id = nil }
|
85
89
|
after(:each) { list.destroy; contact.destroy; campaign.destroy }
|
@@ -108,6 +112,6 @@ describe Contactology::Campaigns::Standard do
|
|
108
112
|
|
109
113
|
|
110
114
|
def create_campaign(attributes = {})
|
111
|
-
Contactology::Campaigns::Standard.create
|
115
|
+
Contactology::Campaigns::Standard.create attributes_for(:standard_campaign).merge(attributes)
|
112
116
|
end
|
113
117
|
end
|
@@ -4,9 +4,8 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Contactology::Campaigns::Transactional do
|
6
6
|
context '.create' do
|
7
|
-
context 'when successful' do
|
8
|
-
|
9
|
-
let(:campaign) { Contactology::Campaigns::Transactional.create Factory.attributes_for(:transactional_campaign) }
|
7
|
+
context 'when successful', :vcr => {:cassette_name => 'campaigns/transactional/create/success'} do
|
8
|
+
let(:campaign) { Contactology::Campaigns::Transactional.create attributes_for(:transactional_campaign) }
|
10
9
|
after(:each) { campaign.destroy }
|
11
10
|
|
12
11
|
subject { campaign }
|
@@ -16,24 +15,36 @@ describe Contactology::Campaigns::Transactional do
|
|
16
15
|
its(:object_id) { should == campaign.object_id }
|
17
16
|
end
|
18
17
|
|
19
|
-
context 'when unsuccessful' do
|
20
|
-
|
21
|
-
let(:campaign) { Contactology::Campaigns::Transactional.create Factory.attributes_for(:transactional_campaign).merge(:content => {:text => 'bad'}) }
|
18
|
+
context 'when unsuccessful', :vcr => {:cassette_name => 'campaigns/transactional/create/failure'} do
|
19
|
+
let(:campaign) { Contactology::Campaigns::Transactional.create attributes_for(:transactional_campaign).merge(:content => {:text => 'bad'}) }
|
22
20
|
|
23
21
|
subject { campaign }
|
24
22
|
|
25
|
-
it
|
26
|
-
|
27
|
-
|
23
|
+
it 'returns a Contactology::SendResult' do
|
24
|
+
pending('This is incorrectly passing successfully on Contactology.') do
|
25
|
+
should be_kind_of Contactology::SendResult
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not be successful' do
|
30
|
+
pending('This is incorrectly passing successfully on Contactology.') do
|
31
|
+
should_not be_successful
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should contain issues' do
|
36
|
+
pending('This is incorrectly passing successfully on Contactology.') do
|
37
|
+
subject.issues.should_not be_empty
|
38
|
+
end
|
39
|
+
end
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
43
|
|
32
44
|
context '#send_campaign' do
|
33
|
-
context 'when successful' do
|
34
|
-
|
35
|
-
let(:
|
36
|
-
let(:campaign) { Factory :transactional_campaign }
|
45
|
+
context 'when successful', :vcr => {:cassette_name => 'campaigns/transactional/send_campaign/success'} do
|
46
|
+
let(:contact) { create :contact }
|
47
|
+
let(:campaign) { create :transactional_campaign }
|
37
48
|
|
38
49
|
after(:each) do
|
39
50
|
campaign.destroy
|
@@ -47,9 +58,8 @@ describe Contactology::Campaigns::Transactional do
|
|
47
58
|
its(:issues) { should be_empty }
|
48
59
|
end
|
49
60
|
|
50
|
-
context 'when unsuccessful' do
|
51
|
-
|
52
|
-
let(:campaign) { Factory :transactional_campaign }
|
61
|
+
context 'when unsuccessful', :vcr => {:cassette_name => 'campaigns/transactional/send_campaign/failure'} do
|
62
|
+
let(:campaign) { create :transactional_campaign }
|
53
63
|
after(:each) { campaign.destroy }
|
54
64
|
|
55
65
|
subject { campaign.send_campaign(Struct.new(:email).new('bad')) }
|
@@ -3,8 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Contactology::Contact do
|
6
|
-
context '.create' do
|
7
|
-
use_vcr_cassette 'contact/create'
|
6
|
+
context '.create', :vcr => {:cassette_name => 'contact/create'} do
|
8
7
|
|
9
8
|
it 'raises an ArgumentError without an :email given' do
|
10
9
|
expect {
|
@@ -17,20 +16,19 @@ describe Contactology::Contact do
|
|
17
16
|
subject { contact }
|
18
17
|
after(:each) { contact.destroy }
|
19
18
|
|
20
|
-
it 'creates a new contact' do
|
21
|
-
|
19
|
+
it 'creates a new contact and returns a Contactology::Contact' do
|
20
|
+
# Combined specs for VCR recording consistency.
|
21
|
+
should be_a Contactology::Contact
|
22
22
|
Contactology::Contact.find('created@example.com').should_not be_nil
|
23
23
|
end
|
24
24
|
|
25
|
-
it { should be_kind_of Contactology::Contact }
|
26
25
|
its(:email) { should eql 'created@example.com' }
|
27
26
|
its(:active?) { should be_true }
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
context '.find' do
|
32
|
-
context 'for a matching, active contact' do
|
33
|
-
use_vcr_cassette 'contact/find/active'
|
31
|
+
context 'for a matching, active contact', :vcr => {:cassette_name => 'contact/find/active'} do
|
34
32
|
let(:contact) { Contactology::Contact.create(:email => 'found@example.com') }
|
35
33
|
after(:each) { contact.destroy }
|
36
34
|
subject { Contactology::Contact.find(contact.email) }
|
@@ -40,27 +38,29 @@ describe Contactology::Contact do
|
|
40
38
|
it { should be_active }
|
41
39
|
end
|
42
40
|
|
43
|
-
context 'for a matching, suppressed contact' do
|
44
|
-
|
45
|
-
let(:contact) { Contactology::Contact.create(:email => 'found-suppressed@example.com') }
|
41
|
+
context 'for a matching, suppressed contact', :vcr => {:cassette_name => 'contact/find/suppressed', :match_requests_on => [:api_uri]} do
|
42
|
+
let(:contact) { Contactology::Contact.create(:email => "found-suppressed-%0.2f-%d@example.com" % [Time.now.to_f, rand(100_000)]) }
|
46
43
|
before(:each) { contact.suppress }
|
47
44
|
after(:each) { contact.destroy }
|
48
45
|
subject { Contactology::Contact.find('found-suppressed@example.com') }
|
49
46
|
|
50
47
|
it { should be_kind_of Contactology::Contact }
|
51
48
|
its(:email) { should eql 'found-suppressed@example.com' }
|
52
|
-
|
49
|
+
|
50
|
+
it 'should be suppressed' do
|
51
|
+
pending("Contactology is incorrectly indicating that the user is suppressed, but leaving them active.") do
|
52
|
+
should be_suppressed
|
53
|
+
end
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
|
-
context 'for an unknown email' do
|
56
|
-
use_vcr_cassette 'contact/find/unknown'
|
57
|
+
context 'for an unknown email', :vcr => {:cassette_name => 'contact/find/unknown'} do
|
57
58
|
subject { Contactology::Contact.find('unknown@example.com') }
|
58
59
|
it { should be_nil }
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
context '#active?' do
|
63
|
-
use_vcr_cassette 'contact/active'
|
63
|
+
context '#active?', :vcr => {:cassette_name => 'contact/active'} do
|
64
64
|
let(:contact) do
|
65
65
|
Contactology::Contact.create :email => 'active@example.com'
|
66
66
|
Contactology::Contact.find 'active@example.com'
|
@@ -72,10 +72,9 @@ describe Contactology::Contact do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context '#change_email' do
|
75
|
-
context 'for a known contact' do
|
76
|
-
use_vcr_cassette 'contact/change_email/success'
|
75
|
+
context 'for a known contact', :vcr => {:cassette_name => 'contact/change_email/success', :match_requests_on => [:api_uri]} do
|
77
76
|
let(:contact) { Contactology::Contact.create :email => 'change-email-3@example.com' }
|
78
|
-
let(:new_email) {
|
77
|
+
let(:new_email) { "changed-%d-%d@example.com" % [Time.now.to_f, rand(100_000)] }
|
79
78
|
subject { contact.change_email new_email }
|
80
79
|
after(:each) { contact.destroy }
|
81
80
|
|
@@ -84,27 +83,25 @@ describe Contactology::Contact do
|
|
84
83
|
end
|
85
84
|
|
86
85
|
it { should be_true }
|
87
|
-
|
86
|
+
|
88
87
|
it 'updates the local contact email' do
|
89
88
|
expect { subject }.to change(contact, :email).to(new_email)
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
context 'for an unknown contact' do
|
94
|
-
use_vcr_cassette 'contact/change_email/unknown'
|
92
|
+
context 'for an unknown contact', :vcr => {:cassette_name => 'contact/change_email/unknown'} do
|
95
93
|
let(:contact) { Contactology::Contact.new(:email => 'unknown@example.com') }
|
96
94
|
subject { contact.change_email 'changefail@example.com' }
|
97
95
|
|
98
96
|
it { should be_false }
|
99
|
-
|
97
|
+
|
100
98
|
it 'does not update the local contact email' do
|
101
99
|
expect { subject }.to_not change(contact, :email)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
|
-
context '#destroy' do
|
107
|
-
use_vcr_cassette 'contact/destroy'
|
104
|
+
context '#destroy', :vcr => {:cassette_name => 'contact/destroy'} do
|
108
105
|
|
109
106
|
context 'when successful' do
|
110
107
|
let(:contact) { Contactology::Contact.create :email => 'destroy@example.com' }
|
@@ -119,8 +116,7 @@ describe Contactology::Contact do
|
|
119
116
|
end
|
120
117
|
|
121
118
|
context '#lists' do
|
122
|
-
context 'for a known contact with subscription lists' do
|
123
|
-
use_vcr_cassette 'contact/lists/full'
|
119
|
+
context 'for a known contact with subscription lists', :vcr => {:cassette_name => 'contact/lists/full'} do
|
124
120
|
let(:contact) { Contactology::Contact.create :email => 'lists@example.com' }
|
125
121
|
let(:list) { Contactology::List.create :name => 'contact-list-test' }
|
126
122
|
before(:each) { list.subscribe contact.email }
|
@@ -128,16 +124,15 @@ describe Contactology::Contact do
|
|
128
124
|
|
129
125
|
subject { contact.lists }
|
130
126
|
|
131
|
-
it { should be_kind_of Enumerable }
|
132
|
-
it { should_not be_empty }
|
133
|
-
|
134
127
|
it 'contains the subscribed list' do
|
128
|
+
# Combined specs for VCR recording consistency.
|
129
|
+
should be_an Enumerable
|
130
|
+
should_not be_empty
|
135
131
|
subject.any? { |remote_list| remote_list.id == list.id }.should be_true
|
136
132
|
end
|
137
133
|
end
|
138
134
|
|
139
|
-
context 'for a known contact without subscription lists' do
|
140
|
-
use_vcr_cassette 'contact/lists/empty'
|
135
|
+
context 'for a known contact without subscription lists', :vcr => {:cassette_name => 'contact/lists/empty'} do
|
141
136
|
let(:contact) { Contactology::Contact.create :email => 'emptylists@example.com' }
|
142
137
|
subject { contact.lists }
|
143
138
|
after(:each) { contact.destroy }
|
@@ -146,8 +141,7 @@ describe Contactology::Contact do
|
|
146
141
|
it { should be_empty }
|
147
142
|
end
|
148
143
|
|
149
|
-
context 'for an unknown contact' do
|
150
|
-
use_vcr_cassette 'contact/lists/unknown'
|
144
|
+
context 'for an unknown contact', :vcr => {:cassette_name => 'contact/lists/unknown'} do
|
151
145
|
let(:contact) { Contactology::Contact.new :email => 'unknown@example.com' }
|
152
146
|
subject { contact.lists }
|
153
147
|
after(:each) { contact.destroy }
|
@@ -157,8 +151,7 @@ describe Contactology::Contact do
|
|
157
151
|
end
|
158
152
|
end
|
159
153
|
|
160
|
-
context '#suppress' do
|
161
|
-
use_vcr_cassette 'contact/suppress'
|
154
|
+
context '#suppress', :vcr => {:cassette_name => 'contact/suppress'} do
|
162
155
|
let(:contact) do
|
163
156
|
Contactology::Contact.create :email => 'suppressed@example.com'
|
164
157
|
Contactology::Contact.find 'suppressed@example.com'
|