-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As with Rails, this allows to configure the cache store through `config.rails_heroicon_cache_store` By default it is set to :memory_store. Closes #48
- Loading branch information
1 parent
30ca6e8
commit a89c33b
Showing
7 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
require_relative "helper" | ||
|
||
module RailsHeroicon | ||
class Railtie < Rails::Railtie | ||
class << self | ||
attr_accessor :cache | ||
end | ||
|
||
class Railtie < ::Rails::Railtie | ||
initializer "rails_heroicon.helper" do | ||
ActionView::Base.send :include, Helper | ||
end | ||
|
||
config.rails_heroicon_cache_store = :memory_store | ||
|
||
initializer "rails_heroicon.cache" do | ||
::RailsHeroicon.cache = ActiveSupport::Cache.lookup_store(*config.rails_heroicon_cache_store) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
module RailsHeroicon | ||
class RailtieTest < Minitest::Test | ||
include RunInitializer | ||
|
||
def before_setup | ||
save_cache_store | ||
end | ||
|
||
def setup | ||
run_initializer | ||
end | ||
|
||
def teardown | ||
reset_cache_store | ||
run_initializer | ||
end | ||
|
||
class DefaultCacheStoreTest < RailtieTest | ||
def test_default_config | ||
assert_equal :memory_store, ::RailsHeroicon::Railtie.config.rails_heroicon_cache_store | ||
end | ||
|
||
def test_default_cache | ||
assert_instance_of ActiveSupport::Cache::MemoryStore, ::RailsHeroicon.cache | ||
end | ||
end | ||
|
||
class ChangeCacheStoreTest < RailtieTest | ||
def setup | ||
set_cache_store :null_store | ||
super | ||
end | ||
|
||
def test_changed_cache | ||
assert_instance_of ActiveSupport::Cache::NullStore, ::RailsHeroicon.cache | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters