built_in_data 1.0.2 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/built_in_data/version.rb +1 -1
- data/lib/built_in_data.rb +12 -0
- data/test/built_in_data_test.rb +5 -0
- data/test/dummy/config/environments/test.rb +6 -3
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +1231 -5234
- metadata +9 -13
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b28022b96a300e723ae2377d8322e285298f2b79
|
4
|
+
data.tar.gz: 6d006c9c8cb191997c23f7395e95c0b3a3cf7918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5537320180706f97934bad8e6a16bca311bfe7d5e8e092a3d4e08228639af911a8778dfcce949698fcc56adb51c99c48466135e66f16820bbe433ca62d7d2ec4
|
7
|
+
data.tar.gz: d2fbcb5b365937c789614121107acc97f2684fe7e9aa56aeb1739a051690bdb30a385fd62302e48310f0db70c85f7bdb26053feacb5ba8cce327eecc0ac4377f
|
data/lib/built_in_data.rb
CHANGED
@@ -24,6 +24,11 @@ module BuiltInData
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# cached database id for fixture files
|
28
|
+
def built_in_object_id(key)
|
29
|
+
built_in_object_ids[key]
|
30
|
+
end
|
31
|
+
|
27
32
|
private
|
28
33
|
|
29
34
|
def prepare_objects_hash(hash)
|
@@ -45,6 +50,13 @@ module BuiltInData
|
|
45
50
|
object.save!
|
46
51
|
end
|
47
52
|
end
|
53
|
+
|
54
|
+
# memoized hash of built in object ids
|
55
|
+
def built_in_object_ids
|
56
|
+
@built_in_object_ids ||= Hash.new do |hash, key|
|
57
|
+
hash[key] = where(built_in_key: key).pluck(:id).first
|
58
|
+
end
|
59
|
+
end
|
48
60
|
end
|
49
61
|
|
50
62
|
def built_in?
|
data/test/built_in_data_test.rb
CHANGED
@@ -82,6 +82,11 @@ class BuiltInDataTest < ActiveSupport::TestCase
|
|
82
82
|
NationalPark.load_built_in_data!
|
83
83
|
assert_equal true, NationalPark.find_by(name: 'Yellowstone National Park').active
|
84
84
|
end
|
85
|
+
|
86
|
+
test 'should return built_in_data object database id' do
|
87
|
+
load_hash_data
|
88
|
+
assert_equal NationalPark.where(name: 'Yellowstone National Park').first.id, NationalPark.built_in_object_id(:test)
|
89
|
+
end
|
85
90
|
|
86
91
|
private
|
87
92
|
|
@@ -12,9 +12,11 @@ Rails.application.configure do
|
|
12
12
|
# preloads Rails for running tests, you may have to set it to true.
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
|
-
# Configure
|
16
|
-
config.
|
17
|
-
config.
|
15
|
+
# Configure public file server for tests with Cache-Control for performance.
|
16
|
+
config.public_file_server.enabled = true
|
17
|
+
config.public_file_server.headers = {
|
18
|
+
'Cache-Control' => 'public, max-age=3600'
|
19
|
+
}
|
18
20
|
|
19
21
|
# Show full error reports and disable caching.
|
20
22
|
config.consider_all_requests_local = true
|
@@ -25,6 +27,7 @@ Rails.application.configure do
|
|
25
27
|
|
26
28
|
# Disable request forgery protection in test environment.
|
27
29
|
config.action_controller.allow_forgery_protection = false
|
30
|
+
config.action_mailer.perform_caching = false
|
28
31
|
|
29
32
|
# Tell Action Mailer not to deliver emails to the real world.
|
30
33
|
# The :test delivery method accumulates sent emails in the
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|