better email infrastructure, email for profile comments, webapp format support

This commit is contained in:
Kyle Drake 2015-01-06 19:14:24 -08:00
parent 85fbfed910
commit d611a5a290
7 changed files with 167 additions and 7 deletions

View file

@ -1,13 +1,46 @@
require_relative './environment.rb'
require 'rack/test'
include Rack::Test::Methods
def app
Sinatra::Application
end
describe Site do
describe 'can_email' do
it 'should fail if send_emails is false' do
site = Fabricate :site
site.can_email?.must_equal true
site.update send_emails: false
site.can_email?.must_equal false
site.can_email?(:send_comment_emails).must_equal false
site.update send_emails: true
site.can_email?(:send_comment_emails).must_equal true
site.update send_comment_emails: false
site.can_email?(:send_comment_emails).must_equal false
end
end
describe 'send_email' do
before do
EmailWorker.jobs.clear
@site = Fabricate :site
end
it 'works' do
@site.send_email(subject: 'Subject', body: 'Body')
EmailWorker.jobs.length.must_equal 1
args = EmailWorker.jobs.first['args'].first
args['from'].must_equal Site::FROM_EMAIL
args['to'].must_equal @site.email
args['subject'].must_equal 'Subject'
args['body'].must_equal 'Body'
end
it 'fails if send_emails is false' do
@site.update send_emails: false
@site.send_email(subject: 'Subject', body: 'Body')
end
end
describe 'plan_name' do
it 'should set to free for missing stripe_customer_id' do
site = Fabricate :site