Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed specs; hooked up logging

  • Loading branch information...
commit 6f28083ce7b1978097b8d002474688655a4f9fb6 1 parent 3248163
Joe Moore & Ryan Dy authored
10 README.textile
View
@@ -1,4 +1,12 @@
-h1. ACTS_AS-FU
+h2. Changes by Pivotal:
+
+In the original implementation, one could not truly use two different database connections: ActsAsFu would use ActiveRecord::Base's connection, or setting ActsAsFu's connection would change ActiveRecord::Base's connection globally, breaking other tests.
+
+To fix this, created ActsAsFu::Connection, an abstract class that extends from ActiveRecord::Base. This segregates ActsAsFu's database connection (to whatever database technology) from ActiveRecord::Base, and thus from the rest of the project.
+
+<hr/>
+
+h1. ACTS-AS-FU
Now you have no excuse for not test-driving your ActiveRecord
extending plugins.
7 lib/acts_as_fu/base.rb
View
@@ -11,10 +11,9 @@ class Connection < ActiveRecord::Base
self.abstract_class = true
def self.connect!(config={})
-# p "ActsAsFu::Connection for #{config.inspect}"
- @log = ""
-# self.logger = Logger.new(StringIO.new(log))
-# self.connection.disconnect! rescue nil
+ @@log = ""
+ self.logger = Logger.new(StringIO.new(log))
+ self.connection.disconnect! rescue nil
self.establish_connection(config)
end
end
6 spec/acts_as_fu_spec.rb
View
@@ -53,7 +53,7 @@ def self.awesome?; true end
describe "the class" do
it "is a subclass of ActiveRecord::Base" do
- Foo.superclass.should == ActiveRecord::Base
+ Foo.superclass.should == ActsAsFu::Connection
end
it "has specified attributes" do
@@ -121,7 +121,7 @@ class << Foo; attr_reader :bar end
end
it "allows connection to custom DB config" do
- ActsAsFu.connect! \
+ ActsAsFu::Connection.connect! \
:adapter => 'sqlite3',
:database => db
@@ -140,7 +140,7 @@ class << Foo; attr_reader :bar end
describe "ActsAsFu.report!" do
it "has a log" do
create_models
- ActsAsFu.log.should include("CREATE TABLE")
+ ActsAsFu::Connection.log.should include("CREATE TABLE")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.