Commit 1771bd86d78f0ff8cd86898960fec6ce8117f7ab

Authored by Leandro Santos
1 parent 56703bf0

Fix HighlightsBlock unit test

app/models/block.rb
1 class Block < ActiveRecord::Base 1 class Block < ActiveRecord::Base
2 2
3 - attr_accessible :title 3 + attr_accessible :title, :display
4 4
5 # to be able to generate HTML 5 # to be able to generate HTML
6 include ActionView::Helpers::UrlHelper 6 include ActionView::Helpers::UrlHelper
app/models/highlights_block.rb
1 class HighlightsBlock < Block 1 class HighlightsBlock < Block
2 2
  3 + attr_accessible :images
  4 +
3 settings_items :images, :type => Array, :default => [] 5 settings_items :images, :type => Array, :default => []
4 settings_items :interval, :type => 'integer', :default => 4 6 settings_items :interval, :type => 'integer', :default => 4
5 settings_items :shuffle, :type => 'boolean', :default => false 7 settings_items :shuffle, :type => 'boolean', :default => false
@@ -30,7 +32,7 @@ class HighlightsBlock &lt; Block @@ -30,7 +32,7 @@ class HighlightsBlock &lt; Block
30 32
31 def content(args={}) 33 def content(args={})
32 block = self 34 block = self
33 - lambda do 35 + proc do
34 render :file => 'blocks/highlights', :locals => { :block => block } 36 render :file => 'blocks/highlights', :locals => { :block => block }
35 end 37 end
36 end 38 end
app/models/link_list_block.rb
1 class LinkListBlock < Block 1 class LinkListBlock < Block
2 2
3 - attr_accessible :links, :display 3 + attr_accessible :links
4 4
5 ICONS = [ 5 ICONS = [
6 ['no-icon', _('(No icon)')], 6 ['no-icon', _('(No icon)')],
test/unit/highlights_block_test.rb
@@ -60,7 +60,9 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase @@ -60,7 +60,9 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase
60 should 'be able to update display setting' do 60 should 'be able to update display setting' do
61 user = create_user('testinguser').person 61 user = create_user('testinguser').person
62 box = fast_create(Box, :owner_id => user.id) 62 box = fast_create(Box, :owner_id => user.id)
63 - block = HighlightsBlock.create!(:display => 'never', :box => box) 63 + block = HighlightsBlock.create!(:display => 'never').tap do |b|
  64 + b.box = box
  65 + end
64 assert block.update_attributes!(:display => 'always') 66 assert block.update_attributes!(:display => 'always')
65 block.reload 67 block.reload
66 assert_equal 'always', block.display 68 assert_equal 'always', block.display
@@ -143,7 +145,7 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase @@ -143,7 +145,7 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase
143 block = HighlightsBlock.new 145 block = HighlightsBlock.new
144 block.stubs(:owner).returns(owner) 146 block.stubs(:owner).returns(owner)
145 147
146 - assert_kind_of Array, block.folder_choices 148 + assert_equal [], block.folder_choices
147 end 149 end
148 end 150 end
149 151