Commit e340547251abbe29ad8f9fce64e96b1d738109f3

Authored by AntonioTerceiro
1 parent ffbac895

ActionItem152: storing settings in a block


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1235 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 14 additions and 4 deletions   Show diff stats
app/models/block.rb
... ... @@ -2,6 +2,11 @@ class Block < ActiveRecord::Base
2 2 acts_as_list :scope => :box
3 3 belongs_to :box
4 4  
  5 + serialize :settings, Hash
  6 + def settings
  7 + self[:settings] ||= Hash.new
  8 + end
  9 +
5 10 def self.description
6 11 _('A dummy block.')
7 12 end
... ... @@ -10,8 +15,4 @@ class Block < ActiveRecord::Base
10 15 "This is block number %d" % self.id
11 16 end
12 17  
13   - def editor
14   - { :controller => 'block_editor', :id => self.id }
15   - end
16   -
17 18 end
... ...
test/unit/block_test.rb
... ... @@ -6,4 +6,13 @@ class BlockTest < Test::Unit::TestCase
6 6 assert_kind_of String, Block.description
7 7 end
8 8  
  9 + should 'store settings in a hash' do
  10 + block = Block.new
  11 +
  12 + assert_kind_of Hash, block.settings
  13 + block.save!
  14 +
  15 + assert_kind_of Hash, Block.find(block.id).settings
  16 + end
  17 +
9 18 end
... ...