Spree::Config issues illuminated, beware caching!

166 views
Skip to first unread message

josh jacobs

unread,
Sep 6, 2011, 9:20:54 AM9/6/11
to spree...@googlegroups.com
I recently resolved an issue with Spree::Config and wanted to post my results to help the future googler.

Problem
Spree::Config values were not predictable. Sometimes they were fine and returning results as expected, but sometimes they had reverted to the default values.

Explanation
I was able to define a very simple use case that illustrated the problem. What I discovered was that running any test that invoked Spree::Config caused the values of Spree::Config preferences in my development environment to be reset to defaults. The development database was not changing, but the cached class was. 

Even though caching was disabled in test.rb (config.cache_classes = false), Spree was still caching the configuration because it apparently disregards this setting. Spree::Config behavior is to loads values first from the cache if they are available (or at least this is my understanding) and so running tests updated the cached class and was polluting my development environment.

Resolution
One solution is to add Rails.cache.clear to my tests. This is not DRY.

The better solution was to configure a different cache store for test and development. In test.rb I added config.cache_store = :memory_store, restarted spork, and everything works.

:)

Patrick McElwee

unread,
Mar 13, 2012, 8:52:32 AM3/13/12
to spree...@googlegroups.com
Thank you! I was beginning to go crazy over this. This is very well presented.

Jones Lee

unread,
Mar 13, 2012, 9:11:16 AM3/13/12
to spree...@googlegroups.com
Good find, I'd really appreciate if you could file a GH issue, it's definitely something we should look into.

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/eeI3644iHrAJ.

To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Joshua Jacobs

unread,
Mar 13, 2012, 9:17:35 AM3/13/12
to spree...@googlegroups.com

Stefan Wrobel

unread,
Apr 4, 2013, 1:22:41 PM4/4/13
to spree...@googlegroups.com
Any movement on this? I just spent the morning banging my head against the wall trying to figure out why preferences weren't being wiped when I blew out my dev database. Turns out I had to Rails. cache.clear ... which makes no sense! Caching preferences???
Reply all
Reply to author
Forward
0 new messages