kbaum-pickle 0.2.1.1 → 0.2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/pickle/adapter.rb +5 -1
- data/lib/pickle/session.rb +2 -2
- data/pickle.gemspec +1 -1
- data/spec/lib/pickle_adapter_spec.rb +5 -0
- metadata +1 -1
data/lib/pickle/adapter.rb
CHANGED
@@ -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
|
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
|
data/lib/pickle/session.rb
CHANGED
@@ -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.
|
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
@@ -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)
|