kbaum-pickle 0.2.1.1 → 0.2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,9 +28,13 @@ module Pickle
28
28
  klass.abstract_class? || !klass.table_exists? ||
29
29
  (defined?(CGI::Session::ActiveRecordStore::Session) && klass == CGI::Session::ActiveRecordStore::Session) ||
30
30
  (defined?(::ActiveRecord::SessionStore::Session) && klass == ::ActiveRecord::SessionStore::Session)
31
- end if defined?(::ActiveRecord)
31
+ end if class_exists?(::ActiveRecord)
32
32
  @@model_classes ||= []
33
33
  end
34
+
35
+ def self.class_exists?(klass)
36
+ defined?(klass)
37
+ end
34
38
 
35
39
  # machinist adapter
36
40
  class Machinist < Adapter
@@ -45,7 +45,7 @@ module Pickle
45
45
  def find_models(factory, fields = nil)
46
46
  models_by_index(factory).clear
47
47
  model_class = pickle_config.factories[factory].klass
48
- records = model_class.find(:all, :conditions => convert_models_to_attributes(model_class, parse_fields(fields)))
48
+ records = model_class.all(:conditions => convert_models_to_attributes(model_class, parse_fields(fields)))
49
49
  records.each {|record| store_model(factory, nil, record)}
50
50
  end
51
51
 
@@ -154,4 +154,4 @@ module Pickle
154
154
  models_by_index(factory) << record
155
155
  end
156
156
  end
157
- end
157
+ end
data/pickle.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kbaum-pickle}
8
- s.version = "0.2.1.1"
8
+ s.version = "0.2.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ian White"]
@@ -25,6 +25,11 @@ describe Pickle::Adapter do
25
25
  Pickle::Adapter.model_classes.should_not include(ActiveRecord::SessionStore::Session)
26
26
  end
27
27
  end
28
+
29
+ it 'should tolerate active record not being defined' do
30
+ Pickle::Adapter.should_receive(:class_exists?).with(::ActiveRecord).and_return(false)
31
+ Pickle::Adapter.model_classes.should be_empty
32
+ end
28
33
 
29
34
  it "should not include classes without a table" do
30
35
  klass = Class.new(ActiveRecord::Base)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kbaum-pickle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.1
4
+ version: 0.2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White