Permalink
Browse files

fix failing specs due to #connection not being defined

  • Loading branch information...
1 parent ddb9b5f commit 5b987d63596b95d41b5911789981bf226e395ff2 @technoweenie committed Jul 4, 2008
Showing with 6 additions and 4 deletions.
  1. +4 −3 lib/model_stubbing/model.rb
  2. +2 −1 lib/model_stubbing/stub.rb
View
7 lib/model_stubbing/model.rb
@@ -99,12 +99,13 @@ def insert
end
def purge
- #Fixtures.cache_for_connection(connection).delete(@model_class.table_name) if defined?(Fixtures)
- connection.delete "DELETE FROM #{connection.quote_table_name(@model_class.table_name)}", 'Fixture Delete'
+ if connection
+ connection.delete "DELETE FROM #{connection.quote_table_name(@model_class.table_name)}", 'Model Stubs Delete'
+ end
end
def connection
- @connection ||= model_class.connection
+ @connection ||= model_class.respond_to?(:connection) && model_class.connection
end
end
end
View
3 lib/model_stubbing/stub.rb
@@ -167,7 +167,8 @@ def value_list
column_name = column_name_for key
column = column_for column_name
value = value.record.id if value.is_a?(Stub)
- fixtures << @stub.connection.quote(value, column).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")
+ quoted = @stub.connection ? @stub.connection.quote(value, column) : %("#{value.to_s}")
+ fixtures << quoted.gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")
end.join(", ")
end

0 comments on commit 5b987d6

Please sign in to comment.