frozen_record 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/frozen_record/base.rb +2 -2
- data/lib/frozen_record/test_helper.rb +10 -12
- data/lib/frozen_record/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/test_helper_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 933e76edb412172ed157cf1ed9e574707fa7061f
|
4
|
+
data.tar.gz: 8b515acc39df4dd9de0e09d5fb8318fe9003ba1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e91cf29881b8d0f5b972df7e849cf0f3b621ac6f2ce64b6cf6dba771c3cf247add9c91f9d3fe044b9244b1f9009545e117463352559ce96153ea3374636f8087
|
7
|
+
data.tar.gz: 4496c6d25dc7e487df51efeabd808e0df16cde00cd834eee0d46ab11d51e25cf7f5a36fc56e274e8d18086477c123ff819624457e663e450017266db5dd7653e
|
data/lib/frozen_record/base.rb
CHANGED
@@ -6,24 +6,24 @@ module FrozenRecord
|
|
6
6
|
def load_fixture(model_class, alternate_base_path)
|
7
7
|
@cache ||= {}
|
8
8
|
|
9
|
-
|
9
|
+
unless model_class < FrozenRecord::Base
|
10
|
+
raise ArgumentError, "Model class (#{model_class}) does not inherit from #{FrozenRecord::Base}"
|
11
|
+
end
|
10
12
|
|
11
13
|
return if @cache.key?(model_class)
|
12
14
|
|
13
|
-
@cache[model_class]
|
14
|
-
old_base_path: model_class.base_path,
|
15
|
-
old_auto_reloading: model_class.auto_reloading,
|
16
|
-
}
|
15
|
+
@cache[model_class] ||= model_class.base_path
|
17
16
|
|
18
|
-
model_class.auto_reloading = true
|
19
17
|
model_class.base_path = alternate_base_path
|
18
|
+
model_class.load_records(force: true)
|
20
19
|
end
|
21
20
|
|
22
21
|
def unload_fixtures
|
23
|
-
@cache
|
24
|
-
|
25
|
-
|
26
|
-
model_class.
|
22
|
+
return unless defined?(@cache) && @cache
|
23
|
+
|
24
|
+
@cache.each do |model_class, old_base_path|
|
25
|
+
model_class.base_path = old_base_path
|
26
|
+
model_class.load_records(force: true)
|
27
27
|
end
|
28
28
|
|
29
29
|
@cache = nil
|
@@ -32,8 +32,6 @@ module FrozenRecord
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def ensure_model_class_is_frozenrecord(model_class)
|
35
|
-
return if model_class < FrozenRecord::Base
|
36
|
-
raise ArgumentError, "Model class (#{model_class}) does not inherit from #{FrozenRecord::Base}"
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/test_helper_spec.rb
CHANGED
@@ -47,5 +47,11 @@ describe 'test fixture loading' do
|
|
47
47
|
|
48
48
|
expect(Country.count).to be == 3
|
49
49
|
end
|
50
|
+
|
51
|
+
it 'does has no effect if no alternate fixtures were loaded' do
|
52
|
+
FrozenRecord::TestHelper.unload_fixtures
|
53
|
+
|
54
|
+
expect(Country.count).to be == 3
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frozen_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|