Skip to content
Permalink
Browse files
Remove deprecated after_bundle helper inside plugins templates
  • Loading branch information
rafaelfranca committed Jan 17, 2019
1 parent fa791fb commit 4d51efe24e461a2a3ed562787308484cd48370c7
@@ -1,3 +1,7 @@
* Remove deprecated `after_bundle` helper inside plugins templates.

*Rafael Mendonça França*

* Remove deprecated `server` argument from the rails server command.

*Rafael Mendonça França*
@@ -8,7 +8,6 @@ module Actions
def initialize(*) # :nodoc:
super
@indentation = 0
@after_bundle_callbacks = []
end

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

# Registers a callback to be executed after bundle and spring binstubs
# have run.
#
# after_bundle do
# git add: '.'
# end
def after_bundle(&block)
@after_bundle_callbacks << block
end

private

# Define log for backwards compatibility. If just one argument is sent,
@@ -276,6 +276,8 @@ def initialize(*args)
if options[:api]
self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze
end

@after_bundle_callbacks = []
end

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

# Registers a callback to be executed after bundle and spring binstubs
# have run.
#
# after_bundle do
# git add: '.'
# end
def after_bundle(&block) # :doc:
@after_bundle_callbacks << block
end

def get_builder_class
defined?(::AppBuilder) ? ::AppBuilder : Rails::AppBuilder
end
@@ -263,16 +263,6 @@ def finish_template

public_task :apply_rails_template

def run_after_bundle_callbacks
unless @after_bundle_callbacks.empty?
ActiveSupport::Deprecation.warn("`after_bundle` is deprecated and will be removed in the next version of Rails. ")
end

@after_bundle_callbacks.each do |callback|
callback.call
end
end

def name
@name ||= begin
# same as ActiveSupport::Inflector#underscore except not replacing '-'
@@ -712,38 +712,6 @@ def test_app_update_generates_bin_file
Object.send(:remove_const, "ENGINE_ROOT")
end

def test_after_bundle_callback
path = "http://example.org/rails_template"
template = +%{ after_bundle { run "echo ran after_bundle" } }
template.instance_eval "def read; self; end" # Make the string respond to read

check_open = -> *args do
assert_equal [ path, "Accept" => "application/x-thor-template" ], args
template
end

sequence = ["echo ran after_bundle"]
@sequence_step ||= 0
ensure_bundler_first = -> command do
assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}"
@sequence_step += 1
end

content = nil
generator([destination_root], template: path).stub(:open, check_open, template) do
generator.stub(:bundle_command, ensure_bundler_first) do
generator.stub(:run, ensure_bundler_first) do
silence_stream($stdout) do
content = capture(:stderr) { generator.invoke_all }
end
end
end
end

assert_equal 1, @sequence_step
assert_match(/DEPRECATION WARNING: `after_bundle` is deprecated/, content)
end

private

def action(*args, &block)

0 comments on commit 4d51efe

Please sign in to comment.