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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31ee3732403546691dbd1deef7d620263fae1981
4
- data.tar.gz: ce0fcb850fdc7b0e3a3440827e322146bee5e63a
3
+ metadata.gz: b28022b96a300e723ae2377d8322e285298f2b79
4
+ data.tar.gz: 6d006c9c8cb191997c23f7395e95c0b3a3cf7918
5
5
  SHA512:
6
- metadata.gz: 7ce07210f73a7903ee56c31bad4bb46c2120b3132abef6bf8a3b701a85324c2d1fb496b8e89614d59a2b81f9c5c0fa9b7dd2e1c3da09f937bca5a8de956d50c5
7
- data.tar.gz: c0a4188a0fdeb8fdcfb48a1cbfd11ad77463b72b799312ad238f29b02e5716977082db63cebd478ed78b7e136bfb5f860d7a4056e90125669b11049d7ddc4a7e
6
+ metadata.gz: 5537320180706f97934bad8e6a16bca311bfe7d5e8e092a3d4e08228639af911a8778dfcce949698fcc56adb51c99c48466135e66f16820bbe433ca62d7d2ec4
7
+ data.tar.gz: d2fbcb5b365937c789614121107acc97f2684fe7e9aa56aeb1739a051690bdb30a385fd62302e48310f0db70c85f7bdb26053feacb5ba8cce327eecc0ac4377f
@@ -1,3 +1,3 @@
1
1
  module BuiltInData
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
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?
@@ -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 static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
- config.static_cache_control = 'public, max-age=3600'
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
Binary file