[Git][noosfero/noosfero][master] 2 commits: Fix cache_key expiration on image uploaded in articles

Antonio Terceiro gitlab at mg.gitlab.com
Fri Nov 13 15:16:39 BRST 2015


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
67589517 by Thiago Ribeiro at 2015-11-13T14:57:32Z
Fix cache_key expiration on image uploaded in articles

Signed-off-by: Daniela Soares Feitosa <danielafeitosa at colivre.coop.br>
Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>

- - - - -
bd70a538 by Antonio Terceiro at 2015-11-13T17:16:19Z
Merge branch 'fix_image_cache_key' into 'master'

Fix cache_key expiration on image uploaded in articles

Signed-off-by: Daniela Soares Feitosa <danielafeitosa at colivre.coop.br>

See merge request !717
- - - - -


2 changed files:

- lib/create_thumbnails_job.rb
- test/unit/create_thumbnails_job_test.rb


Changes:

=====================================
lib/create_thumbnails_job.rb
=====================================
--- a/lib/create_thumbnails_job.rb
+++ b/lib/create_thumbnails_job.rb
@@ -3,5 +3,9 @@ class CreateThumbnailsJob < Struct.new(:class_name, :file_id)
     return unless class_name.constantize.exists?(file_id)
     file = class_name.constantize.find(file_id)
     file.create_thumbnails
+    article = Article.where(:image_id => file_id).first
+    if article
+      article.touch
+    end
   end
 end


=====================================
test/unit/create_thumbnails_job_test.rb
=====================================
--- a/test/unit/create_thumbnails_job_test.rb
+++ b/test/unit/create_thumbnails_job_test.rb
@@ -34,4 +34,16 @@ class CreateThumbnailsJobTest < ActiveSupport::TestCase
     end
   end
 
+  should 'expire cache of articles that use an image that just got a thumbnail' do
+    person = create_user('test_user').person
+    file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => person)
+    article = create(Article, :name => 'test', :image_builder => {
+       :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
+    }, :profile_id => person.id)
+    old_cache_key = article.cache_key
+    job = CreateThumbnailsJob.new(file.class.name, file.id)
+    job.perform
+    process_delayed_job_queue
+    assert_not_equal old_cache_key, Article.find(article.id).reload.cache_key
+  end
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/1e5370563a661ed048c466a45eddd7fa33b290b8...bd70a538c161042ffe70ec22e1a97ae5ffa2e3dd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151113/a35201b5/attachment.html>


More information about the Noosfero-dev mailing list