1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Haml] Get rid of some Rails 3 beta 3 deprecation warnings in the tests.

This commit is contained in:
Nathan Weizenbaum 2010-04-17 16:33:57 -07:00
parent 1ed29bfeeb
commit c471e68307
4 changed files with 42 additions and 2 deletions

View file

@ -182,6 +182,28 @@ module Haml
ActionPack::VERSION::TINY == "0.beta")
end
# Returns whether this environment is using ActionPack
# version 3.0.0.beta.3 or greater.
#
# @return [Boolean]
def ap_geq_3_beta_3?
# The ActionPack module is always loaded automatically in Rails >= 3
return false unless defined?(ActionPack) && defined?(ActionPack::VERSION)
version =
if defined?(ActionPack::VERSION::MAJOR)
ActionPack::VERSION::MAJOR
else
# Rails 1.2
ActionPack::VERSION::Major
end
version >= 3 &&
((defined?(ActionPack::VERSION::TINY) && ActionPack::VERSION::TINY >= 1) ||
(defined?(ActionPack::VERSION::BUILD) &&
ActionPack::VERSION::BUILD =~ /beta(\d+)/ &&
$1.to_i >= 3))
end
# Returns an ActionView::Template* class.
# In pre-3.0 versions of Rails, most of these classes
# were of the form `ActionView::TemplateFoo`,

View file

@ -268,7 +268,7 @@ END
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
</form>
HTML
- form_for :article, @article, :url => '' do |f|
- form_for #{form_for_calling_convention(:article)}, :url => '' do |f|
Title:
= f.text_field :title
Body:
@ -367,7 +367,7 @@ HAML
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
</form>
HTML
#{rails_block_helper_char} form_for :article, @article, :url => '' do |f|
#{rails_block_helper_char} form_for #{form_for_calling_convention(:article)}, :url => '' do |f|
Title:
= f.text_field :title
Body:

View file

@ -62,6 +62,19 @@ click
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
</form>
</div>
- elsif Haml::Util.ap_geq_3_beta_3?
%p
= form_tag ''
%div
= form_tag '' do
%div= submit_tag 'save'
- @foo = 'value one'
= test_partial 'partial'
= form_for @article, :as => :article, :url => '', :html => {:class => nil, :id => nil} do |f|
Title:
= f.text_field :title
Body:
= f.text_field :body
- elsif Haml::Util.ap_geq_3?
%p
= form_tag ''

View file

@ -42,4 +42,9 @@ class Test::Unit::TestCase
return '=' if Haml::Util.ap_geq_3?
return '-'
end
def form_for_calling_convention(name)
return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3_beta_3?
return ":#{name}, @#{name}"
end
end