Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion padrino-core/lib/padrino-core/application/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def route!(base = settings, pass_block = nil)
verb = request.request_method
candidacies, allows = routes.partition { |route| route.verb == verb }
if candidacies.empty?
response['Allows'] = allows.map(&:verb).join(', ')
response['Allow'] = allows.map(&:verb).uniq.join(', ')
halt 405
end
end
Expand Down
1 change: 1 addition & 0 deletions padrino-core/test/test_routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ class Test < Padrino::Application
end
get '/bar'
assert_equal 405, status
assert_equal 'POST', response['Allow']
end

it 'should respond to' do
Expand Down
4 changes: 3 additions & 1 deletion padrino-mailer/lib/padrino-mailer/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def settings
# Sinatra almost compatibility.
#
def self.set(name, value)
self.class.instance_eval { define_method(name) { value } unless method_defined?(:erb) }
singleton_class.class_eval do
define_method(name) { value } unless method_defined?(name)
end
end

##
Expand Down
23 changes: 23 additions & 0 deletions padrino-mailer/test/test_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,27 @@
assert_equal "Object 1<br>\nObject 2<br>\nObject &lt;evil&gt;<br>\nObject <good><br>", message.body.to_s.chomp
end
end

describe 'Mail::Message.set' do
it 'should define accessor methods for settings' do
Mail::Message.set(:_test_custom_setting, 'custom_value')
message = Mail::Message.new
assert_equal 'custom_value', message.settings._test_custom_setting
ensure
if Mail::Message.singleton_class.method_defined?(:_test_custom_setting)
Mail::Message.singleton_class.send(:remove_method, :_test_custom_setting)
end
end

it 'should not redefine an already defined method' do
Mail::Message.set(:_test_another_setting, 'first')
Mail::Message.set(:_test_another_setting, 'second')
message = Mail::Message.new
assert_equal 'first', message.settings._test_another_setting
ensure
if Mail::Message.singleton_class.method_defined?(:_test_another_setting)
Mail::Message.singleton_class.send(:remove_method, :_test_another_setting)
end
end
Comment on lines +186 to +190
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same cleanup issue here: _test_another_setting is defined as a singleton method on Mail::Message, but the ensure block removes from Class. This will leave the test method defined across the suite and can cause cross-test pollution; remove it from Mail::Message.singleton_class instead.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — same correction applied here: cleanup now targets Mail::Message.singleton_class.send(:remove_method, ...) with the appropriate guard check.

end
end
Loading