Methods
S
T
Instance Public methods
setup()
# File actionmailer/test/caching_test.rb, line 115
def setup
  super
  @store = ActiveSupport::Cache::MemoryStore.new
  @mailer = CachingMailer.new
  @mailer.perform_caching = true
  @mailer.cache_store = @store
end
test_fragment_cache_instrumentation()
# File actionmailer/test/caching_test.rb, line 174
def test_fragment_cache_instrumentation
  payload = nil

  subscriber = proc do |*args|
    event = ActiveSupport::Notifications::Event.new(*args)
    payload = event.payload
  end

  ActiveSupport::Notifications.subscribed(subscriber, "read_fragment.action_mailer") do
    @mailer.fragment_cache
  end

  assert_equal "caching_mailer", payload[:mailer]
  assert_equal "views/caching/#{template_digest("caching_mailer/fragment_cache")}", payload[:key]
end
test_fragment_caching()
# File actionmailer/test/caching_test.rb, line 123
def test_fragment_caching
  email = @mailer.fragment_cache
  expected_body = "\"Welcome\""

  assert_match expected_body, email.body.encoded
  assert_match expected_body,
    @store.read("views/caching/#{template_digest("caching_mailer/fragment_cache")}")
end
test_fragment_caching_in_partials()
# File actionmailer/test/caching_test.rb, line 132
def test_fragment_caching_in_partials
  email = @mailer.fragment_cache_in_partials
  expected_body = 'Old fragment caching in a partial'
  assert_match(expected_body, email.body.encoded)

  assert_match(expected_body,
    @store.read("views/caching/#{template_digest("caching_mailer/_partial")}"))
end
test_fragment_caching_options()
# File actionmailer/test/caching_test.rb, line 149
def test_fragment_caching_options
  time = Time.now
  email = @mailer.fragment_caching_options
  expected_body = "No Digest"

  assert_match expected_body, email.body.encoded
  Time.stub(:now, time + 11) do
    assert_nil @store.read("views/no_digest")
  end
end
test_fragment_caching_with_options()
# File actionpack/test/controller/caching_test.rb, line 221
def test_fragment_caching_with_options
  time = Time.now
  get :fragment_cached_with_options
  assert_response :success
  expected_body = "<body>\n<p>ERB</p>\n</body>\n"

  assert_equal expected_body, @response.body
  Time.stub(:now, time + 11) do
    assert_nil @store.read("views/with_options")
  end
end
test_fragment_caching_with_variant()
# File actionpack/test/controller/caching_test.rb, line 281
def test_fragment_caching_with_variant
  get :formatted_fragment_cached_with_variant, format: "html", params: { v: :phone }
  assert_response :success
  expected_body = "<body>\n<p>PHONE</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "<p>PHONE</p>",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached_with_variant/#{template_digest("functional_caching/formatted_fragment_cached_with_variant")}")
end
test_html_formatted_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 258
def test_html_formatted_fragment_caching
  get :formatted_fragment_cached, format: "html"
  assert_response :success
  expected_body = "<body>\n<p>ERB</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "<p>ERB</p>",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached")}")
end
test_multipart_fragment_caching()
# File actionmailer/test/caching_test.rb, line 160
def test_multipart_fragment_caching
  email = @mailer.multipart_cache

  expected_text_body = "\"Welcome text\""
  expected_html_body = "\"Welcome html\""
  encoded_body = email.body.encoded
  assert_match expected_text_body, encoded_body
  assert_match expected_html_body, encoded_body
  assert_match expected_text_body,
               @store.read("views/text_caching")
  assert_match expected_html_body,
               @store.read("views/html_caching")
end
test_render_inline_before_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 233
def test_render_inline_before_fragment_caching
  get :inline_fragment_cached
  assert_response :success
  assert_match(/Some inline content/, @response.body)
  assert_match(/Some cached content/, @response.body)
  assert_match("Some cached content",
    @store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached")}"))
end
test_skip_fragment_cache_digesting()
# File actionmailer/test/caching_test.rb, line 141
def test_skip_fragment_cache_digesting
  email = @mailer.skip_fragment_cache_digesting
  expected_body = "No Digest"

  assert_match expected_body, email.body.encoded
  assert_match expected_body, @store.read("views/no_digest")
end
test_skipping_fragment_cache_digesting()
# File actionpack/test/controller/caching_test.rb, line 212
def test_skipping_fragment_cache_digesting
  get :fragment_cached_without_digest, format: "html"
  assert_response :success
  expected_body = "<body>\n<p>ERB</p>\n</body>\n"

  assert_equal expected_body, @response.body
  assert_equal "<p>ERB</p>", @store.read("views/nodigest")
end
test_xml_formatted_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 269
def test_xml_formatted_fragment_caching
  get :formatted_fragment_cached, format: "xml"
  assert_response :success
  expected_body = "<body>\n  <p>Builder</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "  <p>Builder</p>\n",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached")}")
end