File tree Expand file tree Collapse file tree 5 files changed +20
-4
lines changed Expand file tree Collapse file tree 5 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ def self.fragmented(serializer)
152
152
# @todo require less code comments. See
153
153
# https://github.com/rails-api/active_model_serializers/pull/1249#issuecomment-146567837
154
154
def self . cache ( options = { } )
155
- self . _cache = ActionController :: Base . cache_store if Rails . configuration . action_controller . perform_caching
155
+ self . _cache = ActiveModelSerializers . config . cache_store if ActiveModelSerializers . config . perform_caching
156
156
self . _cache_key = options . delete ( :key )
157
157
self . _cache_only = options . delete ( :only )
158
158
self . _cache_except = options . delete ( :except )
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ class Railtie < Rails::Railtie
8
8
end
9
9
end
10
10
11
+ initializer 'active_model_serializers.caching' do
12
+ ActiveSupport . on_load ( :action_controller ) do
13
+ ActiveModelSerializers . config . cache_store = ActionController ::Base . cache_store
14
+ ActiveModelSerializers . config . perform_caching = Rails . configuration . action_controller . perform_caching
15
+ end
16
+ end
17
+
11
18
initializer 'generators' do |app |
12
19
app . load_generators
13
20
require 'generators/serializer/resource_override'
Original file line number Diff line number Diff line change 5
5
module ActiveModelSerializers
6
6
mattr_accessor ( :logger ) { ActiveSupport ::TaggedLogging . new ( ActiveSupport ::Logger . new ( STDOUT ) ) }
7
7
8
+ def self . config
9
+ ActiveModel ::Serializer . config
10
+ end
11
+
8
12
extend ActiveSupport ::Autoload
9
13
autoload :Model
10
14
autoload :Callbacks
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class Serializer
4
4
module Adapter
5
5
class FragmentCacheTest < Minitest ::Test
6
6
def setup
7
+ super
7
8
@spam = Spam ::UnrelatedLink . new ( id : 'spam-id-1' )
8
9
@author = Author . new ( name : 'Joao M. D. Moura' )
9
10
@role = Role . new ( name : 'Great Author' , description : nil )
Original file line number Diff line number Diff line change 1
- class Foo < Rails ::Application
1
+ class ActiveModelSerializers :: RailsApplication < Rails ::Application
2
2
if Rails ::VERSION ::MAJOR >= 4
3
3
config . eager_load = false
4
+
4
5
config . secret_key_base = 'abc123'
5
- config . action_controller . perform_caching = true
6
+
6
7
config . active_support . test_order = :random
8
+
7
9
config . logger = Logger . new ( nil )
10
+
11
+ config . action_controller . perform_caching = true
8
12
ActionController ::Base . cache_store = :memory_store
9
13
end
10
14
end
11
- Foo . initialize!
15
+ ActiveModelSerializers :: RailsApplication . initialize!
12
16
13
17
module TestHelper
14
18
Routes = ActionDispatch ::Routing ::RouteSet . new
You can’t perform that action at this time.
0 commit comments