Commit 17dff5dd289cacb2a4e4cce9a422604c3e961358

Authored by Antonio Terceiro
2 parents 083d29d3 486e450c

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
Showing 2 changed files with 8 additions and 1 deletions   Show diff stats
app/models/block.rb
... ... @@ -23,7 +23,7 @@ class Block < ActiveRecord::Base
23 23 end
24 24  
25 25 def get_limit
26   - [0,limit].max
  26 + [0,limit.to_i].max
27 27 end
28 28  
29 29 def embed_code
... ...
test/unit/block_test.rb
... ... @@ -330,4 +330,11 @@ class BlockTest < ActiveSupport::TestCase
330 330 block.save!
331 331 assert !block.display_to_user?(person_friend)
332 332 end
  333 +
  334 + should 'get limit as a number when limit is string' do
  335 + block = RecentDocumentsBlock.new
  336 + block.settings[:limit] = '5'
  337 + assert block.get_limit.is_a?(Fixnum)
  338 + end
  339 +
333 340 end
... ...