diff --git a/padrino-core/lib/padrino-core/application/routing.rb b/padrino-core/lib/padrino-core/application/routing.rb
index aaa1ba3e3..33e9fb470 100644
--- a/padrino-core/lib/padrino-core/application/routing.rb
+++ b/padrino-core/lib/padrino-core/application/routing.rb
@@ -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
diff --git a/padrino-core/test/test_routing.rb b/padrino-core/test/test_routing.rb
index 490b25370..833eafeb6 100644
--- a/padrino-core/test/test_routing.rb
+++ b/padrino-core/test/test_routing.rb
@@ -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
diff --git a/padrino-mailer/lib/padrino-mailer/ext.rb b/padrino-mailer/lib/padrino-mailer/ext.rb
index 0a7d3a14a..3e4a6a888 100644
--- a/padrino-mailer/lib/padrino-mailer/ext.rb
+++ b/padrino-mailer/lib/padrino-mailer/ext.rb
@@ -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
##
diff --git a/padrino-mailer/test/test_message.rb b/padrino-mailer/test/test_message.rb
index 7597d4e92..26e6a9576 100644
--- a/padrino-mailer/test/test_message.rb
+++ b/padrino-mailer/test/test_message.rb
@@ -166,4 +166,27 @@
assert_equal "Object 1
\nObject 2
\nObject <evil>
\nObject
", 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
+ end
end