[Git][noosfero/noosfero][master] open_graph: fix test after fixes on notifications

Bráulio Bhavamitra gitlab at mg.gitlab.com
Sat Sep 10 10:05:51 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
fef0290f by Braulio Bhavamitra at 2016-09-10T10:04:17-03:00
open_graph: fix test after fixes on notifications

- - - - -


3 changed files:

- plugins/open_graph/lib/ext/uploaded_file.rb
- plugins/open_graph/lib/open_graph_plugin/stories.rb
- plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb


Changes:

=====================================
plugins/open_graph/lib/ext/uploaded_file.rb
=====================================
--- a/plugins/open_graph/lib/ext/uploaded_file.rb
+++ b/plugins/open_graph/lib/ext/uploaded_file.rb
@@ -3,6 +3,6 @@ require_dependency 'uploaded_file'
 class UploadedFile
 
   extend OpenGraphPlugin::AttachStories::ClassMethods
-  open_graph_attach_stories only: :add_an_image
+  open_graph_attach_stories only: [:add_an_image, :add_a_document]
 
 end


=====================================
plugins/open_graph/lib/open_graph_plugin/stories.rb
=====================================
--- a/plugins/open_graph/lib/open_graph_plugin/stories.rb
+++ b/plugins/open_graph/lib/open_graph_plugin/stories.rb
@@ -28,11 +28,9 @@ class OpenGraphPlugin::Stories
       models: :UploadedFile,
       on: :create,
       criteria: proc do |article, actor|
-        article.is_a? UploadedFile
+        article.is_a? UploadedFile and not article.image?
       end,
       publish_if: proc do |uploaded_file, actor|
-        # done in add_an_image
-        next false if uploaded_file.image?
         uploaded_file.published?
       end,
       object_data_url: proc do |uploaded_file, actor|
@@ -49,10 +47,10 @@ class OpenGraphPlugin::Stories
       models: :UploadedFile,
       on: :create,
       criteria: proc do |article, actor|
-        article.is_a? UploadedFile
+        article.is_a? UploadedFile and article.image?
       end,
       publish_if: proc do |uploaded_file, actor|
-        uploaded_file.image? and uploaded_file.parent.is_a? Gallery
+        uploaded_file.published? and uploaded_file.parent.is_a? Gallery
       end,
       object_data_url: proc do |uploaded_file, actor|
         uploaded_file.url.merge view: true


=====================================
plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb
=====================================
--- a/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb
+++ b/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb
@@ -54,13 +54,13 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase
     blog_post = TextArticle.create! profile: user, parent: blog, name: 'blah', author: user
     assert_last_activity user, :create_an_article, url_for(blog_post)
 
+    document = UploadedFile.create! uploaded_data: fixture_file_upload('/files/doctest.en.xhtml', 'text/html'), profile: user
+    assert_last_activity user, :add_a_document, url_for(document, document.url.merge(view: true))
+
     gallery = Gallery.create! name: 'gallery', profile: user
     image = UploadedFile.create! uploaded_data: fixture_file_upload('/files/rails.png', 'image/png'), parent: gallery, profile: user
     assert_last_activity user, :add_an_image, url_for(image, image.url.merge(view: true))
 
-    document = UploadedFile.create! uploaded_data: fixture_file_upload('/files/doctest.en.xhtml', 'text/html'), profile: user
-    assert_last_activity user, :add_a_document, url_for(document, document.url.merge(view: true))
-
     event = Event.create! name: 'event', profile: user
     assert_last_activity user, :create_an_event, url_for(event)
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/fef0290fe54f6d4d894436dc3847e32f521efc0d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160910/e7f42f26/attachment-0001.html>


More information about the Noosfero-dev mailing list