Skip to content

Commit

Permalink
Finished fixing specs after Rails 3 refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed May 4, 2011
1 parent be41eb6 commit 6789220
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.0.0.pre
* Expect Rails 3
* Changed how callbacks work. Returning false in a before_move action does not block save operations. Use a validation or exception in the callback if you need that.
* Switched to RSpec
* Remove use of Comparable
8 changes: 1 addition & 7 deletions lib/awesome_nested_set/awesome_nested_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def acts_as_nested_set(options = {})
class_inheritable_reader :acts_as_nested_set_options

include CollectiveIdea::Acts::NestedSet::Model
include Comparable
include Columns
extend Columns

Expand Down Expand Up @@ -240,11 +239,6 @@ def child?
!parent_id.nil?
end

# order by left column
def <=>(x)
left <=> x.left
end

# Returns root
def root
self_and_ancestors.first
Expand Down Expand Up @@ -321,7 +315,7 @@ def same_scope?(other)
# Find the first sibling to the left
def left_sibling
siblings.where(["#{self.class.quoted_table_name}.#{quoted_left_column_name} < ?", left]).
order("#{self.class.quoted_table_name}.#{quoted_left_column_name} DESC").first
order("#{self.class.quoted_table_name}.#{quoted_left_column_name} DESC").last
end

# Find the first sibling to the right
Expand Down
4 changes: 2 additions & 2 deletions spec/awesome_nested_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ def check_structure(entries, structure)
assert !categories(:child_3).root?
end

it "before_move_callback_returning_false_halts_save" do
it "should not halt save actions" do
Category.test_allows_move = false
categories(:child_3).parent_id = nil
categories(:child_3).save.should_not be_true
categories(:child_3).save.should be_true
end
end
end

0 comments on commit 6789220

Please sign in to comment.