Skip to content

Commit ef28f1e

Browse files
zzakr7kamura
authored andcommitted
Flash.add_flash_types should define helpers as private
Co-authored-by: Ryo Nakamura <[email protected]>
1 parent dd2b18e commit ef28f1e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

actionpack/lib/action_controller/metal/flash.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,12 @@ def add_flash_types(*types)
3838
define_method(type) do
3939
request.flash[type]
4040
end
41+
private type
4142
helper_method(type) if respond_to?(:helper_method)
4243

4344
self._flash_types += [type]
4445
end
4546
end
46-
47-
def action_methods # :nodoc:
48-
@action_methods ||= super - _flash_types.map(&:to_s).to_set
49-
end
5047
end
5148

5249
private

actionpack/test/controller/flash_test.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def use_flash
274274

275275
def set_bar
276276
flash[:bar] = "for great justice"
277-
head :ok
277+
render inline: "<%= bar %>"
278278
end
279279

280280
def set_flash_optionally
@@ -330,7 +330,7 @@ def test_added_flash_types_method
330330
with_test_route_set do
331331
get "/set_bar"
332332
assert_response :success
333-
assert_equal "for great justice", @controller.bar
333+
assert_equal "for great justice", response.body
334334
end
335335
end
336336

@@ -356,7 +356,7 @@ def test_flash_factored_into_etag
356356
end
357357
end
358358

359-
def test_flash_usable_in_metal_without_helper
359+
def test_flash_unusable_in_metal_without_helper
360360
controller_class = nil
361361

362362
assert_nothing_raised do
@@ -367,8 +367,11 @@ def test_flash_usable_in_metal_without_helper
367367

368368
controller = controller_class.new
369369

370-
assert_respond_to controller, :alert
371-
assert_respond_to controller, :notice
370+
assert_not_respond_to controller, :alert
371+
assert_not_respond_to controller, :notice
372+
373+
assert_includes controller.private_methods, :alert
374+
assert_includes controller.private_methods, :notice
372375
end
373376

374377
private

actionpack/test/controller/helper_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class JustMeController < ActionController::Base
3737
clear_helpers
3838

3939
def flash
40-
render inline: "<h1><%= notice %></h1>"
40+
render inline: "<h1><%= request.flash[:notice] %></h1>"
4141
end
4242

4343
def lib

0 commit comments

Comments
 (0)