Skip to content

Commit

Permalink
Regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
methodmissing committed Feb 14, 2009
1 parent 4ab699b commit 234c3b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/scrooge/framework/base.rb
Expand Up @@ -208,7 +208,7 @@ def scopes?
# Return the scopes storage path for the current framework.
#
def scopes_path
@profiles_path ||= File.join( config, 'scrooge', 'scopes' )
@scopes_path ||= File.join( config, 'scrooge', 'scopes' )
end

# Return the scopes storage path for a given scope and optional filename.
Expand Down Expand Up @@ -258,7 +258,7 @@ def to_scope!
GUARD.synchronize do
scope = Time.now.to_i
dump_scope!( scope )
scope
scope.to_s
end
end

Expand Down
8 changes: 5 additions & 3 deletions spec/units/scrooge/framework/base_spec.rb
Expand Up @@ -77,14 +77,15 @@
@signature = Time.now.to_i.to_s
FileUtils.mkdir_p( File.join( @base.scopes_path, @signature ) )
@base.scopes.should include( @signature )
FileUtils.rm_r( File.join( @base.scopes_path, @signature ) )
end
end

it "should be able to determine if there's any previously persisted scopes" do
with_rails do
@base.stub!(:config).and_return( CONFIG )
@base.send( :ensure_scopes_path )
@base.scopes?().should eql( true )
@base.scopes?().should eql( false )
end
end

Expand All @@ -106,7 +107,8 @@
with_rails do
@base.stub!(:config).and_return( CONFIG )
::Rails.stub!(:env).and_return( "test" )
lambda{ @base.to_scope! }.should change( @base.scopes, :size )
@base.to_scope!()
@base.scopes.size.should == 1
end
end

Expand All @@ -115,7 +117,7 @@
@base.stub!(:config).and_return( CONFIG )
::Rails.stub!(:env).and_return( "test" )
@scope = @base.to_scope!
lambda{ @base.from_scope!( @scope ) }.should change( Scrooge::Base.profile.tracker, :object_id )
lambda{ Scrooge::Base.profile.scope = @base.from_scope!( @scope ) }.should change( Scrooge::Base.profile.tracker, :object_id )
end
end

Expand Down
9 changes: 5 additions & 4 deletions spec/units/scrooge/tracker/model_spec.rb
Expand Up @@ -30,7 +30,8 @@

it "should be able to restore itself from a serialized representation" do
@model << [:name, :description, :price]
lambda{ @model.marshal_load( { "Product" => [:price] } ) }.should change( @model.attributes, :size ).from(3).to(1)
@model.marshal_load( { "Product" => [:price] } )
@model.attributes.size.should eql( 1 )
end

it "should be able to render a attribute selection SQL snippet from it's referenced attributes" do
Expand All @@ -50,11 +51,11 @@
end

it "should be able to merge itself with another model tracker" do
@other_model << [:name, :description]
@other_model << %w(name description)
@model.merge( @other_model )
@model.attributes.to_a.should eql( [:name, :description] )
@model.attributes.to_a.sort.should eql( %w(description name) )
@another_model.merge( @model )
@another_model.attributes.to_a.should eql( [:name, :description] )
@another_model.attributes.to_a.sort.should eql( %w(description name) )
@another_model.attributes.should_not_receive(:merge)
@another_model.merge( nil )
end
Expand Down

0 comments on commit 234c3b3

Please sign in to comment.