Permalink
Browse files

Merge branch 'rails31' into unstable

  • Loading branch information...
2 parents 1e111a1 + ad3275b commit dedc3c118aad825591e5c081480cf525315cb4ba @fxposter fxposter committed Jun 28, 2011
Showing with 17 additions and 12 deletions.
  1. +5 −4 Appraisals
  2. +0 −1 Gemfile
  3. +2 −0 README.rdoc
  4. +3 −3 lib/nested_form/builder_mixin.rb
  5. +1 −1 spec/nested_form/builder_spec.rb
  6. +5 −3 spec/nested_form/view_helper_spec.rb
  7. +1 −0 spec/spec_helper.rb
View
@@ -1,7 +1,8 @@
-appraise "rails3" do
- gem "rails", "~> 3.0.0"
+appraise 'rails3' do
+ gem 'rails', '~> 3.0.0'
+ gem 'formtastic'
end
-appraise "rails3_1" do
- gem "rails", "~> 3.1.0.rc4"
+appraise 'rails3_1' do
+ gem 'rails', '~> 3.1.0.rc4'
end
View
@@ -2,6 +2,5 @@ source "http://rubygems.org/"
gemspec
gem 'sqlite3'
gem 'simple_form'
-gem 'formtastic'
gem 'rake'
gem 'appraisal'
View
@@ -38,6 +38,8 @@ There's a small fix for Rails 3.1 form handling.
Also support of Rails 3.1 led me to huge refactor of specs setup (now using Helper specs from rspec-rails instead of custom implementation spec context).
Last, but not least - I used appraisal[https://github.com/thoughtbot/appraisal] gem to run specs for rails 3 and 3.1.
+Formtastic is supported only with Rails 3.0, Rails 3.1 integration is not available now.
+
== Setup
Add it to your Gemfile then run +bundle+ to install it.
@@ -48,12 +48,12 @@ def link_to_remove(*args, &block)
hidden_field(:_destroy) + @template.link_to(*args, &block)
end
- def fields_for_with_nested_attributes(association_name, *args, block)
+ def fields_for_with_nested_attributes(association_name, *args)
# TODO Test this better
- block ||= Proc.new { |fields| @template.render(:partial => "#{association_name.to_s.singularize}_fields", :locals => {:f => fields}) }
+ block = args.pop || Proc.new { |fields| @template.render(:partial => "#{association_name.to_s.singularize}_fields", :locals => {:f => fields}) }
@fields ||= {}
@fields[association_name] = block
- super(association_name, *args, block)
+ super(association_name, *(args << block))
end
def fields_for_nested_model(name, object, options, block)
@@ -1,6 +1,6 @@
require "spec_helper"
-[NestedForm::Builder, NestedForm::SimpleBuilder, NestedForm::FormtasticBuilder].each do |builder|
+[NestedForm::Builder, NestedForm::SimpleBuilder, defined?(NestedForm::FormtasticBuilder) ? NestedForm::FormtasticBuilder : nil].compact.each do |builder|
describe builder do
describe "with no options" do
before(:each) do
@@ -29,9 +29,11 @@
end
end
- it "should pass instance of NestedForm::FormtasticBuilder to semantic_nested_form_for block" do
- _view.semantic_nested_form_for(Project.new) do |f|
- f.should be_instance_of(NestedForm::FormtasticBuilder)
+ if defined?(NestedForm::FormtasticBuilder)
+ it "should pass instance of NestedForm::FormtasticBuilder to semantic_nested_form_for block" do
+ _view.semantic_nested_form_for(Project.new) do |f|
+ f.should be_instance_of(NestedForm::FormtasticBuilder)
+ end
end
end
View
@@ -2,6 +2,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "bundler/setup"
require "rails"
+require 'action_view/railtie'
Bundler.require(:default)
require 'action_controller/railtie'
require 'active_record'

0 comments on commit dedc3c1

Please sign in to comment.