[Git][noosfero/noosfero][master] 2 commits: Retrieves uploaded image as first_image

Leandro Nunes gitlab at mg.gitlab.com
Mon Jun 26 10:06:50 BRT 2017


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
5fc7c52c by Gabriel Silva at 2017-06-25T06:38:38+00:00
Retrieves uploaded image as first_image

Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>

- - - - -
dc57ad08 by Leandro Nunes at 2017-06-26T13:06:06+00:00
Merge branch 'track_thumb' into 'master'

Retrieves uploaded image as first_image

Closes #274

See merge request !1256
- - - - -


2 changed files:

- app/models/article.rb
- test/unit/article_test.rb


Changes:

=====================================
app/models/article.rb
=====================================
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -864,7 +864,7 @@ class Article < ApplicationRecord
   end
 
   def first_image
-    img = ( image.present? && { 'src' => File.join([Noosfero.root, image.public_filename].join) } ) ||
+    img = ( image.present? && { 'src' => File.join([Noosfero.root, image.public_filename(:uploaded)].join) } ) ||
           Nokogiri::HTML.fragment(self.lead.to_s).css('img[src]').first ||
           Nokogiri::HTML.fragment(self.body.to_s).search('img').first
     img.nil? ? '' : img['src']


=====================================
test/unit/article_test.rb
=====================================
--- a/test/unit/article_test.rb
+++ b/test/unit/article_test.rb
@@ -1687,7 +1687,7 @@ class ArticleTest < ActiveSupport::TestCase
     )
     img = {}
     img.expects(:present?).returns true
-    img.expects(:public_filename).returns 'pic.jpg'
+    img.expects(:public_filename).with(:uploaded).returns 'pic.jpg'
     a.expects(:image).at_least_once.returns img
     assert_equal 'pic.jpg', a.first_image
   end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/07bcc0a9a53453fdb4cd95811f436e27811582cc...dc57ad0888bf9ecd14b8daf266a34164ced3198c

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/07bcc0a9a53453fdb4cd95811f436e27811582cc...dc57ad0888bf9ecd14b8daf266a34164ced3198c
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170626/ac2ee291/attachment-0001.html>


More information about the Noosfero-dev mailing list