From 486e450c98f4730bd066262e929845ce4baad4fc Mon Sep 17 00:00:00 2001 From: Daniela Feitosa Date: Fri, 24 Apr 2015 01:52:07 -0300 Subject: [PATCH] blocks: make sure limit is integer on get_limit --- app/models/block.rb | 2 +- test/unit/block_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/block.rb b/app/models/block.rb index 524d197..b3ab72e 100644 --- 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 diff --git a/test/unit/block_test.rb b/test/unit/block_test.rb index e23e84f..b1b68fe 100644 --- 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 -- libgit2 0.21.2