Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix appveyor failure cache not being expired #1168

Merged
merged 1 commit into from
Sep 17, 2015
Merged

Conversation

bf4
Copy link
Member

@bf4 bf4 commented Sep 17, 2015

Fixes #1130

The cache isn't being expired:

def render_object_expired_with_cache_enabled
  generate_cached_serializer(post)
  post.title = 'ZOMG a New Post' # new title will only show up if cache expired
  sleep 0.1
  render json: post
end

 def test_render_with_cache_enable_and_expired
        ActionController::Base.cache_store.clear
        get :render_object_expired_with_cache_enabled

        expected = {
          id: 1,
          title: 'ZOMG a New Post',... # expect the new title
end
PostSerializer = Class.new(ActiveModel::Serializer) do
  cache key: 'post', expires_in: 0.1, skip_digest: true
....
 1) Failure:
ActionController::Serialization::ImplicitSerializerTest#test_cache_expiration_on_update 
[C:/projects/active-model-serializers/test/action_controller/serialization_test.rb:394]:
--- expected
+++ actual
@@ -1 +1 @@
-"{\"id\":1,\"title\":\"ZOMG a New Post\",
  \"body\":\"Body\",\"comments\":[{\"id\":1,\"body\":\"ZOMG A COMMENT\"}],\"blog\":{\"id\":999,\"name\":\"Custom blog\"},\"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"
+"{\"id\":1,\"title\":\"New Post\",
  \"body\":\"Body\",\"comments\":[{\"id\":1,\"body\":\"ZOMG A COMMENT\"}],\"blog\":{\"id\":999,\"name\":\"Custom blog\"},\"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"

@bf4 bf4 force-pushed the fix_appveyor branch 2 times, most recently from 4a39247 to a1f8c7a Compare September 17, 2015 06:26
@bf4 bf4 changed the title Fix appveyor failure on json string ordering Fix appveyor failure cache not being expired Sep 17, 2015

Timecop.travel(Time.zone.now + expires_in) do
render json: post
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, at least I removed the sleep

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bf4 added a commit that referenced this pull request Sep 17, 2015
Fix appveyor failure cache not being expired
@bf4 bf4 merged commit 3f0794b into rails-api:master Sep 17, 2015
@bf4 bf4 deleted the fix_appveyor branch September 17, 2015 15:05
bf4 added a commit to bf4/active_model_serializers that referenced this pull request Sep 17, 2015
Fix appveyor failure cache not being expired
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants