Skip to content

Commit

Permalink
Merge branch 'main' into propshaft-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed May 15, 2024
2 parents cee5cb2 + 72fccfb commit ea0723c
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 387 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gem "cssbundling-rails"
gem "importmap-rails", ">= 1.2.3"
gem "tailwindcss-rails"
gem "dartsass-rails"
gem "kamal"
gem "kamal", require: false
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid Active Model (and by extension the entire framework)
# being dependent on a binary library.
Expand Down
3 changes: 2 additions & 1 deletion activesupport/lib/active_support/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,8 @@ def handle_expired_entry(entry, key, options)
# When an entry has a positive :race_condition_ttl defined, put the stale entry back into the cache
# for a brief period while the entry is being recalculated.
entry.expires_at = Time.now.to_f + race_ttl
write_entry(key, entry, expires_in: race_ttl * 2)
options[:expires_in] = race_ttl * 2
write_entry(key, entry, **options)
else
delete_entry(key, **options)
end
Expand Down
36 changes: 35 additions & 1 deletion activesupport/test/cache/behaviors/cache_store_coder_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

module CacheStoreCoderBehavior
class SpyCoder
attr_reader :dumped_entries, :loaded_entries
attr_reader :dumped_entries, :loaded_entries, :dump_compressed_entries

def initialize
@dumped_entries = []
@loaded_entries = []
@dump_compressed_entries = []
end

def dump(entry)
Expand All @@ -19,6 +20,15 @@ def load(payload)
@loaded_entries << entry
entry
end

def dump_compressed(entry, threshold)
if threshold == 0
@dump_compressed_entries << entry
Marshal.dump(entry)
else
dump(entry)
end
end
end

def test_coder_receive_the_entry_on_write
Expand Down Expand Up @@ -83,4 +93,28 @@ def test_nil_coder_bypasses_serialization
entry = ActiveSupport::Cache::Entry.new("value")
assert_same entry, @store.send(:serialize_entry, entry)
end

def test_coder_is_used_during_handle_expired_entry_when_expired
coder = SpyCoder.new
@store = lookup_store(coder: coder)
@store.write("foo", "bar", expires_in: 1.second)
assert_equal 0, coder.loaded_entries.size
assert_equal 1, coder.dumped_entries.size

travel_to(2.seconds.from_now) do
val = @store.fetch(
"foo",
race_condition_ttl: 5,
compress: true,
compress_threshold: 0
) { "baz" }
assert_equal "baz", val
assert_equal 1, coder.loaded_entries.size # 1 read in fetch
assert_equal "bar", coder.loaded_entries.first.value
assert_equal 1, coder.dumped_entries.size # did not change from original write
assert_equal 2, coder.dump_compressed_entries.size # 1 write the expired entry handler, 1 in fetch
assert_equal "bar", coder.dump_compressed_entries.first.value
assert_equal "baz", coder.dump_compressed_entries.last.value
end
end
end
3 changes: 2 additions & 1 deletion railties/lib/rails/commands/console/irb_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def start

env = colorized_env
app_name = @app.class.module_parent_name.underscore.dasherize
prompt_prefix = "#{app_name}(#{env})"
prompt_prefix = "%N(#{env})"
IRB.conf[:IRB_NAME] = app_name

IRB.conf[:PROMPT][:RAILS_PROMPT] = {
PROMPT_I: "#{prompt_prefix}> ",
Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ def run_kamal
bundle_command "binstubs kamal"
bundle_command "exec kamal init"

remove_file ".env"
template "env.erb", ".env.erb"
template "config/deploy.yml", force: true
end
Expand Down
42 changes: 0 additions & 42 deletions railties/lib/rails/generators/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ def gem
raise NotImplementedError
end

def docker_base
raise NotImplementedError
end

def docker_build
raise NotImplementedError
end

def base_package
raise NotImplementedError
end
Expand Down Expand Up @@ -125,14 +117,6 @@ def gem
["mysql2", ["~> 0.5"]]
end

def docker_base
"curl default-mysql-client libvips"
end

def docker_build
"build-essential default-libmysqlclient-dev git"
end

def base_package
"default-mysql-client"
end
Expand Down Expand Up @@ -172,14 +156,6 @@ def gem
["pg", ["~> 1.1"]]
end

def docker_base
"curl libvips postgresql-client"
end

def docker_build
"build-essential git libpq-dev"
end

def base_package
"postgresql-client"
end
Expand Down Expand Up @@ -220,14 +196,6 @@ def gem
["trilogy", ["~> 2.7"]]
end

def docker_base
"curl libvips"
end

def docker_build
"build-essential git"
end

def base_package
nil
end
Expand Down Expand Up @@ -258,14 +226,6 @@ def gem
["sqlite3", [">= 1.4"]]
end

def docker_base
"curl libsqlite3-0 libvips"
end

def docker_build
"build-essential git"
end

def base_package
"libsqlite3-0"
end
Expand All @@ -284,8 +244,6 @@ def name; end
def service; end
def port; end
def volume; end
def docker_base; end
def docker_build; end
def base_package; end
def build_package; end
def feature_name; end
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ea0723c

Please sign in to comment.