Skip to content

Instantly share code, notes, and snippets.

@mfazekas
Last active August 29, 2015 14:10
Show Gist options
  • Save mfazekas/b0a4ddcd425b80074d14 to your computer and use it in GitHub Desktop.
Save mfazekas/b0a4ddcd425b80074d14 to your computer and use it in GitHub Desktop.
deliver_now in action mailer objects bugreport https://github.com/rails/rails/issues/17965
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
#gem 'rails', github: 'rails/rails', branch: '4-2-stable'
gem 'rails', '4.2.0.rc2'
#gem 'rails', '4.1.8'
#gem 'arel', github: 'rails/arel'
#gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'byebug'
GEMFILE
system 'bundle'
end
require 'byebug'
require 'bundler'
Bundler.setup(:default)
require 'rails'
require 'action_controller/railtie'
require 'action_mailer/railtie'
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
secrets.secret_token = 'secret_token'
secrets.secret_key_base = 'secret_key_base'
config.action_mailer.delivery_method = :test
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get '/' => 'test#index'
end
end
ActionMailer::Base.delivery_method = :test
class TestMailer < ActionMailer::Base
def msg
mail to:"[email protected]",
subject:"asd",
from: "[email protected]",
body: "test"
end
def msg_and_deliver
msg.deliver
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def index
render text: 'Home'
end
end
require 'minitest/autorun'
require 'rack/test'
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_msg
ActionMailer::Base.deliveries.clear
TestMailer.msg.deliver
assert_equal 1,ActionMailer::Base.deliveries.size
end
def test_msg_and_deliver
ActionMailer::Base.deliveries.clear
TestMailer.msg_and_deliver
assert_equal 1,ActionMailer::Base.deliveries.size
end
def test_msg_and_deliver_with_something_called
ActionMailer::Base.deliveries.clear
TestMailer.msg_and_deliver.present?
assert_equal 1,ActionMailer::Base.deliveries.size
end
private
def app
Rails.application
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment