Skip to content

Commit 4d51efe

Browse files
committed
Remove deprecated after_bundle helper inside plugins templates
1 parent fa791fb commit 4d51efe

File tree

5 files changed

+16
-53
lines changed

5 files changed

+16
-53
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `after_bundle` helper inside plugins templates.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `server` argument from the rails server command.
26

37
*Rafael Mendonça França*

railties/lib/rails/generators/actions.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Actions
88
def initialize(*) # :nodoc:
99
super
1010
@indentation = 0
11-
@after_bundle_callbacks = []
1211
end
1312

1413
# Adds an entry into +Gemfile+ for the supplied gem.
@@ -267,16 +266,6 @@ def readme(path)
267266
log File.read(find_in_source_paths(path))
268267
end
269268

270-
# Registers a callback to be executed after bundle and spring binstubs
271-
# have run.
272-
#
273-
# after_bundle do
274-
# git add: '.'
275-
# end
276-
def after_bundle(&block)
277-
@after_bundle_callbacks << block
278-
end
279-
280269
private
281270

282271
# Define log for backwards compatibility. If just one argument is sent,

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ def initialize(*args)
276276
if options[:api]
277277
self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze
278278
end
279+
280+
@after_bundle_callbacks = []
279281
end
280282

281283
public_task :set_default_accessors!
@@ -497,6 +499,16 @@ def file(*args, &block)
497499
create_file(*args, &block)
498500
end
499501

502+
# Registers a callback to be executed after bundle and spring binstubs
503+
# have run.
504+
#
505+
# after_bundle do
506+
# git add: '.'
507+
# end
508+
def after_bundle(&block) # :doc:
509+
@after_bundle_callbacks << block
510+
end
511+
500512
def get_builder_class
501513
defined?(::AppBuilder) ? ::AppBuilder : Rails::AppBuilder
502514
end

railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ def finish_template
263263

264264
public_task :apply_rails_template
265265

266-
def run_after_bundle_callbacks
267-
unless @after_bundle_callbacks.empty?
268-
ActiveSupport::Deprecation.warn("`after_bundle` is deprecated and will be removed in the next version of Rails. ")
269-
end
270-
271-
@after_bundle_callbacks.each do |callback|
272-
callback.call
273-
end
274-
end
275-
276266
def name
277267
@name ||= begin
278268
# same as ActiveSupport::Inflector#underscore except not replacing '-'

railties/test/generators/plugin_generator_test.rb

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -712,38 +712,6 @@ def test_app_update_generates_bin_file
712712
Object.send(:remove_const, "ENGINE_ROOT")
713713
end
714714

715-
def test_after_bundle_callback
716-
path = "http://example.org/rails_template"
717-
template = +%{ after_bundle { run "echo ran after_bundle" } }
718-
template.instance_eval "def read; self; end" # Make the string respond to read
719-
720-
check_open = -> *args do
721-
assert_equal [ path, "Accept" => "application/x-thor-template" ], args
722-
template
723-
end
724-
725-
sequence = ["echo ran after_bundle"]
726-
@sequence_step ||= 0
727-
ensure_bundler_first = -> command do
728-
assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}"
729-
@sequence_step += 1
730-
end
731-
732-
content = nil
733-
generator([destination_root], template: path).stub(:open, check_open, template) do
734-
generator.stub(:bundle_command, ensure_bundler_first) do
735-
generator.stub(:run, ensure_bundler_first) do
736-
silence_stream($stdout) do
737-
content = capture(:stderr) { generator.invoke_all }
738-
end
739-
end
740-
end
741-
end
742-
743-
assert_equal 1, @sequence_step
744-
assert_match(/DEPRECATION WARNING: `after_bundle` is deprecated/, content)
745-
end
746-
747715
private
748716

749717
def action(*args, &block)

0 commit comments

Comments
 (0)