Skip to content

Instantly share code, notes, and snippets.

@claudiob
Last active December 3, 2015 03:02
Show Gist options
  • Save claudiob/37079cf529f80008d022 to your computer and use it in GitHub Desktop.
Save claudiob/37079cf529f80008d022 to your computer and use it in GitHub Desktop.

Revisions

  1. claudiob renamed this gist Dec 3, 2015. 1 changed file with 0 additions and 0 deletions.
  2. claudiob revised this gist Dec 3, 2015. 1 changed file with 41 additions and 0 deletions.
    41 changes: 41 additions & 0 deletions passing_test_after_21631.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    begin
    require 'bundler/inline'
    rescue LoadError => e
    $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
    raise e
    end

    gemfile(true) do
    source 'https://rubygems.org'
    gem 'rails'
    end

    require 'active_support'
    require 'minitest/autorun'

    # Ensure backward compatibility with Minitest 4
    Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)

    ActiveSupport::TestCase.test_order = :random

    class CacheNotificationOrderTest < ActiveSupport::TestCase
    def setup
    @record_size = ActiveSupport::Cache.lookup_store(:memory_store).send(:cached_size, 1, ActiveSupport::Cache::Entry.new("aaaaaaaaaa"))
    @cache = ActiveSupport::Cache.lookup_store(:memory_store, :expires_in => 60, :size => @record_size * 10 + 1)
    end

    def test_that_works_on_rails42_and_fails_on_master
    @events = [ ]
    ActiveSupport::Notifications.subscribe(/^cache_(.*)\.active_support$/) do |*args|
    @events << ActiveSupport::Notifications::Event.new(*args)
    end

    @cache.fetch("radiohead") { "House Of Cards" }

    assert_equal @events[0].name, 'cache_read.active_support'
    assert_equal @events[1].name, 'cache_generate.active_support'
    assert_equal @events[2].name, 'cache_write.active_support'
    ensure
    ActiveSupport::Notifications.unsubscribe(/^cache_(.*)\.active_support$/)
    end
    end
  3. claudiob created this gist Dec 3, 2015.
    44 changes: 44 additions & 0 deletions failing_test_after_21631.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    begin
    require 'bundler/inline'
    rescue LoadError => e
    $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
    raise e
    end

    gemfile(true) do
    source 'https://rubygems.org'
    gem 'rails', github: 'rails/rails'
    gem 'arel', github: 'rails/arel'
    gem 'rack', github: 'rack/rack'
    gem 'sprockets', github: 'rails/sprockets'
    gem 'sprockets-rails', github: 'rails/sprockets-rails'
    gem 'sass-rails', github: 'rails/sass-rails'
    end

    require 'active_support'
    require 'minitest/autorun'

    # Ensure backward compatibility with Minitest 4
    Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)

    class CacheNotificationOrderTest < ActiveSupport::TestCase
    def setup
    @record_size = ActiveSupport::Cache.lookup_store(:memory_store).send(:cached_size, 1, ActiveSupport::Cache::Entry.new("aaaaaaaaaa"))
    @cache = ActiveSupport::Cache.lookup_store(:memory_store, :expires_in => 60, :size => @record_size * 10 + 1)
    end

    def test_that_works_on_rails42_and_fails_on_master
    @events = [ ]
    ActiveSupport::Notifications.subscribe(/^cache_(.*)\.active_support$/) do |*args|
    @events << ActiveSupport::Notifications::Event.new(*args)
    end

    @cache.fetch("radiohead") { "House Of Cards" }

    assert_equal @events[0].name, 'cache_read.active_support'
    assert_equal @events[1].name, 'cache_generate.active_support'
    assert_equal @events[2].name, 'cache_write.active_support'
    ensure
    ActiveSupport::Notifications.unsubscribe(/^cache_(.*)\.active_support$/)
    end
    end