huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

Possible regression in 0.4.5 - updates not reflected on next read #73

Closed tovodeverett closed 8 years ago

tovodeverett commented 9 years ago

I believe I am seeing a regression in 0.4.5. The following code works as expected with 0.4.4, but does not work as expected with 0.4.5:

p Setting.test# expect nil
Setting.test= 'foo'
p Setting.test# expect 'foo', get nil

It appears that writes do not invalidate or update the cache, whereas in 0.4.4 they did.

sandrew commented 9 years ago

+1 getting in test environment in RSpec

savef commented 8 years ago

This is an issue with Rails really, that it doesn't run after_commit callbacks in tests. See here for more info, it's already fixed in Rails 5. For your Rails 4 tests DHH posted a solution here. Basically, change this:

test "hello world" do
  assert_equal "Hello, world!", hello_world
end

To this:

uses_transaction :test_hello_world
test "hello world" do
  assert_equal "Hello, world!", hello_world
end
wojtek-krysiak commented 8 years ago

In my case I cleared all cache before assertion by Rails.cache.clear

huacnlee commented 8 years ago

Use new version 0.5.x

tovodeverett commented 8 years ago

Is this supposedly fixed in 0.5.3, or is there a later version of 0.5.x I should be using? I'm seeing issues with my test suite when I update from 0.4.4 to 0.5.3. The problems go away when I revert to 0.4.4.

huacnlee commented 8 years ago

@tovodeverett Which Rails version?

tovodeverett commented 8 years ago

Rails 4.2.5.1 currently. When the regression first cropped up between 0.4.4 and 0.4.5 back in September, I was using Rails 4.2.4.

justin808 commented 8 years ago

I have a PR on this issue #86.