summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Dreyer <ktdreyer@ktdreyer.com>2013-02-07 09:05:34 -0700
committerKen Dreyer <ktdreyer@ktdreyer.com>2013-02-12 22:12:59 -0700
commitda7b4699c1edad0898db1e944f056c5b2c5103fa (patch)
treeea9f0d3e95fd49b83e788088a0fe58c3043fd666
parent5a5bf511690b1f58874755d6fa8507168f2e7ee5 (diff)
downloadrubygem-activerecord-da7b4699c1edad0898db1e944f056c5b2c5103fa.tar.gz
rubygem-activerecord-da7b4699c1edad0898db1e944f056c5b2c5103fa.tar.xz
rubygem-activerecord-da7b4699c1edad0898db1e944f056c5b2c5103fa.zip
Downgrade to ActiveRecord 2.3.16 and add RHEL 6 compatibility
-rw-r--r--.gitignore2
-rw-r--r--rubygem-activerecord-fix-more-failing-tests.patch32
-rw-r--r--rubygem-activerecord-fix-set-order.patch53
-rw-r--r--rubygem-activerecord-remove-rdoc-task.patch76
-rw-r--r--rubygem-activerecord-sqlite-api.patch25
-rw-r--r--rubygem-activerecord-xml-serialization.patch28
-rw-r--r--rubygem-activerecord.spec115
-rw-r--r--sources4
8 files changed, 296 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index 423c94f..df68631 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,5 @@ activerecord-2.3.8.gem
/activerecord-3.2.10.gem
/activerecord-3.2.11-tests.tgz
/activerecord-3.2.11.gem
+/activerecord-2.3.16-tests.tgz
+/activerecord-2.3.16.gem
diff --git a/rubygem-activerecord-fix-more-failing-tests.patch b/rubygem-activerecord-fix-more-failing-tests.patch
new file mode 100644
index 0000000..6851ba7
--- /dev/null
+++ b/rubygem-activerecord-fix-more-failing-tests.patch
@@ -0,0 +1,32 @@
+From 774fac0e736c589ef32dc61a02864b2abdc5fee3 Mon Sep 17 00:00:00 2001
+From: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
+Date: Thu, 22 Mar 2012 23:47:22 -0300
+Subject: [PATCH] Fix more failing tests related to ruby 1.8.7 p358 version change
+
+(cherry-picked from commit f748d36b4014418c48553836a56b4bec74e15e49)
+---
+ activerecord/test/cases/nested_attributes_test.rb | 6 +++++-
+ 1 files changed, 5 insertions(+), 1 deletions(-)
+
+diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
+index 6b144a1..d4bb6f8 100644
+--- a/activerecord/test/cases/nested_attributes_test.rb
++++ b/activerecord/test/cases/nested_attributes_test.rb
+@@ -513,9 +513,13 @@ module NestedAttributesOnACollectionAssociationTests
+ end
+
+ def test_should_automatically_build_new_associated_models_for_each_entry_in_a_hash_where_the_id_is_missing
++ attributes = ActiveSupport::OrderedHash.new
++ attributes['foo'] = { :name => 'Grace OMalley' }
++ attributes['bar'] = { :name => 'Privateers Greed' }
++
+ @pirate.send(@association_name).destroy_all
+ @pirate.reload.attributes = {
+- association_getter => { 'foo' => { :name => 'Grace OMalley' }, 'bar' => { :name => 'Privateers Greed' }}
++ association_getter => attributes
+ }
+
+ assert @pirate.send(@association_name).first.new_record?
+--
+1.7.1
+
diff --git a/rubygem-activerecord-fix-set-order.patch b/rubygem-activerecord-fix-set-order.patch
new file mode 100644
index 0000000..411d9a7
--- /dev/null
+++ b/rubygem-activerecord-fix-set-order.patch
@@ -0,0 +1,53 @@
+From 515251513259787f4c679299a1c379dc19ad4921 Mon Sep 17 00:00:00 2001
+From: Evan Phoenix <ephoenix@engineyard.com>
+Date: Mon, 22 Mar 2010 09:51:44 -0700
+Subject: [PATCH] Don't depend on order of elements in Set
+
+(cherry picked from commit a307fd6bd37d12d8ad6baa7e7fcfd0207e8b354a)
+---
+ activerecord/test/cases/finder_test.rb | 21 ++++++++++++++++-----
+ 1 files changed, 16 insertions(+), 5 deletions(-)
+
+diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
+index 871fdc3..8fd7d08 100644
+--- a/activerecord/test/cases/finder_test.rb
++++ b/activerecord/test/cases/finder_test.rb
+@@ -494,6 +494,18 @@ class FinderTest < ActiveRecord::TestCase
+ assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on
+ end
+
++ class SimpleEnumerable
++ include Enumerable
++
++ def initialize(ary)
++ @ary = ary
++ end
++
++ def each(&b)
++ @ary.each(&b)
++ end
++ end
++
+ def test_bind_enumerable
+ quoted_abc = %(#{ActiveRecord::Base.connection.quote('a')},#{ActiveRecord::Base.connection.quote('b')},#{ActiveRecord::Base.connection.quote('c')})
+
+@@ -503,12 +515,11 @@ class FinderTest < ActiveRecord::TestCase
+ assert_equal '1,2,3', bind(':a', :a => [1, 2, 3])
+ assert_equal quoted_abc, bind(':a', :a => %w(a b c)) # '
+
+- require 'set'
+- assert_equal '1,2,3', bind('?', Set.new([1, 2, 3]))
+- assert_equal quoted_abc, bind('?', Set.new(%w(a b c)))
++ assert_equal '1,2,3', bind('?', SimpleEnumerable.new([1, 2, 3]))
++ assert_equal quoted_abc, bind('?', SimpleEnumerable.new(%w(a b c)))
+
+- assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3]))
+- assert_equal quoted_abc, bind(':a', :a => Set.new(%w(a b c))) # '
++ assert_equal '1,2,3', bind(':a', :a => SimpleEnumerable.new([1, 2, 3]))
++ assert_equal quoted_abc, bind(':a', :a => SimpleEnumerable.new(%w(a b c))) # '
+ end
+
+ def test_bind_empty_enumerable
+--
+1.7.1
+
diff --git a/rubygem-activerecord-remove-rdoc-task.patch b/rubygem-activerecord-remove-rdoc-task.patch
new file mode 100644
index 0000000..82cf19e
--- /dev/null
+++ b/rubygem-activerecord-remove-rdoc-task.patch
@@ -0,0 +1,76 @@
+From c2928e6acd9a214d3d04ba1d059932af73443230 Mon Sep 17 00:00:00 2001
+From: Ken Dreyer <ktdreyer@ktdreyer.com>
+Date: Thu, 7 Feb 2013 20:40:36 -0700
+Subject: [PATCH] remove Rake rdoc task
+
+The ruby-rdoc package in RHEL 6 is too old. Remove any trace of it from
+the Rakefile.
+---
+ activerecord/Rakefile | 30 ------------------------------
+ 1 files changed, 0 insertions(+), 30 deletions(-)
+
+diff --git a/activerecord/Rakefile b/activerecord/Rakefile
+index 47570bd..65d68e1 100644
+--- a/activerecord/Rakefile
++++ b/activerecord/Rakefile
+@@ -1,7 +1,6 @@
+ require 'rubygems'
+ require 'rake'
+ require 'rake/testtask'
+-require 'rdoc/task'
+ require 'rake/packagetask'
+ require 'rubygems/package_task'
+
+@@ -155,26 +154,6 @@ task :build_frontbase_databases => 'frontbase:build_databases'
+ task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
+
+
+-# Generate the RDoc documentation
+-
+-RDoc::Task.new { |rdoc|
+- rdoc.rdoc_dir = 'doc'
+- rdoc.title = "Active Record -- Object-relation mapping put on rails"
+- rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
+- rdoc.options << '--charset' << 'utf-8'
+- rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
+- rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
+- rdoc.rdoc_files.include('lib/**/*.rb')
+- rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
+- rdoc.rdoc_files.include('dev-utils/*.rb')
+-}
+-
+-# Enhance rdoc task to copy referenced images also
+-task :rdoc do
+- FileUtils.mkdir_p "doc/files/examples/"
+- FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png"
+-end
+-
+
+ # Create compressed packages
+
+@@ -200,9 +179,6 @@ spec = Gem::Specification.new do |s|
+ s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite3"
+ s.require_path = 'lib'
+
+- s.extra_rdoc_files = %w( README )
+- s.rdoc_options.concat ['--main', 'README']
+-
+ s.author = "David Heinemeier Hansson"
+ s.email = "david@loudthinking.com"
+ s.homepage = "http://www.rubyonrails.org"
+@@ -249,12 +225,6 @@ task :pgem => [:package] do
+ `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
+ end
+
+-desc "Publish the API documentation"
+-task :pdoc => [:rdoc] do
+- require 'rake/contrib/sshpublisher'
+- Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
+-end
+-
+ desc "Publish the release files to RubyForge."
+ task :release => [ :package ] do
+ require 'rubyforge'
+--
+1.7.1
+
diff --git a/rubygem-activerecord-sqlite-api.patch b/rubygem-activerecord-sqlite-api.patch
new file mode 100644
index 0000000..eb9583f
--- /dev/null
+++ b/rubygem-activerecord-sqlite-api.patch
@@ -0,0 +1,25 @@
+From 6b3e7d3f9f84d53855e0af72720a923caaa58313 Mon Sep 17 00:00:00 2001
+From: Ken Dreyer <ktdreyer@ktdreyer.com>
+Date: Thu, 7 Feb 2013 21:55:51 -0700
+Subject: [PATCH] Use RHEL'6 SQLite3 Version API
+
+---
+ activerecord/test/cases/query_cache_test.rb | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
+index f7f9777..77993d8 100644
+--- a/activerecord/test/cases/query_cache_test.rb
++++ b/activerecord/test/cases/query_cache_test.rb
+@@ -52,7 +52,7 @@ class QueryCacheTest < ActiveRecord::TestCase
+ require 'sqlite3/version' if current_adapter?(:SQLite3Adapter)
+
+ Task.cache do
+- if current_adapter?(:SQLite3Adapter) && SQLite3::Version::VERSION > '1.2.5'
++ if current_adapter?(:SQLite3Adapter) && SQLite3::Version::STRING > '1.2.5'
+ assert_instance_of Fixnum, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
+ else
+ assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
+--
+1.7.1
+
diff --git a/rubygem-activerecord-xml-serialization.patch b/rubygem-activerecord-xml-serialization.patch
new file mode 100644
index 0000000..aa0b0dd
--- /dev/null
+++ b/rubygem-activerecord-xml-serialization.patch
@@ -0,0 +1,28 @@
+From e9abd0fc11dd965dc8ea4de3fa8dcb694d2b112d Mon Sep 17 00:00:00 2001
+From: Ken Dreyer <ktdreyer@ktdreyer.com>
+Date: Thu, 7 Feb 2013 22:13:30 -0700
+Subject: [PATCH] skip xml in serialization_test
+
+With the recent YAML changes, these tests fail when trying calling
+from_xml. The simplest fix is to remove from_xml and to_xml from the
+test, and only test to_json and from_json.
+---
+ activerecord/test/cases/serialization_test.rb | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/activerecord/test/cases/serialization_test.rb b/activerecord/test/cases/serialization_test.rb
+index 8841694..d2cfb62 100644
+--- a/activerecord/test/cases/serialization_test.rb
++++ b/activerecord/test/cases/serialization_test.rb
+@@ -2,7 +2,7 @@ require "cases/helper"
+ require 'models/contact'
+
+ class SerializationTest < ActiveRecord::TestCase
+- FORMATS = [ :xml, :json ]
++ FORMATS = [ :json ]
+
+ def setup
+ @contact_attributes = {
+--
+1.7.1
+
diff --git a/rubygem-activerecord.spec b/rubygem-activerecord.spec
index 88a9528..8ac996a 100644
--- a/rubygem-activerecord.spec
+++ b/rubygem-activerecord.spec
@@ -1,11 +1,15 @@
# Generated from activerecord-1.15.5.gem by gem2rpm -*- rpm-spec -*-
%global gem_name activerecord
+%if 0%{?el6}
+%global rubyabi 1.8
+%else
%global rubyabi 1.9.1
+%endif
Summary: Implements the ActiveRecord pattern for ORM
Name: rubygem-%{gem_name}
Epoch: 1
-Version: 3.2.11
+Version: 2.3.16
Release: 1%{?dist}
Group: Development/Languages
License: MIT
@@ -13,28 +17,62 @@ URL: http://www.rubyonrails.org
Source0: http://rubygems.org/downloads/activerecord-%{version}.gem
# git clone http://github.com/rails/rails.git
# cd rails/activerecord/
-# git checkout v3.2.11
-# tar czvf activerecord-3.2.11-tests.tgz test/
+# git checkout v2.3.16
+# tar czvf activerecord-2.3.16-tests.tgz test/
Source1: activerecord-%{version}-tests.tgz
+
+# RDoc on RHEL 6 is too old to work with Rake.
+# Patch the Rakefile to remove it.
+Patch1: rubygem-activerecord-remove-rdoc-task.patch
+
+# Tests fail without f748d36b4014418c48553836a56b4bec74e15e49
+# See https://github.com/rails/rails/issues/4292
+# (Merged in Rails 3.0)
+# I've cherry-picked onto v2.3.16 to account for line number differences.
+Patch2: rubygem-activerecord-fix-more-failing-tests.patch
+
+# Test test_bind_enumerable fails without
+# a307fd6bd37d12d8ad6baa7e7fcfd0207e8b354a (merged in Rails 3.0)
+# I've cherry-picked onto v2.3.16.
+Patch3: rubygem-activerecord-fix-set-order.patch
+
+# Test test_cache_does_not_wrap_string_results_in_arrays fails:
+# NameError: uninitialized constant SQLite3::Version::VERSION
+# Fix is in b7e5a64e1612220d315f5a67d28879d331cee546
+# (merged in Rails 3.0).
+Patch4: rubygem-activerecord-sqlite-api.patch
+
+# Test test_serialize_should_allow_attribute_except_filtering and
+# test_serialize_should_be_reversible fail:
+# ActiveSupport::CoreExtensions::Hash::Conversions::DisallowedType: Disallowed type attribute: "yaml"
+# Patch the tests to avoid calling "from_xml".
+Patch5: rubygem-activerecord-xml-serialization.patch
+
Requires: ruby(abi) = %{rubyabi}
Requires: ruby(rubygems)
Requires: rubygem(activesupport) = %{version}
-Requires: rubygem(activemodel) = %{version}
-Requires: rubygem(arel)
-Requires: rubygem(tzinfo) >= 0.3.23
+%if 0%{?fedora}
BuildRequires: rubygems-devel
-BuildRequires: rubygem(bcrypt-ruby)
-BuildRequires: rubygem(activesupport) = %{version}
-BuildRequires: rubygem(activemodel) = %{version}
-BuildRequires: rubygem(sqlite3)
-BuildRequires: rubygem(erubis)
-BuildRequires: rubygem(mocha)
-BuildRequires: rubygem(arel)
-BuildRequires: rubygem(tzinfo) >= 0.3.23
-BuildRequires: rubygem(minitest)
+%else
+BuildRequires: ruby(rubygems)
+%endif
+BuildRequires(check): rubygem(rake)
+BuildRequires(check): rubygem(activesupport) = %{version}
+BuildRequires(check): rubygem(sqlite3-ruby)
+BuildRequires(check): rubygem(mocha)
+
BuildArch: noarch
Provides: rubygem(%{gem_name}) = %{version}
+# macros for RHEL6 compatibility:
+%{!?gem_dir: %global gem_dir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)}
+%{!?gem_instdir: %global gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}}
+%{!?gem_libdir: %global gem_libdir %{gem_instdir}/lib}
+%{!?gem_cache: %global gem_cache %{gem_dir}/cache/%{gem_name}-%{version}.gem}
+%{!?gem_spec: %global gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}.gemspec}
+%{!?gem_docdir: %global gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}}
+%{!?gem_extdir: %global gem_extdir %{_libdir}/gems/exts/%{gem_name}-%{version}}
+
%description
Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database
tables and classes together for business objects, like Customer or
@@ -56,6 +94,20 @@ mkdir -p .%{gem_dir}
gem install --local --install-dir .%{gem_dir} \
--force --rdoc %{SOURCE0}
+# move the tests into place
+tar xzf %{SOURCE1} -C .%{gem_instdir}
+
+pushd .%{gem_instdir}
+%patch1 -p2
+%patch2 -p2
+%patch3 -p2
+%if 0%{?el6}
+# ActiveRecord needs Patch4 with RHEL 6's rubygem-sqlite3-ruby
+%patch4 -p2
+%endif
+%patch5 -p2
+popd
+
%build
%install
@@ -64,42 +116,31 @@ cp -a .%{gem_dir}/* %{buildroot}%{gem_dir}
%check
pushd .%{gem_instdir}
-
-tar xzvf %{SOURCE1}
-
-# load_path is not available, remove its require.
-sed -i '1,2d' test/cases/helper.rb
-
-ruby -I.:test:lib << EOF
- test_files = Dir.glob( "test/cases/**/*_test.rb" )
- test_files.reject! { |x| x =~ %r|/adapters/| }
-
- # Only test sqlite3 backend
- test_files += Dir.glob("test/cases/adapters/sqlite3/*_test.rb")
-
- # To prevent a circular dependency w/ actionpack.
- test_files.delete('test/cases/session_store/session_test.rb')
-
- test_files.each { |f| require f }
-EOF
-
+ rake test_sqlite3 --trace
popd
%files
%dir %{gem_instdir}
%{gem_libdir}
-%doc %{gem_instdir}/MIT-LICENSE
%exclude %{gem_cache}
%{gem_spec}
%files doc
%doc %{gem_docdir}
-%doc %{gem_instdir}/CHANGELOG.md
-%doc %{gem_instdir}/README.rdoc
+%doc %{gem_instdir}/CHANGELOG
+%doc %{gem_instdir}/README
%doc %{gem_instdir}/examples
+%{gem_instdir}/RUNNING_UNIT_TESTS
+%{gem_instdir}/test
+%{gem_instdir}/install.rb
+%{gem_instdir}/Rakefile
%changelog
+* Thu Feb 07 2013 Ken Dreyer <ktdreyer@ktdreyer.com> - 1:2.3.16-1
+- Downgrade to ActiveRecord 2.3.16.
+- RHEL 6 compatibility
+
* Wed Jan 09 2013 Vít Ondruch <vondruch@redhat.com> - 1:3.2.11-1
- Update to ActiveRecord 3.2.11.
diff --git a/sources b/sources
index 175f66a..f84209e 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
-deef6128890f8e081699ea245a8e763f activerecord-3.2.11-tests.tgz
-0a015404f80bdd7b03b03c667d976e9f activerecord-3.2.11.gem
+29e82c71c7f9847634c15d749814efeb activerecord-2.3.16-tests.tgz
+cb2f369b6270c5bcff073460f1ce4345 activerecord-2.3.16.gem