Commit 87890031d50e2b6ebde793eb7b84bdd392627fb7
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'stable' of gitlab.com:participa/noosfero into stable
Showing
10 changed files
with
92 additions
and
66 deletions
Show diff stats
app/helpers/profile_helper.rb
1 | 1 | module ProfileHelper |
2 | 2 | |
3 | 3 | COMMON_CATEGORIES = ActiveSupport::OrderedHash.new |
4 | - COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :tags] | |
4 | + COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :article_tags] | |
5 | 5 | COMMON_CATEGORIES[:interests] = [:interests] |
6 | 6 | COMMON_CATEGORIES[:general] = nil |
7 | 7 | |
... | ... | @@ -41,6 +41,7 @@ module ProfileHelper |
41 | 41 | :birth_date => _('Date of birth'), |
42 | 42 | :created_at => _('Profile created at'), |
43 | 43 | :members_count => _('Members'), |
44 | + :article_tags => _('Tags') | |
44 | 45 | } |
45 | 46 | |
46 | 47 | EXCEPTION = { |
... | ... | @@ -73,14 +74,18 @@ module ProfileHelper |
73 | 74 | return '' |
74 | 75 | end |
75 | 76 | value = begin profile.send(field) rescue nil end |
76 | - if !value.blank? | |
77 | + return '' if value.blank? | |
78 | + if value.kind_of?(Hash) | |
79 | + content = self.send("treat_#{field}", value) | |
80 | + content_tag('tr', content_tag('td', title(field), :class => 'field-name') + content_tag('td', content)) | |
81 | + else | |
77 | 82 | entries = multiple ? value : [] << value |
78 | 83 | entries.map do |entry| |
79 | 84 | content = self.send("treat_#{field}", entry) |
80 | - content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) | |
85 | + unless content.blank? | |
86 | + content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) | |
87 | + end | |
81 | 88 | end.join("\n") |
82 | - else | |
83 | - '' | |
84 | 89 | end |
85 | 90 | end |
86 | 91 | |
... | ... | @@ -142,7 +147,7 @@ module ProfileHelper |
142 | 147 | link_to events.published.count, :controller => 'events', :action => 'events' |
143 | 148 | end |
144 | 149 | |
145 | - def treat_tags(tags) | |
150 | + def treat_article_tags(tags) | |
146 | 151 | tag_cloud @tags, :id, { :action => 'tags' }, :max_size => 18, :min_size => 10 |
147 | 152 | end |
148 | 153 | ... | ... |
app/models/external_feed.rb
... | ... | @@ -13,6 +13,7 @@ class ExternalFeed < ActiveRecord::Base |
13 | 13 | attr_accessible :address, :enabled |
14 | 14 | |
15 | 15 | def add_item(title, link, date, content) |
16 | + return if content.blank? | |
16 | 17 | doc = Hpricot(content) |
17 | 18 | doc.search('*').each do |p| |
18 | 19 | if p.instance_of? Hpricot::Elem | ... | ... |
db/migrate/20140708121356_index_articles_filtered_fields.rb
1 | 1 | class IndexArticlesFilteredFields < ActiveRecord::Migration |
2 | 2 | def self.up |
3 | 3 | %w[articles article_versions].each do |table| |
4 | - add_index table, [:path] | |
5 | - add_index table, [:path, :profile_id] | |
4 | + add_index table.to_sym, [:path] | |
5 | + add_index table.to_sym, [:path, :profile_id] | |
6 | 6 | end |
7 | 7 | add_index :articles, [:type] |
8 | 8 | add_index :articles, [:type, :parent_id] | ... | ... |
db/migrate/20140709212646_add_spam_comments_counter_cache_to_articles.rb
... | ... | @@ -2,7 +2,10 @@ class AddSpamCommentsCounterCacheToArticles < ActiveRecord::Migration |
2 | 2 | def self.up |
3 | 3 | add_column :articles, :spam_comments_count, :integer, :default => 0 |
4 | 4 | add_column :article_versions, :spam_comments_count, :integer, :default => 0 |
5 | - execute "update articles set spam_comments_count = (select count(*) from comments where comments.source_id = articles.id and comments.source_type = 'Article' and comments.spam = 't');" | |
5 | + | |
6 | + execute("SELECT comments.source_id as source_id, count(comments.id) as comments_count FROM comments LEFT OUTER JOIN articles ON articles.id = source_id WHERE comments.source_type = 'Article' AND comments.spam = 't' GROUP BY comments.source_id;").each do |data| | |
7 | + execute("UPDATE articles SET spam_comments_count = '#{data['comments_count']}' WHERE id = #{data['source_id']}") | |
8 | + end | |
6 | 9 | end |
7 | 10 | |
8 | 11 | def self.down | ... | ... |
db/migrate/20140709224246_create_real_relation_between_article_and_author.rb
... | ... | @@ -4,8 +4,10 @@ class CreateRealRelationBetweenArticleAndAuthor < ActiveRecord::Migration |
4 | 4 | add_column :article_versions, :author_id, :integer |
5 | 5 | |
6 | 6 | # Set article's author as the first version's last_changed_by_id. |
7 | - execute "update articles set author_id = (select article_versions.last_changed_by_id from article_versions where article_versions.article_id = articles.id and article_versions.version = 1 limit 1)" | |
8 | - end | |
7 | + execute("UPDATE article_versions SET author_id = last_changed_by_id") | |
8 | + | |
9 | + execute("UPDATE articles SET author_id = article_versions.author_id FROM article_versions WHERE article_versions.article_id = articles.id AND article_versions.version = 1") | |
10 | + end | |
9 | 11 | |
10 | 12 | def self.down |
11 | 13 | remove_column :articles, :author_id | ... | ... |
db/migrate/20140724180943_add_index_to_blog_posts_sort.rb
1 | 1 | class AddIndexToBlogPostsSort < ActiveRecord::Migration |
2 | 2 | def self.up |
3 | 3 | %w[articles article_versions].each do |table| |
4 | - add_index table, [:published_at, :id] | |
4 | + add_index table.to_sym, [:published_at, :id] | |
5 | 5 | end |
6 | 6 | end |
7 | 7 | |
8 | 8 | def self.down |
9 | 9 | %w[articles article_versions].each do |table| |
10 | - remove_index table, [:published_at, :id] | |
10 | + remove_index table.to_sym, [:published_at, :id] | |
11 | 11 | end |
12 | 12 | end |
13 | 13 | end | ... | ... |
features/profile_tags.feature
... | ... | @@ -1,20 +0,0 @@ |
1 | -Feature: profile tags | |
2 | - As a Noosfero user | |
3 | - I want to to view content tagged | |
4 | - So that I can follow the subjects I care about | |
5 | - | |
6 | - Background: | |
7 | - Given the following users | |
8 | - | login | | |
9 | - | terceiro | | |
10 | - And the following articles | |
11 | - | owner | name | body | tag_list | | |
12 | - | terceiro | text 1 | text 1 content | tag1, tag2 | | |
13 | - | terceiro | text 2 | text 2 content | tag1, tag3 | | |
14 | - | |
15 | - Scenario: tag feed | |
16 | - When I go to terceiro's profile | |
17 | - And I follow "tag1" | |
18 | - And I follow "Feed for this tag" | |
19 | - Then I should see "text 1" | |
20 | - And I should see "text 2" |
plugins/pairwise/views/content_viewer/prompt.html.erb
1 | 1 | <% extend PairwisePlugin::Helpers::ViewerHelper %> |
2 | 2 | |
3 | -<% if embeded %> | |
4 | - <%= javascript_include_tag :defaults, 'jquery-latest.js', | |
5 | - 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'colorbox', | |
6 | - 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', | |
7 | - 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', | |
8 | - 'add-and-join', 'report-abuse', 'catalog', 'manage-products', | |
9 | - 'jquery-ui-timepicker-addon', :cache => 'cache-general' %> | |
10 | -<% end %> | |
3 | +<%= render :file => 'layouts/_javascript' if embeded %> | |
11 | 4 | |
12 | 5 | <%= render :partial => 'content_viewer/prompt_body', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => nil, :source => (defined?(source) ? source : '') }%> | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -98,8 +98,9 @@ class ProfileControllerTest < ActionController::TestCase |
98 | 98 | |
99 | 99 | should 'show friends link to person' do |
100 | 100 | person = create_user('person_1').person |
101 | + person.add_friend(profile) | |
101 | 102 | get :index, :profile => person.identifier |
102 | - assert_tag :tag => 'a', :content => /#{profile.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } | |
103 | + assert_tag :tag => 'a', :content => /#{person.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } | |
103 | 104 | end |
104 | 105 | |
105 | 106 | should 'display tag for profile' do |
... | ... | @@ -221,6 +222,7 @@ class ProfileControllerTest < ActionController::TestCase |
221 | 222 | |
222 | 223 | should 'display "Products" link for enterprise' do |
223 | 224 | ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) |
225 | + product = fast_create(Product, :profile_id => ent.id) | |
224 | 226 | |
225 | 227 | get :index, :profile => 'my-test-enterprise' |
226 | 228 | assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ |
... | ... | @@ -488,6 +490,14 @@ class ProfileControllerTest < ActionController::TestCase |
488 | 490 | assert_tag :tag => 'a', :content => 'One picture', :attributes => { :href => /\/testuser\/gallery/ } |
489 | 491 | end |
490 | 492 | |
493 | + should 'show tags in index' do | |
494 | + article = create(Article, :name => 'Published at', :profile_id => profile.id, :tag_list => ['tag1']) | |
495 | + | |
496 | + get :index, :profile => profile.identifier | |
497 | + | |
498 | + assert_tag :tag => 'a', :content => 'tag1', :attributes => { :href => /profile\/#{profile.identifier}\/tags\/tag1$/ } | |
499 | + end | |
500 | + | |
491 | 501 | should 'show description of orgarnization' do |
492 | 502 | login_as(@profile.identifier) |
493 | 503 | ent = fast_create(Enterprise) |
... | ... | @@ -1057,8 +1067,16 @@ class ProfileControllerTest < ActionController::TestCase |
1057 | 1067 | atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) |
1058 | 1068 | get :index, :profile => person.identifier |
1059 | 1069 | assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'} |
1070 | + end | |
1071 | + | |
1072 | + should "show the network activity if the viewer follows the profile" do | |
1073 | + login_as(profile.identifier) | |
1074 | + person = fast_create(Person) | |
1075 | + at = fast_create(ActionTracker::Record, :user_id => person.id) | |
1076 | + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) | |
1060 | 1077 | |
1061 | 1078 | person.add_friend(profile) |
1079 | + profile.add_friend(person) | |
1062 | 1080 | get :index, :profile => person.identifier |
1063 | 1081 | assert_tag :tag => 'div', :attributes => {:id => 'profile-network'} |
1064 | 1082 | end |
... | ... | @@ -1077,8 +1095,16 @@ class ProfileControllerTest < ActionController::TestCase |
1077 | 1095 | scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) |
1078 | 1096 | get :index, :profile => person.identifier |
1079 | 1097 | assert_no_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } |
1098 | + end | |
1099 | + | |
1100 | + should "show the scrap area on wall if the user follows the user" do | |
1101 | + login_as(profile.identifier) | |
1102 | + person = fast_create(Person) | |
1103 | + scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) | |
1080 | 1104 | |
1081 | 1105 | person.add_friend(profile) |
1106 | + profile.add_friend(person) | |
1107 | + | |
1082 | 1108 | get :index, :profile => person.identifier |
1083 | 1109 | assert_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } |
1084 | 1110 | end |
... | ... | @@ -1449,9 +1475,9 @@ class ProfileControllerTest < ActionController::TestCase |
1449 | 1475 | viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public', 'birth_date' => 'public' } } |
1450 | 1476 | viewed.save! |
1451 | 1477 | get :index, :profile => viewed.identifier |
1452 | - assert_tag :tag => 'td', :content => 'Sex:' | |
1478 | + assert_tag :tag => 'td', :content => 'Sex' | |
1453 | 1479 | assert_tag :tag => 'td', :content => 'Male' |
1454 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
1480 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
1455 | 1481 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
1456 | 1482 | end |
1457 | 1483 | |
... | ... | @@ -1463,9 +1489,9 @@ class ProfileControllerTest < ActionController::TestCase |
1463 | 1489 | viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public' } } |
1464 | 1490 | viewed.save! |
1465 | 1491 | get :index, :profile => viewed.identifier |
1466 | - assert_tag :tag => 'td', :content => 'Sex:' | |
1492 | + assert_tag :tag => 'td', :content => 'Sex' | |
1467 | 1493 | assert_tag :tag => 'td', :content => 'Male' |
1468 | - assert_no_tag :tag => 'td', :content => 'Date of birth:' | |
1494 | + assert_no_tag :tag => 'td', :content => 'Date of birth' | |
1469 | 1495 | assert_no_tag :tag => 'td', :content => 'August 26, 1990' |
1470 | 1496 | end |
1471 | 1497 | |
... | ... | @@ -1479,9 +1505,9 @@ class ProfileControllerTest < ActionController::TestCase |
1479 | 1505 | strange = create_user('person_2').person |
1480 | 1506 | login_as(strange.identifier) |
1481 | 1507 | get :index, :profile => viewed.identifier |
1482 | - assert_tag :tag => 'td', :content => 'Sex:' | |
1508 | + assert_tag :tag => 'td', :content => 'Sex' | |
1483 | 1509 | assert_tag :tag => 'td', :content => 'Male' |
1484 | - assert_no_tag :tag => 'td', :content => 'Date of birth:' | |
1510 | + assert_no_tag :tag => 'td', :content => 'Date of birth' | |
1485 | 1511 | assert_no_tag :tag => 'td', :content => 'August 26, 1990' |
1486 | 1512 | end |
1487 | 1513 | |
... | ... | @@ -1496,9 +1522,9 @@ class ProfileControllerTest < ActionController::TestCase |
1496 | 1522 | Person.any_instance.stubs(:is_a_friend?).returns(true) |
1497 | 1523 | login_as(friend.identifier) |
1498 | 1524 | get :index, :profile => viewed.identifier |
1499 | - assert_tag :tag => 'td', :content => 'Sex:' | |
1525 | + assert_tag :tag => 'td', :content => 'Sex' | |
1500 | 1526 | assert_tag :tag => 'td', :content => 'Male' |
1501 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
1527 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
1502 | 1528 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
1503 | 1529 | end |
1504 | 1530 | |
... | ... | @@ -1511,9 +1537,9 @@ class ProfileControllerTest < ActionController::TestCase |
1511 | 1537 | viewed.save! |
1512 | 1538 | login_as(viewed.identifier) |
1513 | 1539 | get :index, :profile => viewed.identifier |
1514 | - assert_tag :tag => 'td', :content => 'Sex:' | |
1540 | + assert_tag :tag => 'td', :content => 'Sex' | |
1515 | 1541 | assert_tag :tag => 'td', :content => 'Male' |
1516 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
1542 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
1517 | 1543 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
1518 | 1544 | end |
1519 | 1545 | |
... | ... | @@ -1526,7 +1552,7 @@ class ProfileControllerTest < ActionController::TestCase |
1526 | 1552 | login_as(strange.identifier) |
1527 | 1553 | get :index, :profile => viewed.identifier |
1528 | 1554 | assert_tag :tag => 'th', :content => 'Contact' |
1529 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
1555 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
1530 | 1556 | end |
1531 | 1557 | |
1532 | 1558 | should 'show contact to friend' do |
... | ... | @@ -1539,7 +1565,7 @@ class ProfileControllerTest < ActionController::TestCase |
1539 | 1565 | login_as(friend.identifier) |
1540 | 1566 | get :index, :profile => viewed.identifier |
1541 | 1567 | assert_tag :tag => 'th', :content => 'Contact' |
1542 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
1568 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
1543 | 1569 | end |
1544 | 1570 | |
1545 | 1571 | should 'show contact to self' do |
... | ... | @@ -1550,7 +1576,7 @@ class ProfileControllerTest < ActionController::TestCase |
1550 | 1576 | login_as(viewed.identifier) |
1551 | 1577 | get :index, :profile => viewed.identifier |
1552 | 1578 | assert_tag :tag => 'th', :content => 'Contact' |
1553 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
1579 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
1554 | 1580 | end |
1555 | 1581 | |
1556 | 1582 | should 'not show contact to non friend' do |
... | ... | @@ -1562,7 +1588,7 @@ class ProfileControllerTest < ActionController::TestCase |
1562 | 1588 | login_as(strange.identifier) |
1563 | 1589 | get :index, :profile => viewed.identifier |
1564 | 1590 | assert_no_tag :tag => 'th', :content => 'Contact' |
1565 | - assert_no_tag :tag => 'td', :content => 'e-Mail:' | |
1591 | + assert_no_tag :tag => 'td', :content => 'e-Mail' | |
1566 | 1592 | end |
1567 | 1593 | |
1568 | 1594 | should 'show contact to friend even if private' do |
... | ... | @@ -1575,7 +1601,7 @@ class ProfileControllerTest < ActionController::TestCase |
1575 | 1601 | login_as(friend.identifier) |
1576 | 1602 | get :index, :profile => viewed.identifier |
1577 | 1603 | assert_tag :tag => 'th', :content => 'Contact' |
1578 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
1604 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
1579 | 1605 | end |
1580 | 1606 | |
1581 | 1607 | should 'show contact to self even if private' do |
... | ... | @@ -1586,7 +1612,7 @@ class ProfileControllerTest < ActionController::TestCase |
1586 | 1612 | login_as(viewed.identifier) |
1587 | 1613 | get :index, :profile => viewed.identifier |
1588 | 1614 | assert_tag :tag => 'th', :content => 'Contact' |
1589 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
1615 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
1590 | 1616 | end |
1591 | 1617 | |
1592 | 1618 | should 'not display list of communities to manage on menu by default' do |
... | ... | @@ -1694,22 +1720,28 @@ class ProfileControllerTest < ActionController::TestCase |
1694 | 1720 | |
1695 | 1721 | should 'show enterprises field if enterprises are enabled on environment' do |
1696 | 1722 | person = fast_create(Person) |
1723 | + enterprise = fast_create(Enterprise) | |
1724 | + enterprise.add_admin person | |
1697 | 1725 | environment = person.environment |
1698 | 1726 | environment.disable('disable_asset_enterprises') |
1699 | 1727 | environment.save! |
1700 | 1728 | |
1701 | 1729 | get :index, :profile => person.identifier |
1702 | - assert_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } | |
1730 | + assert_tag :tag => 'td', :content => 'Enterprises' | |
1731 | + assert_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} | |
1703 | 1732 | end |
1704 | 1733 | |
1705 | 1734 | should 'not show enterprises field if enterprises are disabled on environment' do |
1706 | 1735 | person = fast_create(Person) |
1736 | + enterprise = fast_create(Enterprise) | |
1737 | + enterprise.add_admin person | |
1707 | 1738 | environment = person.environment |
1708 | 1739 | environment.enable('disable_asset_enterprises') |
1709 | 1740 | environment.save! |
1710 | 1741 | |
1711 | 1742 | get :index, :profile => person.identifier |
1712 | - assert_no_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } | |
1743 | + assert_no_tag :tag => 'td', :content => 'Enterprises' | |
1744 | + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} | |
1713 | 1745 | end |
1714 | 1746 | |
1715 | 1747 | end | ... | ... |
test/unit/profile_helper_test.rb
... | ... | @@ -17,45 +17,55 @@ class ProfileHelperTest < ActiveSupport::TestCase |
17 | 17 | self.stubs(:user).returns(nil) |
18 | 18 | profile.expects(:may_display_field_to?).returns(true) |
19 | 19 | profile.expects(:field).returns('value') |
20 | - assert_match /Title.*value/, display_field('Title', profile, 'field') | |
20 | + expects(:title).with(:field, anything).returns('Title') | |
21 | + assert_match /Title.*value/, display_field(:field) | |
21 | 22 | end |
22 | 23 | |
23 | 24 | should 'not display field if may not display it and not forced' do |
24 | 25 | self.stubs(:user).returns(nil) |
25 | 26 | profile.expects(:may_display_field_to?).returns(false) |
26 | - assert_equal '', display_field('Title', profile, 'field') | |
27 | + profile.expects(:field).never | |
28 | + assert_equal '', display_field(:field) | |
27 | 29 | end |
28 | 30 | |
29 | 31 | should 'display field if may not display it but is forced' do |
30 | 32 | self.stubs(:user).returns(nil) |
31 | 33 | profile.stubs(:may_display_field_to?).returns(false) |
34 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
35 | + FORCE.merge!({:person => [:field]}) | |
32 | 36 | profile.expects(:field).returns('value') |
33 | - assert_match /Title.*value/, display_field('Title', profile, 'field', true) | |
37 | + expects(:title).with(:field, anything).returns('Title') | |
38 | + assert_match /Title.*value/, display_field(:field) | |
34 | 39 | end |
35 | 40 | |
36 | 41 | should 'display work info if at least one of the fields should be displayed' do |
37 | 42 | self.stubs(:user).returns(nil) |
38 | 43 | profile.stubs(:may_display_field_to?).with(:organization, nil).returns(true) |
39 | 44 | profile.stubs(:may_display_field_to?).with(:organization_website, nil).returns(false) |
45 | + profile.stubs(:may_display_field_to?).with(:professional_activity, nil).returns(false) | |
46 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
40 | 47 | profile.expects(:organization).returns('Organization Name') |
41 | 48 | profile.expects(:organization_website).never |
42 | - assert_match /Work.*Organization Name/, display_work_info(profile) | |
49 | + profile.expects(:professional_activity).never | |
50 | + assert_match /Work.*Organization Name/, display_work | |
43 | 51 | end |
44 | 52 | |
45 | 53 | should 'not display work info if none of the fields should be displayed' do |
46 | 54 | self.stubs(:user).returns(nil) |
47 | 55 | profile.stubs(:may_display_field_to?).returns(false) |
56 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
48 | 57 | profile.expects(:organization).never |
49 | 58 | profile.expects(:organization_website).never |
50 | - assert_equal '', display_work_info(profile) | |
59 | + assert_equal '', display_work | |
51 | 60 | end |
52 | 61 | |
53 | 62 | should 'display work info if both fields should be displayed' do |
54 | 63 | self.stubs(:user).returns(nil) |
55 | 64 | profile.stubs(:may_display_field_to?).returns(true) |
65 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
56 | 66 | profile.expects(:organization).returns('Organization Name') |
57 | 67 | profile.expects(:organization_website).returns('') |
58 | - assert_match /Work.*Organization Name/, display_work_info(profile) | |
68 | + assert_match /Work.*Organization Name/, display_work | |
59 | 69 | end |
60 | 70 | |
61 | 71 | end | ... | ... |