added catarse_monkeymail to improve the mailchimp integration
Esse commit está contido em:
+1
-1
@@ -54,7 +54,7 @@ gem 'ezcrypto'
|
||||
gem 'pundit'
|
||||
|
||||
# Email marketing
|
||||
gem 'catarse_mailchimp', git: 'git://github.com/catarse/catarse_mailchimp', ref: '2ed4f39'
|
||||
gem 'catarse_monkeymail'
|
||||
|
||||
# HTML manipulation and formatting
|
||||
gem 'formtastic', '~> 2.2.1'
|
||||
|
||||
+7
-14
@@ -7,15 +7,6 @@ GIT
|
||||
jquery-rails
|
||||
rails (~> 4)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/catarse/catarse_mailchimp
|
||||
revision: 2ed4f3931dfa292e5c1c62619772f04e41c68629
|
||||
ref: 2ed4f39
|
||||
specs:
|
||||
catarse_mailchimp (0.0.1)
|
||||
mailchimp
|
||||
supermodel
|
||||
|
||||
GIT
|
||||
remote: git://github.com/catarse/moip-ruby.git
|
||||
revision: c0225ad71645cd1df35dafa1e45c9f092b3abb9e
|
||||
@@ -94,6 +85,9 @@ GEM
|
||||
enumerate_it
|
||||
libxml-ruby (~> 2.6.0)
|
||||
rails (~> 4.0)
|
||||
catarse_monkeymail (0.0.1)
|
||||
mailchimp-api (~> 2.0.4)
|
||||
rails (~> 4.0.3)
|
||||
catarse_paypal_express (2.2.3)
|
||||
activemerchant (>= 1.34.0)
|
||||
rails (~> 4.0)
|
||||
@@ -228,8 +222,9 @@ GEM
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mailchimp (0.0.9)
|
||||
httparty
|
||||
mailchimp-api (2.0.4)
|
||||
excon (>= 0.16.0)
|
||||
json (>= 1.7.7)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.5.2)
|
||||
@@ -415,8 +410,6 @@ GEM
|
||||
activesupport (>= 3.0)
|
||||
sprockets (~> 2.8)
|
||||
state_machine (1.2.0)
|
||||
supermodel (0.1.4)
|
||||
activemodel (>= 3.0.0.beta)
|
||||
tag_helper (0.0.3)
|
||||
temple (0.6.7)
|
||||
term-ansicolor (1.2.2)
|
||||
@@ -464,8 +457,8 @@ DEPENDENCIES
|
||||
browser
|
||||
capybara (~> 2.1.0)
|
||||
carrierwave (~> 0.10.0)
|
||||
catarse_mailchimp!
|
||||
catarse_moip (~> 2.3.5)
|
||||
catarse_monkeymail
|
||||
catarse_paypal_express (= 2.2.3)
|
||||
catarse_settings_db
|
||||
chartkick
|
||||
|
||||
@@ -5,20 +5,6 @@ class User < ActiveRecord::Base
|
||||
# :validatable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :omniauthable
|
||||
begin
|
||||
# NOTE: Sync normal users on mailchimp
|
||||
sync_with_mailchimp subscribe_data: ->(user) {
|
||||
{ EMAIL: user.email, FNAME: user.name,
|
||||
CITY: (user.address_city||'outro / other'), STATE: (user.address_state||'outro / other') }
|
||||
},
|
||||
list_id: CatarseSettings[:mailchimp_list_id],
|
||||
subscribe_when: ->(user) { (user.newsletter_changed? && user.newsletter) || (user.newsletter && user.new_record?) },
|
||||
unsubscribe_when: ->(user) { user.newsletter_changed? && !user.newsletter },
|
||||
unsubscribe_email: ->(user) { user.email }
|
||||
|
||||
rescue Exception => e
|
||||
Rails.logger.info "-----> #{e.inspect}"
|
||||
end
|
||||
|
||||
delegate :display_name, :display_image, :short_name, :display_image_html,
|
||||
:medium_name, :display_credits, :display_total_of_contributions, :contributions_text, :twitter_link, :gravatar_url,
|
||||
|
||||
@@ -133,23 +133,6 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
end
|
||||
end
|
||||
|
||||
def sync_with_mailchimp(project)
|
||||
begin
|
||||
user = project.user
|
||||
mailchimp_params = { EMAIL: user.email, FNAME: user.name, CITY: user.address_city, STATE: user.address_state }
|
||||
|
||||
if project.successful?
|
||||
CatarseMailchimp::API.subscribe(mailchimp_params, CatarseSettings[:mailchimp_successful_projects_list])
|
||||
end
|
||||
|
||||
if project.failed?
|
||||
CatarseMailchimp::API.subscribe(mailchimp_params, CatarseSettings[:mailchimp_failed_projects_list])
|
||||
end
|
||||
rescue Exception => e
|
||||
Rails.logger.info "-----> #{e.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deliver_default_notification_for(project, notification_type)
|
||||
|
||||
@@ -38,7 +38,7 @@ module Catarse
|
||||
config.active_record.observers = [
|
||||
:contribution_observer, :user_observer, :channel_observer,
|
||||
:update_observer, :project_observer, :channel_post_observer,
|
||||
:mixpanel_observer
|
||||
:mixpanel_observer, '::CatarseMonkeymail::MonkeyProjectObserver',
|
||||
]
|
||||
|
||||
# Enable the asset pipeline
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
MAILCHIMP_API_KEY = CatarseSettings[:mailchimp_api_key]
|
||||
@@ -125,39 +125,6 @@ describe ProjectObserver do
|
||||
it("should notify the project owner"){ project.finish }
|
||||
end
|
||||
|
||||
describe "sync with mailchimp" do
|
||||
before do
|
||||
CatarseSettings[:mailchimp_successful_projects_list] = 'OwnerListId'
|
||||
CatarseSettings[:mailchimp_failed_projects_list] = 'UnsuccesfulListId'
|
||||
end
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, online_days: -7, goal: 10, state: 'online', user: user) }
|
||||
|
||||
context 'when project is successful' do
|
||||
before do
|
||||
create(:contribution, value: 15, state: 'confirmed', project: project)
|
||||
project.update_attributes state: 'waiting_funds'
|
||||
end
|
||||
|
||||
it 'subscribe project owner to successful projects mailchimp list' do
|
||||
CatarseMailchimp::API.should_receive(:subscribe).with({ EMAIL: user.email, FNAME: user.name,
|
||||
CITY: user.address_city, STATE: user.address_state }, 'OwnerListId')
|
||||
end
|
||||
|
||||
after { project.finish }
|
||||
end
|
||||
|
||||
context 'when project is unsuccesful' do
|
||||
it 'subscribe project owner to failed projects mailchimp list' do
|
||||
CatarseMailchimp::API.should_receive(:subscribe).with({ EMAIL: user.email, FNAME: user.name,
|
||||
CITY: user.address_city, STATE: user.address_state }, 'UnsuccesfulListId')
|
||||
end
|
||||
|
||||
after { project.finish }
|
||||
end
|
||||
end
|
||||
|
||||
describe "save_dates" do
|
||||
context "when project goes from in_analysis to rejected" do
|
||||
let(:project){ create(:project, state: 'in_analysis') }
|
||||
|
||||
@@ -80,14 +80,13 @@ RSpec.configure do |config|
|
||||
|
||||
# Stubs and configuration
|
||||
config.before(:each) do
|
||||
CatarseMailchimp::API.stub(:subscribe).and_return(true)
|
||||
CatarseMailchimp::API.stub(:unsubscribe).and_return(true)
|
||||
User.any_instance.stub(:subscribe_to_newsletter_list).and_return(true)
|
||||
User.any_instance.stub(:unsubscribe_to_newsletter_list).and_return(true)
|
||||
Project.any_instance.stub(:subscribe_to_list).and_return(true)
|
||||
Project.any_instance.stub(:store_image_url).and_return('http://www.store_image_url.com')
|
||||
ProjectObserver.any_instance.stub(:after_create)
|
||||
UserObserver.any_instance.stub(:after_create)
|
||||
Project.any_instance.stub(:download_video_thumbnail)
|
||||
CatarseMailchimp::API.stub(:subscribe)
|
||||
CatarseMailchimp::API.stub(:unsubscribe)
|
||||
Notification.stub(:notify)
|
||||
Notification.stub(:notify_once)
|
||||
Calendar.any_instance.stub(:fetch_events_from)
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário