Skip to content

Commit

Permalink
Add mocks for tests where the MC key is actually set
Browse files Browse the repository at this point in the history
  • Loading branch information
simonv3 committed Jul 7, 2015
1 parent 02e4410 commit 09652d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
it 'should connect to mailchimp if mailing list and confirmed' do
stub_request(:post, "https://api.mailchimp.com/2.0/lists/list")
.to_return(:body => '{"total":1,"data":[{"id":"7ec999ba49","web_id":540717,"name":"OpenFarm Helpers","date_created":"2015-04-03 08:25:15","email_type_option":false,"use_awesomebar":true,"default_from_name":"The OpenFarm Team","default_from_email":"[email protected]","default_subject":"","default_language":"en","list_rating":0,"subscribe_url_short":"http:\/\/eepurl.com\/biTabv","subscribe_url_long":"http:\/\/openfarm.us8.list-manage.com\/subscribe?u=&id=7ec999ba49","beamer_address":"[email protected]","visibility":"pub","stats":{"member_count":24,"unsubscribe_count":0,"cleaned_count":0,"member_count_since_send":27,"unsubscribe_count_since_send":0,"cleaned_count_since_send":0,"campaign_count":0,"grouping_count":0,"group_count":0,"merge_var_count":1,"avg_sub_rate":0,"avg_unsub_rate":0,"target_sub_rate":0,"open_rate":0,"click_rate":0,"date_last_campaign":null},"modules":[]}],"errors":[]}')
# stub_request(:post, "https://us8.api.mailchimp.com/2.0/lists/list")
# .to_return(:body => '{"total":1,"data":[{"id":"7ec999ba49","web_id":540717,"name":"OpenFarm Helpers","date_created":"2015-04-03 08:25:15","email_type_option":false,"use_awesomebar":true,"default_from_name":"The OpenFarm Team","default_from_email":"[email protected]","default_subject":"","default_language":"en","list_rating":0,"subscribe_url_short":"http:\/\/eepurl.com\/biTabv","subscribe_url_long":"http:\/\/openfarm.us8.list-manage.com\/subscribe?u=&id=7ec999ba49","beamer_address":"[email protected]","visibility":"pub","stats":{"member_count":24,"unsubscribe_count":0,"cleaned_count":0,"member_count_since_send":27,"unsubscribe_count_since_send":0,"cleaned_count_since_send":0,"campaign_count":0,"grouping_count":0,"group_count":0,"merge_var_count":1,"avg_sub_rate":0,"avg_unsub_rate":0,"target_sub_rate":0,"open_rate":0,"click_rate":0,"date_last_campaign":null},"modules":[]}],"errors":[]}')
stub_request(:post, "https://us8.api.mailchimp.com/2.0/lists/list")
.to_return(:body => '{"total":1,"data":[{"id":"7ec999ba49","web_id":540717,"name":"OpenFarm Helpers","date_created":"2015-04-03 08:25:15","email_type_option":false,"use_awesomebar":true,"default_from_name":"The OpenFarm Team","default_from_email":"[email protected]","default_subject":"","default_language":"en","list_rating":0,"subscribe_url_short":"http:\/\/eepurl.com\/biTabv","subscribe_url_long":"http:\/\/openfarm.us8.list-manage.com\/subscribe?u=&id=7ec999ba49","beamer_address":"[email protected]","visibility":"pub","stats":{"member_count":24,"unsubscribe_count":0,"cleaned_count":0,"member_count_since_send":27,"unsubscribe_count_since_send":0,"cleaned_count_since_send":0,"campaign_count":0,"grouping_count":0,"group_count":0,"merge_var_count":1,"avg_sub_rate":0,"avg_unsub_rate":0,"target_sub_rate":0,"open_rate":0,"click_rate":0,"date_last_campaign":null},"modules":[]}],"errors":[]}')
stub_request(:post, "https://api.mailchimp.com/2.0/lists/subscribe")
.to_return(:body => '{"apikey":"","id":"7ec999ba49","email":{"email":"[email protected]"},"merge_vars":{"DNAME":"Alek Romaguera"},"double_optin":false,"update_existing":true}')
stub_request(:post, "https://us8.api.mailchimp.com/2.0/lists/subscribe")
.to_return(:body => '{"apikey":"","id":"7ec999ba49","email":{"email":"[email protected]"},"merge_vars":{"DNAME":"Alek Romaguera"},"double_optin":false,"update_existing":true}')
user = FactoryGirl.create(:confirmed_user)
user.mailing_list = true
user.save
Expand All @@ -28,8 +30,12 @@
# want to add fake sign-ups every time tests are run.
stub_request(:post, "https://api.mailchimp.com/2.0/lists/list")
.to_return(:body => '{"total":1,"data":[{"id":"7ec999ba49","web_id":540717,"name":"OpenFarm Helpers","date_created":"2015-04-03 08:25:15","email_type_option":false,"use_awesomebar":true,"default_from_name":"The OpenFarm Team","default_from_email":"[email protected]","default_subject":"","default_language":"en","list_rating":0,"subscribe_url_short":"http:\/\/eepurl.com\/biTabv","subscribe_url_long":"http:\/\/openfarm.us8.list-manage.com\/subscribe?u=&id=7ec999ba49","beamer_address":"[email protected]","visibility":"pub","stats":{"member_count":24,"unsubscribe_count":0,"cleaned_count":0,"member_count_since_send":27,"unsubscribe_count_since_send":0,"cleaned_count_since_send":0,"campaign_count":0,"grouping_count":0,"group_count":0,"merge_var_count":1,"avg_sub_rate":0,"avg_unsub_rate":0,"target_sub_rate":0,"open_rate":0,"click_rate":0,"date_last_campaign":null},"modules":[]}],"errors":[]}')
stub_request(:post, "https://us8.api.mailchimp.com/2.0/lists/list")
.to_return(:body => '{"total":1,"data":[{"id":"7ec999ba49","web_id":540717,"name":"OpenFarm Helpers","date_created":"2015-04-03 08:25:15","email_type_option":false,"use_awesomebar":true,"default_from_name":"The OpenFarm Team","default_from_email":"[email protected]","default_subject":"","default_language":"en","list_rating":0,"subscribe_url_short":"http:\/\/eepurl.com\/biTabv","subscribe_url_long":"http:\/\/openfarm.us8.list-manage.com\/subscribe?u=&id=7ec999ba49","beamer_address":"[email protected]","visibility":"pub","stats":{"member_count":24,"unsubscribe_count":0,"cleaned_count":0,"member_count_since_send":27,"unsubscribe_count_since_send":0,"cleaned_count_since_send":0,"campaign_count":0,"grouping_count":0,"group_count":0,"merge_var_count":1,"avg_sub_rate":0,"avg_unsub_rate":0,"target_sub_rate":0,"open_rate":0,"click_rate":0,"date_last_campaign":null},"modules":[]}],"errors":[]}')
stub_request(:post, "https://api.mailchimp.com/2.0/lists/subscribe")
.to_return(:body => '{"apikey":"","id":"7ec999ba49","email":{"email":"[email protected]"},"merge_vars":{"DNAME":"Alek Romaguera"},"double_optin":false,"update_existing":true}')
stub_request(:post, "https://us8.api.mailchimp.com/2.0/lists/subscribe")
.to_return(:body => '{"apikey":"","id":"7ec999ba49","email":{"email":"[email protected]"},"merge_vars":{"DNAME":"Alek Romaguera"},"double_optin":false,"update_existing":true}')
user = FactoryGirl.create(:confirmed_user)
user.help_list = true
user.save
Expand Down

0 comments on commit 09652d6

Please sign in to comment.