diff --git a/.travis.yml b/.travis.yml index a611c0b..d4fa2b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,16 @@ rvm: - ree - jruby-18mode gemfile: + - gemfiles/Gemfile-rails.3.0.x + - gemfiles/Gemfile-rails.3.1.x + - gemfiles/Gemfile-rails.3.2.x - Gemfile +matrix: + exclude: + - rvm: ree + gemfile: Gemfile + - rvm: jruby-18mode + gemfile: Gemfile notifications: recipients: - jose.valim@plataformatec.com.br diff --git a/Gemfile b/Gemfile index d87e4e4..04eb1bf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ -source :rubygems +source 'https://rubygems.org' gemspec gem 'rake' gem 'rdoc' + +gem 'actionmailer', '~> 4.0.0.beta1' +gem 'activemodel', '~> 4.0.0.beta1' diff --git a/Gemfile.lock b/Gemfile.lock index b976061..072d505 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,66 +1,63 @@ PATH remote: . specs: - mail_form (1.3.0) - actionmailer (~> 3.0) + mail_form (1.4.0) + actionmailer (>= 3.0) + activemodel (>= 3.0) GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - actionmailer (3.2.9) - actionpack (= 3.2.9) - mail (~> 2.4.4) - actionpack (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - builder (~> 3.0.0) + actionmailer (4.0.0.beta1) + actionpack (= 4.0.0.beta1) + mail (~> 2.5.3) + actionpack (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.0) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.9) - activesupport (= 3.2.9) - builder (~> 3.0.0) - activesupport (3.2.9) - i18n (~> 0.6) - multi_json (~> 1.0) - builder (3.0.4) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) + activesupport (4.0.0.beta1) + i18n (~> 0.6.2) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.33) + atomic (1.0.1) + builder (3.1.4) erubis (2.7.0) - hike (1.2.1) - i18n (0.6.1) - journey (1.0.4) - json (1.7.5) - mail (2.4.4) + i18n (0.6.4) + json (1.7.7) + mail (2.5.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) - multi_json (1.3.7) + mime-types (1.21) + minitest (4.7.0) + multi_json (1.7.2) polyglot (0.3.3) - rack (1.4.1) - rack-cache (1.2) - rack (>= 0.4) + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rake (10.0.2) - rdoc (3.12) + rake (10.0.3) + rdoc (4.0.0) json (~> 1.4) - sprockets (2.2.1) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - tilt (1.3.3) + thread_safe (0.1.0) + atomic treetop (1.4.12) polyglot polyglot (>= 0.3.1) + tzinfo (0.3.37) PLATFORMS ruby DEPENDENCIES + actionmailer (~> 4.0.0.beta1) + activemodel (~> 4.0.0.beta1) mail_form! rake rdoc diff --git a/gemfiles/Gemfile-rails.3.0.x b/gemfiles/Gemfile-rails.3.0.x new file mode 100644 index 0000000..a7791c7 --- /dev/null +++ b/gemfiles/Gemfile-rails.3.0.x @@ -0,0 +1,9 @@ +source 'https://rubygems.org' + +gem 'mail_form', :path => '..' + +gem 'rake' +gem 'rdoc' + +gem 'actionmailer', '~> 3.0.0' +gem 'activemodel', '~> 3.0.0' diff --git a/gemfiles/Gemfile-rails.3.1.x b/gemfiles/Gemfile-rails.3.1.x new file mode 100644 index 0000000..05ed5fd --- /dev/null +++ b/gemfiles/Gemfile-rails.3.1.x @@ -0,0 +1,9 @@ +source 'https://rubygems.org' + +gem 'mail_form', :path => '..' + +gem 'rake' +gem 'rdoc' + +gem 'actionmailer', '~> 3.1.0' +gem 'activemodel', '~> 3.1.0' diff --git a/gemfiles/Gemfile-rails.3.2.x b/gemfiles/Gemfile-rails.3.2.x new file mode 100644 index 0000000..d97eab2 --- /dev/null +++ b/gemfiles/Gemfile-rails.3.2.x @@ -0,0 +1,9 @@ +source 'https://rubygems.org' + +gem 'mail_form', :path => '..' + +gem 'rake' +gem 'rdoc' + +gem 'actionmailer', '~> 3.2.0' +gem 'activemodel', '~> 3.2.0' diff --git a/lib/mail_form/notifier.rb b/lib/mail_form/notifier.rb index 92b5313..1029e84 100644 --- a/lib/mail_form/notifier.rb +++ b/lib/mail_form/notifier.rb @@ -1,5 +1,20 @@ module MailForm class Notifier < ActionMailer::Base + # since ActionMailer 3.0 has own simple_format method + # but we need one from the ActionPack + # https://github.com/rails/rails/commit/fb34f8577c47d958ca32b7ab585c1904e1a776b1 + helper do + def simple_format(text, html_options={}, options={}) + @text_helper ||= Class.new do + include ActionView::Helpers::TextHelper + include ActionView::Helpers::TagHelper + include ActionView::Helpers::SanitizeHelper + end.new + + @text_helper.simple_format(text, html_options, options) + end + end + self.mailer_name = "mail_form" append_view_path File.expand_path('../views', __FILE__) @@ -22,4 +37,4 @@ def contact(resource) mail(headers) end end -end \ No newline at end of file +end diff --git a/lib/mail_form/shim.rb b/lib/mail_form/shim.rb index 2a8d663..4cc8a1b 100644 --- a/lib/mail_form/shim.rb +++ b/lib/mail_form/shim.rb @@ -46,7 +46,7 @@ def id # Create just check validity, and if so, trigger callbacks. def deliver if valid? - _run_deliver_callbacks { true } + run_callbacks :deliver else false end diff --git a/lib/mail_form/views/mail_form/contact.erb b/lib/mail_form/views/mail_form/contact.erb index 0c12327..17c551b 100644 --- a/lib/mail_form/views/mail_form/contact.erb +++ b/lib/mail_form/views/mail_form/contact.erb @@ -22,8 +22,9 @@ value = @resource.request.send(attribute) value = if value.is_a?(Hash) && !value.empty? - list = value.to_a.map{ |k,v| content_tag(:li, h("#{k}: #{v.inspect}")) }.join("\n") - content_tag(:ul, raw(list), :style => "list-style:none;") + content_tag(:ul, :style => "list-style:none;") do + value.to_a.map{ |k,v| content_tag(:li, h("#{k}: #{v.inspect}")) }.reduce{ |list, li| list << li << '\n'.html_safe } + end elsif value.is_a?(String) value else diff --git a/mail_form.gemspec b/mail_form.gemspec index 8230254..b09d220 100644 --- a/mail_form.gemspec +++ b/mail_form.gemspec @@ -18,5 +18,6 @@ Gem::Specification.new do |s| s.rubyforge_project = "mail_form" - s.add_dependency('actionmailer', '~> 3.0') + s.add_dependency('actionmailer', '>= 3.0') + s.add_dependency('activemodel', '>= 3.0') end