Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updates rails in gemfile to 3.1.1, fixes broken tests

  • Loading branch information...
commit f86eb36266a209e98a8276b3dde6441b129f2566 1 parent e7ea6ba
@ramontayag authored
View
7 Gemfile
@@ -1,10 +1,7 @@
source "http://rubygems.org"
-# Add dependencies required to use your gem here.
-# Example:
-gem "activerecord", ">= 3.0.0"
-# Add dependencies to develop your gem here.
-# Include everything needed to run rake, tests, features, etc.
+gem "activerecord", ">= 3.1.1"
+
group :development do
gem "rspec", "~> 2.6.0"
gem "bundler", "~> 1.0.0"
View
32 Gemfile.lock
@@ -1,18 +1,19 @@
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.0.7)
- activesupport (= 3.0.7)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activesupport (3.0.7)
- arel (2.0.10)
- builder (2.1.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ arel (2.2.1)
+ builder (3.0.0)
diff-lcs (1.1.3)
ffi (1.0.10)
git (1.2.5)
@@ -20,12 +21,13 @@ GEM
thor (~> 0.14.6)
guard-rspec (0.5.3)
guard (>= 0.8.4)
- i18n (0.5.0)
+ i18n (0.6.0)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
libnotify (0.5.9)
+ multi_json (1.0.3)
rake (0.9.2.2)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
@@ -38,7 +40,7 @@ GEM
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
- sqlite3 (1.3.3)
+ sqlite3 (1.3.4)
thor (0.14.6)
tzinfo (0.3.31)
@@ -46,7 +48,7 @@ PLATFORMS
ruby
DEPENDENCIES
- activerecord (>= 3.0.0)
+ activerecord (= 3.1.1)
bundler (~> 1.0.0)
guard-rspec
jeweler (~> 1.6.2)
View
32 spec/ordered_tree_spec.rb
@@ -29,20 +29,30 @@
# This is especially important for working with root items that may belong to different accounts
it "should only work within that scope" do
# when the scope is an association
- ordered_tree Page, :scope => :person do
- Page.create(:person => @people[0]).position.should == 1
- Page.create(:person => @people[2]).position.should == 1
- Page.create(:person => @people[0]).position.should == 2
- Page.create(:person => @people[1]).position.should == 1
+ Object.send :remove_const, 'Page'
+ class Page < ActiveRecord::Base
+ belongs_to :person
+ ordered_tree :scope => :person
end
+ Page.create(:person => @people[0]).position.should == 1
+ Page.create(:person => @people[2]).position.should == 1
+ Page.create(:person => @people[0]).position.should == 2
+ Page.create(:person => @people[1]).position.should == 1
+
# when the scope is an association id
- ordered_tree Page, :scope => :person_id do
- Page.create(:person => @people[0]).position.should == 3
- Page.create(:person => @people[2]).position.should == 2
- Page.create(:person => @people[0]).position.should == 4
- Page.create(:person => @people[1]).position.should == 2
+ Object.send :remove_const, 'Page'
+ class Page < ActiveRecord::Base
+ belongs_to :person
+ ordered_tree :scope => :person_id
end
+ Page.create(:person => @people[0]).position.should == 3
+ Page.create(:person => @people[2]).position.should == 2
+ Page.create(:person => @people[0]).position.should == 4
+ Page.create(:person => @people[1]).position.should == 2
+
+ Object.send :remove_const, 'Page'
+ load 'fixtures/page.rb'
end
it "should only work within that scope_condition overridden method" do
@@ -73,7 +83,7 @@ def scope_condition
page_2.position.should == 1
page_2.parent.should == nil
page_3.position.should == 1
- page_3.parent.should == page_1
+ page_3.parent.id.should == page_1.id
page_4.position.should == 2
page_4.parent.should == nil
page_5.position.should == 1
View
6 spec/spec_helper.rb
@@ -45,6 +45,12 @@ def reset_database
end
end
+# Using this doesn't seem to work when >= Rails 3.1
+# http://stackoverflow.com/q/7446358/61018
+#
+# I haven't found a real solution but will just make separate classes
+# to have different configurations, so we don't have to open
+# things up in the spec.
def ordered_tree(klass, *opts)
klass.ordered_tree *opts
yield
Please sign in to comment.
Something went wrong with that request. Please try again.