[noosfero/noosfero][master] 2 commits: blocks: make sure limit is integer on get_limit

Antonio Terceiro gitlab at gitlab.com
Fri Apr 24 10:49:30 BRT 2015


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
486e450c by Daniela Feitosa at 2015-04-24T01:52:07Z
blocks: make sure limit is integer on get_limit

Blocks configured before the definition of limit type were strings and were
crashing

- - - - -
17dff5dd by Antonio Terceiro at 2015-04-24T13:49:16Z
Merge branch 'block_limit' into 'master'

blocks: make sure limit is integer on get_limit

Blocks configured before the definition of limit type were strings and were
crashing

See merge request !558

- - - - -


2 changed files:

- app/models/block.rb
- test/unit/block_test.rb


Changes:

=====================================
app/models/block.rb
=====================================
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -23,7 +23,7 @@ class Block < ActiveRecord::Base
   end
 
   def get_limit
-    [0,limit].max
+    [0,limit.to_i].max
   end
 
   def embed_code


=====================================
test/unit/block_test.rb
=====================================
--- a/test/unit/block_test.rb
+++ b/test/unit/block_test.rb
@@ -330,4 +330,11 @@ class BlockTest < ActiveSupport::TestCase
     block.save!
     assert !block.display_to_user?(person_friend)
   end
+
+  should 'get limit as a number when limit is string' do
+    block = RecentDocumentsBlock.new
+    block.settings[:limit] = '5'
+    assert block.get_limit.is_a?(Fixnum)
+  end
+
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/083d29d3651b5b90ca598978b8dee7a5f3a05b41...17dff5dd289cacb2a4e4cce9a422604c3e961358
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150424/9d4ebb78/attachment.html>


More information about the Noosfero-dev mailing list