Commit 7f3da1f1f310e50282bf7ef3f5c973a0724e67d5
Committed by
Antonio Terceiro
1 parent
b0660bd6
Exists in
master
and in
23 other branches
ActionItem1146: limit has a default and must be a number
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
app/models/recent_documents_block.rb
| @@ -12,7 +12,7 @@ class RecentDocumentsBlock < Block | @@ -12,7 +12,7 @@ class RecentDocumentsBlock < Block | ||
| 12 | _('This block lists your recent content.') | 12 | _('This block lists your recent content.') |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | - settings_items :limit | 15 | + settings_items :limit, :type => :integer, :default => 5 |
| 16 | 16 | ||
| 17 | include ActionController::UrlWriter | 17 | include ActionController::UrlWriter |
| 18 | def content | 18 | def content |
test/unit/recent_documents_block_test.rb
| @@ -44,6 +44,16 @@ class RecentDocumentsBlockTest < Test::Unit::TestCase | @@ -44,6 +44,16 @@ class RecentDocumentsBlockTest < Test::Unit::TestCase | ||
| 44 | assert_no_match /href=.*\/testinguser\/first/, output | 44 | assert_no_match /href=.*\/testinguser\/first/, output |
| 45 | end | 45 | end |
| 46 | 46 | ||
| 47 | + should 'store limit as a number' do | ||
| 48 | + block.limit = '' | ||
| 49 | + assert block.limit.is_a?(Fixnum) | ||
| 50 | + end | ||
| 51 | + | ||
| 52 | + should 'have a non-zero default' do | ||
| 53 | + block.limit = nil | ||
| 54 | + assert block.limit > 0 | ||
| 55 | + end | ||
| 56 | + | ||
| 47 | should 'display a link to sitemap with title "All content"' do | 57 | should 'display a link to sitemap with title "All content"' do |
| 48 | expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) | 58 | expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) |
| 49 | expects(:_).with('All content').returns('All content') | 59 | expects(:_).with('All content').returns('All content') |