Commit e340547251abbe29ad8f9fce64e96b1d738109f3
1 parent
ffbac895
Exists in
master
and in
28 other branches
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,6 +2,11 @@ class Block < ActiveRecord::Base | ||
| 2 | acts_as_list :scope => :box | 2 | acts_as_list :scope => :box |
| 3 | belongs_to :box | 3 | belongs_to :box |
| 4 | 4 | ||
| 5 | + serialize :settings, Hash | ||
| 6 | + def settings | ||
| 7 | + self[:settings] ||= Hash.new | ||
| 8 | + end | ||
| 9 | + | ||
| 5 | def self.description | 10 | def self.description |
| 6 | _('A dummy block.') | 11 | _('A dummy block.') |
| 7 | end | 12 | end |
| @@ -10,8 +15,4 @@ class Block < ActiveRecord::Base | @@ -10,8 +15,4 @@ class Block < ActiveRecord::Base | ||
| 10 | "This is block number %d" % self.id | 15 | "This is block number %d" % self.id |
| 11 | end | 16 | end |
| 12 | 17 | ||
| 13 | - def editor | ||
| 14 | - { :controller => 'block_editor', :id => self.id } | ||
| 15 | - end | ||
| 16 | - | ||
| 17 | end | 18 | end |
test/unit/block_test.rb
| @@ -6,4 +6,13 @@ class BlockTest < Test::Unit::TestCase | @@ -6,4 +6,13 @@ class BlockTest < Test::Unit::TestCase | ||
| 6 | assert_kind_of String, Block.description | 6 | assert_kind_of String, Block.description |
| 7 | end | 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 | end | 18 | end |