Permalink
Browse files

Ensure a Scope always creates a copy of the given sort descriptors.

  • Loading branch information...
1 parent 0d1d2a0 commit f7629cd07f5909b85028d6b5620210c020519c80 @alloy committed Aug 11, 2012
Showing with 6 additions and 4 deletions.
  1. +2 −1 app/scope.rb
  2. +4 −3 spec/scope_spec.rb
View
3 app/scope.rb
@@ -8,7 +8,8 @@ def initWithTarget(target)
def initWithTarget(target, predicate:predicate, sortDescriptors:sortDescriptors, inContext:context)
if init
- @target, @predicate, @sortDescriptors, @context = target, predicate, sortDescriptors, context
+ @target, @predicate, @context = target, predicate, context
+ @sortDescriptors = sortDescriptors.dup if sortDescriptors
end
self
end
View
7 spec/scope_spec.rb
@@ -18,7 +18,10 @@ module MotionData
end
it "stores a copy of the given sort descriptors" do
-
+ descriptors = [Object.new]
+ scope = Scope.alloc.initWithTarget(Author, predicate:nil, sortDescriptors:descriptors, inContext:nil)
+ scope.sortDescriptors.should == descriptors
+ scope.sortDescriptors.object_id.should.not == descriptors.object_id
end
end
@@ -97,8 +100,6 @@ module MotionData
end
describe Scope, "when building a new scope by adding sort conditions" do
- extend Predicate::Builder::Mixin
-
it "sorts by a property" do
scope1 = Scope.alloc.initWithTarget(Author)

0 comments on commit f7629cd

Please sign in to comment.