Commit ab3487d7711b0a5d1ce219e6efd910a0f960b8d2
1 parent
ca7362ba
Exists in
master
and in
29 other branches
ActionItem135: fixed a test on the person info summary
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1086 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
7 changed files
with
13 additions
and
16 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
| @@ -12,6 +12,7 @@ class ProfileEditorController < MyProfileController | @@ -12,6 +12,7 @@ class ProfileEditorController < MyProfileController | ||
| 12 | FavoriteLinksProfile | 12 | FavoriteLinksProfile |
| 13 | ListBlock | 13 | ListBlock |
| 14 | ProfileInfoBlock | 14 | ProfileInfoBlock |
| 15 | + ViewArticle | ||
| 15 | ] | 16 | ] |
| 16 | end | 17 | end |
| 17 | 18 |
app/design_blocks/view_article/controllers/view_article_controller.rb
| @@ -38,6 +38,7 @@ class ViewArticleController < ApplicationController | @@ -38,6 +38,7 @@ class ViewArticleController < ApplicationController | ||
| 38 | ########################### | 38 | ########################### |
| 39 | 39 | ||
| 40 | def edit | 40 | def edit |
| 41 | + @articles = @profile.articles | ||
| 41 | design_render_on_edit | 42 | design_render_on_edit |
| 42 | end | 43 | end |
| 43 | 44 | ||
| @@ -46,5 +47,4 @@ class ViewArticleController < ApplicationController | @@ -46,5 +47,4 @@ class ViewArticleController < ApplicationController | ||
| 46 | design_render_on_edit :nothing => true | 47 | design_render_on_edit :nothing => true |
| 47 | end | 48 | end |
| 48 | 49 | ||
| 49 | - | ||
| 50 | end | 50 | end |
app/design_blocks/view_article/models/view_article.rb
| @@ -12,20 +12,16 @@ class ViewArticle < Design::Block | @@ -12,20 +12,16 @@ class ViewArticle < Design::Block | ||
| 12 | 'ViewArticle' | 12 | 'ViewArticle' |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | - def page | ||
| 16 | - self.settings[:page] | 15 | + def article_id |
| 16 | + self.settings[:article_id] | ||
| 17 | end | 17 | end |
| 18 | - | ||
| 19 | - def page= value | ||
| 20 | - self.settings[:page] = value | ||
| 21 | - end | ||
| 22 | - | ||
| 23 | - def profile | ||
| 24 | - self.settings[:page] | 18 | + |
| 19 | + def article_id= value | ||
| 20 | + self.settings[:article_id] = value | ||
| 25 | end | 21 | end |
| 26 | 22 | ||
| 27 | - def profile= value | ||
| 28 | - self.settings[:page] = value | 23 | + def article |
| 24 | + Article.find(article_id) if article_id | ||
| 29 | end | 25 | end |
| 30 | 26 | ||
| 31 | end | 27 | end |
app/design_blocks/view_article/views/edit.rhtml
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | <p> | 9 | <p> |
| 10 | <label for="design_block_page"> <%= _("Page to show") %> </label> | 10 | <label for="design_block_page"> <%= _("Page to show") %> </label> |
| 11 | - <%= text_field 'design_block', 'page'%> | 11 | + <%= select 'design_block', 'article_id', @articles.map{|a|[a.full_name, a.id]} %> |
| 12 | </p> | 12 | </p> |
| 13 | 13 | ||
| 14 | <%= submit_tag _('Save') %> | 14 | <%= submit_tag _('Save') %> |
app/design_blocks/view_article/views/index.rhtml
app/models/person_info.rb
| @@ -3,7 +3,7 @@ class PersonInfo < ActiveRecord::Base | @@ -3,7 +3,7 @@ class PersonInfo < ActiveRecord::Base | ||
| 3 | belongs_to :person | 3 | belongs_to :person |
| 4 | 4 | ||
| 5 | def summary | 5 | def summary |
| 6 | - ['name', 'sex', 'birth_date', 'address', 'city', 'state', 'country'].map do |col| | 6 | + ['name', 'contact_information', 'sex', 'birth_date', 'address', 'city', 'state', 'country'].map do |col| |
| 7 | [ PersonInfo.columns_hash[col] && PersonInfo.columns_hash[col].human_name, self.send(col) ] | 7 | [ PersonInfo.columns_hash[col] && PersonInfo.columns_hash[col].human_name, self.send(col) ] |
| 8 | end | 8 | end |
| 9 | end | 9 | end |
test/unit/person_info_test.rb
| @@ -20,7 +20,7 @@ class PersonInfoTest < Test::Unit::TestCase | @@ -20,7 +20,7 @@ class PersonInfoTest < Test::Unit::TestCase | ||
| 20 | summary = person_info.summary | 20 | summary = person_info.summary |
| 21 | assert(summary.any? { |line| line[1] == 'person name' }) | 21 | assert(summary.any? { |line| line[1] == 'person name' }) |
| 22 | assert(summary.any? { |line| line[1] == 'my address' }) | 22 | assert(summary.any? { |line| line[1] == 'my address' }) |
| 23 | - assert(summary.any? { |line| line[1] == 'my contact information' }) | 23 | + assert(summary.any? { |line| line[1] == 'my contact information' }, "summary (#{summary.map{|l| l[1] }.compact.join("; ")}) do not contain 'my contact informatidon'") |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | end | 26 | end |