Commit 173bc36f14ade4cdc27ae2da9ea892528a637622

Authored by Daniela Feitosa
1 parent 59b1f0c0

Enhancements on wall

app/controllers/public/profile_controller.rb
... ... @@ -178,8 +178,8 @@ class ProfileController < PublicController
178 178 @scrap.receiver= receiver
179 179 @tab_action = params[:tab_action]
180 180 @message = @scrap.save ? _("Message successfully sent.") : _("You can't leave an empty message.")
181   - @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
182   - render :partial => 'profile_activities_list'
  181 + activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
  182 + render :partial => 'profile_activities_list', :locals => {:activities => activities}
183 183 end
184 184  
185 185 def leave_comment_on_activity
... ... @@ -191,8 +191,8 @@ class ProfileController < PublicController
191 191 @comment.source_type, @comment.source_id = (@activity.target_type == 'Article' ? ['Article', @activity.target_id] : [@activity.class.to_s, @activity.id])
192 192 @tab_action = params[:tab_action]
193 193 @message = @comment.save ? _("Comment successfully added.") : _("You can't leave an empty comment.")
194   - @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
195   - render :partial => 'profile_activities_list'
  194 + activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
  195 + render :partial => 'profile_activities_list', :locals => {:activities => activities}
196 196 end
197 197  
198 198 def view_more_scraps
... ... @@ -202,7 +202,7 @@ class ProfileController < PublicController
202 202  
203 203 def view_more_activities
204 204 @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page])
205   - render :partial => 'profile_activities_scraps', :locals => {:activities => @activities}
  205 + render :partial => 'profile_activities_list', :locals => {:activities => @activities}
206 206 end
207 207  
208 208 def view_more_network_activities
... ...
app/models/enterprise.rb
... ... @@ -181,4 +181,8 @@ class Enterprise < Organization
181 181 true
182 182 end
183 183  
  184 + def activities
  185 + Scrap.find_by_sql("SELECT id, updated_at, 'Scrap' AS klass FROM scraps WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, 'ActionTracker::Record' AS klass FROM action_tracker WHERE action_tracker.target_id = #{self.id} UNION SELECT action_tracker.id, action_tracker.updated_at, 'ActionTracker::Record' AS klass FROM action_tracker INNER JOIN articles ON action_tracker.target_id = articles.id WHERE articles.profile_id = #{self.id} AND action_tracker.target_type = 'Article' ORDER BY action_tracker.updated_at DESC")
  186 + end
  187 +
184 188 end
... ...
app/models/scrap.rb
... ... @@ -13,6 +13,8 @@ class Scrap < ActiveRecord::Base
13 13  
14 14 track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.receiver != s.sender}, :custom_target => :action_tracker_target
15 15  
  16 + track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.receiver == s.sender}
  17 +
16 18 after_create do |scrap|
17 19 scrap.root.update_attribute('updated_at', DateTime.now) unless scrap.root.nil?
18 20 Scrap::Notifier.deliver_mail(scrap) if scrap.send_notification?
... ...
app/models/uploaded_file.rb
... ... @@ -140,4 +140,9 @@ class UploadedFile < Article
140 140 def uploaded_file?
141 141 true
142 142 end
  143 +
  144 + def action_tracker_target
  145 + self
  146 + end
  147 +
143 148 end
... ...
app/views/profile/_comment.rhtml
  1 +<%# Comment %>
1 2 <li class="article-comment" style='border-bottom:none;'>
2 3 <div class="article-comment-inner">
3 4  
4 5 <div class="comment-content comment-logged-in">
5 6  
6   - <% if Person.find(comment.author_id) %>
7   - <%= link_to image_tag(profile_icon(Person.find(comment.author_id), :minor)),
  7 + <% if comment.author %>
  8 + <%= link_to image_tag(profile_icon(comment.author, :minor)),
8 9 Person.find(comment.author_id).url,
9 10 :class => 'comment-picture',
10   - :title => Person.find(comment.author_id).name
  11 + :title => comment.author_name
11 12 %>
12 13 <% end %>
13 14  
14 15 <div class="comment-details">
15 16 <div class="comment-text">
16   - <%= link_to(Person.find(comment.author_id).name, Person.find(comment.author_id).url) %> <%= txt2html comment.body %>
  17 + <%= link_to(comment.author_name, comment.author.url) %> <%= txt2html comment.body %>
17 18 </div>
18 19 <div class="profile-activity-time">
19 20 <%= time_ago_as_sentence(comment.created_at) %>
20 21 </div>
21 22 </div>
22 23  
23   - <% if logged_in? && (user == profile || user == Person.find(comment.author_id) || user.has_permission?(:moderate_comments, profile)) %>
  24 + <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %>
24 25 <% button_bar(:style => 'float: right; margin-top: 0px;') do %>
25 26 <%= icon_button(:delete, _('Remove'), { :action => :remove_comment, :comment_id => comment.id }, :method => :get, :confirm => _('Are you sure you want to remove this comment and all its replies?')) %>
26 27 <% end %>
... ... @@ -37,7 +38,7 @@
37 38 });
38 39 </script>
39 40 <% end %>
40   - <%= report_abuse(Person.find(comment.author_id), :comment_link, comment) if Person.find(comment.author_id) %>
  41 + <%= report_abuse(comment.author, :comment_link, comment) if comment.author %>
41 42 <%= link_to_function _('Reply'),
42 43 "var f = add_comment_reply_form(this, %s); f.find('input[name=comment[title]], textarea').val(''); return false" % comment.id,
43 44 :class => 'comment-footer comment-footer-link comment-footer-hide',
... ... @@ -47,7 +48,7 @@
47 48  
48 49 </div>
49 50  
50   - <% unless Comment.find(comment.id).replies.blank? %>
  51 + <% unless comment.replies.blank? %>
51 52 <ul class="comment-replies">
52 53 <% comment.replies.each do |reply| %>
53 54 <%= render :partial => 'comment', :locals => { :comment => reply } %>
... ...
app/views/profile/_create_article.rhtml
... ... @@ -4,7 +4,7 @@
4 4 <div class='profile-activity-description profile-activity-article-<%= activity.target.class.icon_name %>'>
5 5 <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %></p>
6 6 <div class='profile-activity-lead'>
7   - <b><%= activity.params['name'] %></b>
  7 + <b><%= link_to(activity.params['name'], activity.params['url']) %></b>
8 8 <span title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-new<%= activity.target.class.icon_name %>'></span><br />
9 9 <%= image_tag(activity.params['first_image']) unless activity.params['first_image'].blank? %><%= strip_tags(activity.params['lead']).gsub(/(\xA0|\xC2|\s)+/, ' ').gsub(/^\s+/, '') %> <small><%= link_to(_('See more'), activity.params['url']) unless activity.get_lead.blank? %></small></div>
10 10 <%= content_tag(:p, link_to(_('See complete forum'), activity.get_url), :class => 'see-forum') if activity.target.is_a?(Forum) %>
... ...
app/views/profile/_leave_comment_on_activity.rhtml
1   -<%= @message %>
2   -<% unless @activities.nil? %>
3   - <%= render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} %>
4   -<% end %>
  1 +NÃO É PRA APARECER
... ...
app/views/profile/_leave_scrap.rhtml
1   -<%= @message %>
2   -<% unless @activities.nil? %>
3   - <%= render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} %>
4   -<% end %>
  1 +NÂO DEVE APARECER
... ...
app/views/profile/_leave_scrap_to_self.rhtml
1   -<%= @message %>
2   -<% unless @activities.nil? %>
3   - <%= render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} %>
4   -<% end %>
  1 +NÃO É PRA APARECER
... ...
app/views/profile/_profile.rhtml
1   -<tr>
2   - <td colspan='2'>
  1 +NÃO DEVE APARECER
3 2  
4   - <% plugins_tabs = @plugins.dispatch(:profile_tabs).
5   - map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_eval(&tab[:content]), :start => tab[:title]} }%>
6   -
7   - <% tabs = plugins_tabs.select { |tab| tab[:start] } %>
8   -
9   - <% if @profile.organization? %>
10   - <% tabs << {:title => _('Profile'), :id => 'organization-profile', :content => (render :partial => 'organization_profile')} %>
11   - <% if logged_in? && current_person.follows?(@profile) %>
12   - <% tabs << {:title => _('Wall'), :id => 'profile-wall', :content => (render :partial => 'profile_wall')} %>
13   - <% end %>
14   - <% tabs << {:title => _('What\'s new'), :id => 'profile-network', :content => (render :partial => 'profile_network')} %>
15   - <% elsif @profile.person? %>
16   - <% tabs << {:title => _('Profile'), :id => 'person-profile', :content => (render :partial => 'person_profile')} %>
17   - <% if logged_in? && current_person.follows?(@profile) %>
18   - <% tabs << {:title => _('Wall'), :id => 'profile-wall', :content => (render :partial => 'profile_wall')} %>
19   - <% tabs << {:title => _('Network'), :id => 'profile-network', :content => (render :partial => 'profile_network')} %>
20   - <% end %>
21   - <% end %>
22   -
23   - <% tabs += plugins_tabs.select { |tab| !tab[:start] } %>
24   -
25   - <%= render_tabs(tabs) %>
26   -
27   - </td>
28   -</tr>
... ...
app/views/profile/_profile_activities_list.rhtml
1   -<%= @message %>
2   -<% unless @activities.nil? %>
3   - <%= render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} %>
  1 +<% unless activities.nil? %>
  2 + <% activities.each do |a| %>
  3 + <% activity = a.klass.constantize.find(a.id) %>
  4 + <% if activity.kind_of?(ActionTracker::Record) %>
  5 + <%= render :partial => 'profile_activity', :locals => {:activity => activity} if activity.visible? %>
  6 + <% else %>
  7 + <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %>
  8 + <% end %>
  9 + <% end %>
4 10 <% end %>
... ...
app/views/profile/_profile_activities_scraps.rhtml
1   -<% activities.each do |a| %>
2   - <% activity = a.klass.constantize.find(a.id) %>
3   - <% if activity.kind_of?(ActionTracker::Record) %>
4   - <%= render :partial => 'profile_activity', :locals => {:activity => activity} if activity.visible? %>
5   - <% else %>
6   - <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %>
7   - <% end %>
8   -<% end %>
  1 +NÂO DEVE APARECER!!
  2 +
... ...
app/views/profile/_profile_wall.rhtml
... ... @@ -8,7 +8,7 @@
8 8 </div>
9 9 <div id='leave_scrap_response'></div>
10 10 <ul id='profile_activities'>
11   - <%= render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} %>
  11 + <%= render :partial => 'profile_activities_list', :locals => {:activities => @activities} %>
12 12 </ul>
13 13  
14 14 <% if @activities.current_page < @activities.total_pages %>
... ...
app/views/profile/index.rhtml
... ... @@ -17,6 +17,31 @@
17 17  
18 18 <% if @profile.public? || (logged_in? && current_person.follows?(@profile)) %>
19 19 <table class='profile'>
20   - <%= render :partial => 'profile' %>
  20 + <tr>
  21 + <td colspan='2'>
  22 + <% plugins_tabs = @plugins.dispatch(:profile_tabs).
  23 + map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_eval(&tab[:content]), :start => tab[:title]} }%>
  24 +
  25 + <% tabs = plugins_tabs.select { |tab| tab[:start] } %>
  26 +
  27 + <% if @profile.organization? %>
  28 + <% tabs << {:title => _('Profile'), :id => 'organization-profile', :content => (render :partial => 'organization_profile')} %>
  29 + <% if logged_in? && current_person.follows?(@profile) %>
  30 + <% tabs << {:title => _('Wall'), :id => 'profile-wall', :content => (render :partial => 'profile_wall')} %>
  31 + <% end %>
  32 + <% tabs << {:title => _('What\'s new'), :id => 'profile-network', :content => (render :partial => 'profile_network')} %>
  33 + <% elsif @profile.person? %>
  34 + <% tabs << {:title => _('Profile'), :id => 'person-profile', :content => (render :partial => 'person_profile')} %>
  35 + <% if logged_in? && current_person.follows?(@profile) %>
  36 + <% tabs << {:title => _('Wall'), :id => 'profile-wall', :content => (render :partial => 'profile_wall')} %>
  37 + <% tabs << {:title => _('Network'), :id => 'profile-network', :content => (render :partial => 'profile_network')} %>
  38 + <% end %>
  39 + <% end %>
  40 +
  41 + <% tabs += plugins_tabs.select { |tab| !tab[:start] } %>
  42 +
  43 + <%= render_tabs(tabs) %>
  44 + </td>
  45 + </tr>
21 46 </table>
22 47 <% end %>
... ...
config/initializers/action_tracker.rb
... ... @@ -23,7 +23,7 @@ ActionTrackerConfig.verbs = {
23 23 },
24 24  
25 25 :upload_image => {
26   - :description => lambda { n_('uploaded 1 image: %{details}<br />%{thumbnails}<br style="clear: both;" />', 'uploaded %{num} images: %{details}<br />%{thumbnails}<br style="clear: both;" />', get_view_url.size) % { :num => get_view_url.size, :thumbnails => '{{ta.collect_group_with_index(:thumbnail_path){ |t,i| content_tag(:span, image_tag(t) + link_to(nil, ta.get_view_url[i]))}.last(3).join}}', :details => '{{unique_with_count(ta.collect_group_with_index(:parent_name){ |n,i| link_to(n, ta.get_parent_url[i])}, "%s").join(", ")}}' % _("in the gallery") } },
  26 + :description => lambda { n_('uploaded 1 image<br />%{thumbnails}<br style="clear: both;" />', 'uploaded %{num} images<br />%{thumbnails}<br style="clear: both;" />', get_view_url.size) % { :num => get_view_url.size, :thumbnails => '{{ta.collect_group_with_index(:thumbnail_path){ |t,i| content_tag(:span, image_tag(t) + link_to(nil, ta.get_view_url[i]))}.last(3).join}}' } },
27 27 :type => :groupable
28 28 },
29 29  
... ...
features/profile_activities.feature
... ... @@ -1,88 +0,0 @@
1   -Feature: list activities of a profile
2   - As a visitor
3   - I want to see the activities of a profile
4   -
5   - Background:
6   - Given the following users
7   - | login | name |
8   - | joaosilva | Joao Silva |
9   - And the following articles
10   - | owner | name | body |
11   - | joaosilva | article to comment | first paragraph |
12   - And the following comments
13   - | article | author | title | body |
14   - | article to comment | joaosilva | hi | how are you? |
15   -
16   - Scenario: see the activity of a profile
17   - Given I am logged in as "joaosilva"
18   - When I go to Joao Silva's homepage
19   -#Não tá rodando o delayed job :(
20   -Then I should see "dkjfhv"
21   - Then I should see "first paragraph" within ".profile-activity-item"
22   - And I should see "how are you?" within ".profile-wall-activities-comments"
23   -
24   - @selenium
25   - Scenario: post a comment while not authenticated
26   - Given I am on /booking/article-to-comment
27   - And I fill in "Name" with "Joey Ramone"
28   - And I fill in "e-mail" with "joey@ramones.com"
29   - And I fill in "Title" with "Hey ho, let's go!"
30   - And I fill in "Enter your comment" with "Hey ho, let's go!"
31   - When I press "Post comment"
32   - Then I should see "Hey ho, let's go"
33   -
34   - @selenium
35   - Scenario: post comment while authenticated
36   - Given I am logged in as "booking"
37   - And I am on /booking/article-to-comment
38   - And I fill in "Title" with "Hey ho, let's go!"
39   - And I fill in "Enter your comment" with "Hey ho, let's go!"
40   - When I press "Post comment"
41   - Then I should see "Hey ho, let's go"
42   -
43   - @selenium
44   - Scenario: redirect to right place after comment a picture
45   - Given the following files
46   - | owner | file | mime |
47   - | booking | rails.png | image/png |
48   - Given I am logged in as "booking"
49   - And I am on /booking/rails.png?view=true
50   - And I fill in "Title" with "Hey ho, let's go!"
51   - And I fill in "Enter your comment" with "Hey ho, let's go!"
52   - When I press "Post comment"
53   - Then I should be exactly on /booking/rails.png?view=true
54   -
55   - @selenium
56   - Scenario: show error messages when make a blank comment
57   - Given I am logged in as "booking"
58   - And I am on /booking/article-to-comment
59   - When I press "Post comment"
60   - Then I should see "Title can't be blank"
61   - And I should see "Body can't be blank"
62   -
63   - @selenium
64   - Scenario: disable post comment button
65   - Given I am on /booking/article-to-comment
66   - And I fill in "Name" with "Joey Ramone"
67   - And I fill in "e-mail" with "joey@ramones.com"
68   - And I fill in "Title" with "Hey ho, let's go!"
69   - And I fill in "Enter your comment" with "Hey ho, let's go!"
70   - When I press "Post comment"
71   - Then the "value.Post comment" button should not be enabled
72   - And I should see "Hey ho, let's go"
73   -
74   - @selenium
75   - Scenario: render comment form and go to bottom
76   - Given I am on /booking/article-with-comment
77   - When I follow "Post a comment" within ".post-comment-button"
78   - Then I should see "Enter your comment" within "div#page-comment-form div.post_comment_box.opened"
79   - And I should be exactly on /booking/article-with-comment
80   - And I should be moved to anchor "comment_form"
81   -
82   - @selenium
83   - Scenario: keep comments field filled while trying to do a comment
84   - Given I am on /booking/article-with-comment
85   - And I fill in "Name" with "Joey Ramone"
86   - When I press "Post comment"
87   - Then the "Name" field should contain "Joey Ramone"
88   - And I should see "errors prohibited"
public/stylesheets/application.css
... ... @@ -1434,7 +1434,8 @@ a.comment-picture {
1434 1434 border-radius: 5px;
1435 1435 }
1436 1436  
1437   -.comment-replies .article-comment-inner {
  1437 +.comment-replies .article-comment-inner,
  1438 +.scrap-replies {
1438 1439 border: 1px solid #fff;
1439 1440 padding: 0;
1440 1441 -moz-border-radius: 4px;
... ... @@ -5895,6 +5896,9 @@ h1#agenda-title {
5895 5896 position: relative;
5896 5897 }
5897 5898  
  5899 +#profile-activity li, #profile-network li, #profile-wall li {
  5900 +}
  5901 +
5898 5902 .profile-activity-lead img {
5899 5903 width: 124px;
5900 5904 float: left;
... ... @@ -5954,12 +5958,12 @@ h1#agenda-title {
5954 5958 }
5955 5959  
5956 5960 #profile-wall li.profile-activity-item.upload_image span,
5957   -#profile-wall li.profile-activity-item.upload_image span img,
  5961 +#Xprofile-wall li.profile-activity-item.upload_image span img,
5958 5962 #profile-wall li.profile-activity-item.upload_image span a,
5959 5963 #profile-network li.profile-activity-item.upload_image span,
5960   -#profile-network li.profile-activity-item.upload_image span img,
  5964 +#Xprofile-network li.profile-activity-item.upload_image span img,
5961 5965 #profile-network li.profile-activity-item.upload_image span a {
5962   - width: 124px;
  5966 + width: 120px;
5963 5967 height: 100px;
5964 5968 display: block;
5965 5969 overflow: hidden;
... ... @@ -5967,13 +5971,16 @@ h1#agenda-title {
5967 5971 }
5968 5972  
5969 5973 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
5970   -#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img,
5971 5974 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
5972 5975 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
5973   -#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img,
5974 5976 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {
5975 5977 width: 383px;
5976   - height: 177px;
  5978 + height: auto;
  5979 +}
  5980 +
  5981 +#profile-wall li.profile-activity-item.upload_image span img,
  5982 +#profile-network li.profile-activity-item.upload_image span img {
  5983 + display: block;
5977 5984 }
5978 5985  
5979 5986 #profile-wall li.profile-activity-item.upload_image span,
... ... @@ -5992,6 +5999,7 @@ h1#agenda-title {
5992 5999 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
5993 6000 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {
5994 6001 background-image: url(/images/gallery-image-activity-border-big.png);
  6002 + position: relative;
5995 6003 }
5996 6004  
5997 6005 #profile-wall li.profile-activity-item.upload_image .article-comment span,
... ... @@ -6555,6 +6563,10 @@ h1#agenda-title {
6555 6563 padding: 0 5px;
6556 6564 }
6557 6565  
  6566 +.scrap-replies .profile-wall-reply-form {
  6567 + margin-left: 0px;
  6568 +}
  6569 +
6558 6570 .profile-wall-scrap-replies {
6559 6571 float: right;
6560 6572 margin-right: 2px;
... ... @@ -6584,11 +6596,6 @@ h1#agenda-title {
6584 6596 word-wrap: break-word;
6585 6597 }
6586 6598  
6587   -#profile-wall .profile-wall-scrap-replies textarea,
6588   -#profile-network textarea, #profile-wall textarea {
6589   - width: 98%;
6590   -}
6591   -
6592 6599 #profile-wall textarea {
6593 6600 width: 375px;
6594 6601 }
... ... @@ -6597,6 +6604,12 @@ h1#agenda-title {
6597 6604 width: 388px;
6598 6605 }
6599 6606  
  6607 +#profile-wall .profile-wall-scrap-replies textarea,
  6608 +#profile-network textarea, #profile-wall textarea,
  6609 +#profile-wall li .profile-wall-reply-form textarea {
  6610 + width: 98%;
  6611 +}
  6612 +
6600 6613 #profile-wall #leave_scrap textarea {
6601 6614 width: 442px;
6602 6615 }
... ...
test/factories.rb
... ... @@ -370,7 +370,7 @@ module Noosfero::Factory
370 370 ###############################################
371 371  
372 372 def defaults_for_scrap(params = {})
373   - { :content => 'soment content ', :sender_id => 1, :receiver_id => 1, :created_at => DateTime.now }.merge(params)
  373 + { :content => 'some content ', :sender_id => 1, :receiver_id => 1, :created_at => DateTime.now }.merge(params)
374 374 end
375 375  
376 376 ###############################################
... ...
test/functional/profile_controller_test.rb
... ... @@ -714,22 +714,15 @@ class ProfileControllerTest &lt; ActionController::TestCase
714 714 assert_no_tag :tag => 'p', :content => 'A scrap'
715 715 end
716 716  
717   - should 'see only actions of the current profile when he is not followed by the viewer' do
718   - p1= Person.first
  717 + should 'not display activities of the current profile when he is not followed by the viewer' do
  718 + p1= fast_create(Person)
719 719 p2= fast_create(Person)
720   - p3= fast_create(Person)
721 720  
722   -# UserStampSweeper.any_instance.stubs(:current_user).returns(p1)
723   - ActionTracker::Record.destroy_all
724   - scrap1 = Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1))
725   -
726   -# UserStampSweeper.any_instance.stubs(:current_user).returns(p2)
727   - scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3))
728   -# a2 = ActionTracker::Record.last
  721 + UserStampSweeper.any_instance.stubs(:current_user).returns(p1)
  722 + scrap1 = Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p2))
729 723  
730   -# UserStampSweeper.any_instance.stubs(:current_user).returns(p3)
731   - scrap3 = Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1))
732   -# a3 = ActionTracker::Record.last
  724 + UserStampSweeper.any_instance.stubs(:current_user).returns(p2)
  725 + scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p1))
733 726  
734 727 UserStampSweeper.any_instance.stubs(:current_user).returns(p1)
735 728 TinyMceArticle.create!(:profile => p1, :name => 'An article about free software')
... ... @@ -737,8 +730,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
737 730  
738 731 login_as(profile.identifier)
739 732 get :index, :profile => p1.identifier
740   - assert_not_nil assigns(:activities)
741   - assert_equal [a1], assigns(:activities)
  733 + assert_nil assigns(:activities)
742 734 end
743 735  
744 736 should 'see the activities_items paginated' do
... ... @@ -750,31 +742,27 @@ class ProfileControllerTest &lt; ActionController::TestCase
750 742 assert_equal 30, assigns(:activities).count
751 743 end
752 744  
753   - should 'not see the friends actions and scraps in the current profile activity' do
754   - p1= Person.first
  745 + should 'not see the friends activities in the current profile' do
755 746 p2= fast_create(Person)
756   - assert !p1.is_a_friend?(p2)
  747 + assert !profile.is_a_friend?(p2)
757 748 p3= fast_create(Person)
758   - p1.add_friend(p3)
759   - assert p1.is_a_friend?(p3)
  749 + p3.add_friend(profile)
  750 + assert p3.is_a_friend?(profile)
760 751 ActionTracker::Record.destroy_all
761 752  
762   - scrap1 = Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1))
763   - scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3))
764   - scrap3 = Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1))
  753 + scrap1 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3))
  754 + scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => profile))
765 755  
766 756 UserStampSweeper.any_instance.stubs(:current_user).returns(p3)
767   - TinyMceArticle.create!(:profile => p3, :name => 'An article about free software')
768   - a1 = ActionTracker::Record.last
  757 + article1 = TinyMceArticle.create!(:profile => p3, :name => 'An article about free software')
769 758  
770   - UserStampSweeper.any_instance.stubs(:current_user).returns(p1)
771   - TinyMceArticle.create!(:profile => p1, :name => 'Another article about free software')
772   - a2 = ActionTracker::Record.last
  759 + UserStampSweeper.any_instance.stubs(:current_user).returns(p2)
  760 + article2 = TinyMceArticle.create!(:profile => p2, :name => 'Another article about free software')
773 761  
774 762 login_as(profile.identifier)
775   - get :index, :profile => p1.identifier
  763 + get :index, :profile => p3.identifier
776 764 assert_not_nil assigns(:activities)
777   - assert_equal [a2], assigns(:activities)
  765 + assert_equivalent [scrap1, article1.activity], assigns(:activities).map { |a| a.klass.constantize.find(a.id) }
778 766 end
779 767  
780 768 should 'see all the activities in the current profile network' do
... ... @@ -942,13 +930,29 @@ class ProfileControllerTest &lt; ActionController::TestCase
942 930 assert_template 'index'
943 931 end
944 932  
945   - should 'have wall_itens defined' do
946   - p1= ActionTracker::Record.current_user_from_model
  933 + should 'not have activities defined if not logged in' do
  934 + p1= fast_create(Person)
947 935 get :index, :profile => p1.identifier
948   - assert_equal [], assigns(:wall_items)
  936 + assert_nil assigns(:actvities)
949 937 end
950 938  
951   - should 'the wall_itens be the received scraps in people profile' do
  939 + should 'not have activities defined if logged in but is not following profile' do
  940 + login_as(profile.identifier)
  941 + p1= fast_create(Person)
  942 + get :index, :profile => p1.identifier
  943 + assert_nil assigns(:activities)
  944 + end
  945 +
  946 + should 'have activities defined if logged in and is following profile' do
  947 + login_as(profile.identifier)
  948 + p1= fast_create(Person)
  949 + p1.add_friend(profile)
  950 + ActionTracker::Record.destroy_all
  951 + get :index, :profile => p1.identifier
  952 + assert_equal [], assigns(:activities)
  953 + end
  954 +
  955 + should 'the activities be the received scraps in people profile' do
952 956 p1 = ActionTracker::Record.current_user_from_model
953 957 p2 = fast_create(Person)
954 958 p3 = fast_create(Person)
... ... @@ -963,10 +967,10 @@ class ProfileControllerTest &lt; ActionController::TestCase
963 967 @controller.stubs(:current_user).returns(user)
964 968 Person.any_instance.stubs(:follows?).returns(true)
965 969 get :index, :profile => p1.identifier
966   - assert_equal [s2,s3], assigns(:wall_items)
  970 + assert_equal [s2,s3], assigns(:activities)
967 971 end
968 972  
969   - should 'the wall_itens be the received scraps in community profile' do
  973 + should 'the activities be the received scraps in community profile' do
970 974 c = fast_create(Community)
971 975 p1 = fast_create(Person)
972 976 p2 = fast_create(Person)
... ... @@ -982,10 +986,10 @@ class ProfileControllerTest &lt; ActionController::TestCase
982 986 @controller.stubs(:current_user).returns(user)
983 987 Person.any_instance.stubs(:follows?).returns(true)
984 988 get :index, :profile => c.identifier
985   - assert_equal [s2,s3], assigns(:wall_items)
  989 + assert_equal [s2,s3], assigns(:activities)
986 990 end
987 991  
988   - should 'the wall_itens be paginated in people profiles' do
  992 + should 'the activities be paginated in people profiles' do
989 993 p1 = Person.first
990 994 40.times{fast_create(Scrap, :sender_id => p1.id, :created_at => Time.now)}
991 995  
... ... @@ -997,10 +1001,10 @@ class ProfileControllerTest &lt; ActionController::TestCase
997 1001 Person.any_instance.stubs(:follows?).returns(true)
998 1002 assert_equal 40, p1.scraps_received.not_replies.count
999 1003 get :index, :profile => p1.identifier
1000   - assert_equal 30, assigns(:wall_items).count
  1004 + assert_equal 30, assigns(:activities).count
1001 1005 end
1002 1006  
1003   - should 'the wall_itens be paginated in community profiles' do
  1007 + should 'the activities be paginated in community profiles' do
1004 1008 p1 = Person.first
1005 1009 c = fast_create(Community)
1006 1010 40.times{fast_create(Scrap, :receiver_id => c.id)}
... ... @@ -1013,7 +1017,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
1013 1017 Person.any_instance.stubs(:follows?).returns(true)
1014 1018 assert_equal 40, c.scraps_received.not_replies.count
1015 1019 get :index, :profile => c.identifier
1016   - assert_equal 30, assigns(:wall_items).count
  1020 + assert_equal 30, assigns(:activities).count
1017 1021 end
1018 1022  
1019 1023 should "the owner of activity could remove it" do
... ... @@ -1083,17 +1087,17 @@ class ProfileControllerTest &lt; ActionController::TestCase
1083 1087 end
1084 1088 end
1085 1089  
1086   - should "not show the scrap button on network activity if the user don't follow the user" do
  1090 + should "not show the network activity if the viewer don't follow the profile" do
1087 1091 login_as(profile.identifier)
1088 1092 person = fast_create(Person)
1089 1093 at = fast_create(ActionTracker::Record, :user_id => person.id)
1090 1094 atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id)
1091   - get :index, :profile => profile.identifier
1092   - assert_no_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'}
  1095 + get :index, :profile => person.identifier
  1096 + assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'}
1093 1097  
1094 1098 person.add_friend(profile)
1095   - get :index, :profile => profile.identifier
1096   - assert_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'}
  1099 + get :index, :profile => person.identifier
  1100 + assert_tag :tag => 'div', :attributes => {:id => 'profile-network'}
1097 1101 end
1098 1102  
1099 1103 should "not show the scrap button on network activity if the user is himself" do
... ... @@ -1104,16 +1108,16 @@ class ProfileControllerTest &lt; ActionController::TestCase
1104 1108 assert_no_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'}
1105 1109 end
1106 1110  
1107   - should "not show the scrap button on wall activity if the user don't follow the user" do
  1111 + should "not show the scrap area on wall if the user don't follow the user" do
1108 1112 login_as(profile.identifier)
1109 1113 person = fast_create(Person)
1110 1114 scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id)
1111   - get :index, :profile => profile.identifier
1112   - assert_no_tag :tag => 'p', :attributes => {:class => 'profile-wall-send-message'}
  1115 + get :index, :profile => person.identifier
  1116 + assert_no_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} }
1113 1117  
1114 1118 person.add_friend(profile)
1115   - get :index, :profile => profile.identifier
1116   - assert_tag :tag => 'p', :attributes => {:class => 'profile-wall-send-message'}
  1119 + get :index, :profile => person.identifier
  1120 + assert_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} }
1117 1121 end
1118 1122  
1119 1123 should "not show the scrap button on wall activity if the user is himself" do
... ... @@ -1169,7 +1173,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
1169 1173 assert_equal 40, profile.tracked_actions.count
1170 1174 get :view_more_activities, :profile => profile.identifier, :page => 2
1171 1175 assert_response :success
1172   - assert_template '_profile_activities_scraps'
  1176 + assert_template '_profile_activities_list'
1173 1177 assert_equal 10, assigns(:activities).count
1174 1178 end
1175 1179  
... ... @@ -1270,8 +1274,8 @@ class ProfileControllerTest &lt; ActionController::TestCase
1270 1274 login_as(profile.identifier)
1271 1275 get :index, :profile => profile.identifier
1272 1276  
1273   - assert_tag :tag => 'div', :attributes => { :id => 'profile-wall' }, :descendant => { :tag => 'p', :content => 'A scrap' }
1274   - assert_tag :tag => 'div', :attributes => { :id => 'profile-wall' }, :descendant => { :tag => 'a', :content => 'An article about free software' }
  1277 + assert_tag :tag => 'p', :content => 'A scrap', :attributes => { :class => 'profile-activity-text'}
  1278 + assert_tag :tag => 'div', :attributes => { :class => 'profile-activity-lead' }, :descendant => { :tag => 'a', :content => 'An article about free software' }
1275 1279 end
1276 1280  
1277 1281 should 'have scraps and activities on activities' do
... ... @@ -1307,7 +1311,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
1307 1311  
1308 1312 assert_equal 0, count
1309 1313 post :leave_comment_on_activity, :profile => profile.identifier, :comment => {:body => 'something'}, :source_id => activity.id
1310   - assert_equal count + 1, activity.comments.count
  1314 + assert_equal count + 1, ActionTracker::Record.find(activity.id).comments_count
1311 1315 assert_response :success
1312 1316 assert_equal "Comment successfully added.", assigns(:message)
1313 1317 end
... ... @@ -1318,10 +1322,9 @@ class ProfileControllerTest &lt; ActionController::TestCase
1318 1322 TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software')
1319 1323 activity = ActionTracker::Record.last
1320 1324 count = activity.comments.count
1321   -puts activity.inspect
1322 1325 assert_equal 0, count
1323 1326 post :leave_comment_on_activity, :profile => another_person.identifier, :comment => {:body => 'something'}, :source_id => activity.id
1324   - assert_equal count + 1, activity.comments.count
  1327 + assert_equal count + 1, ActionTracker::Record.find(activity.id).comments_count
1325 1328 assert_response :success
1326 1329 assert_equal "Comment successfully added.", assigns(:message)
1327 1330 end
... ...
test/unit/article_test.rb
... ... @@ -323,11 +323,13 @@ class ArticleTest &lt; ActiveSupport::TestCase
323 323 (1..4).each do |n|
324 324 create(TextileArticle, :name => "art #{n}", :profile_id => profile.id)
325 325 end
326   - 2.times { profile.articles.first.comments.build(:title => 'test', :body => 'asdsad', :author => profile).save! }
327   - 4.times { profile.articles.last.comments.build(:title => 'test', :body => 'asdsad', :author => profile).save! }
328   -assert_equal 'bla', profile.articles.map(&:comments_count)
  326 + first_article = profile.articles.first
  327 + 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => first_article).save! }
  328 +
  329 + last_article = profile.articles.last
  330 + 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => last_article).save! }
329 331 # should respect the order (more commented comes first)
330   - assert_equal [profile.articles.first], profile.articles.most_commented(2)
  332 + assert_equal [last_article, first_article], profile.articles.most_commented(2)
331 333 end
332 334  
333 335 should 'identify itself as a non-folder' do
... ... @@ -361,16 +363,16 @@ assert_equal &#39;bla&#39;, profile.articles.map(&amp;:comments_count)
361 363  
362 364 should 'index comments title together with article' do
363 365 owner = create_user('testuser').person
364   - art = owner.articles.build(:name => 'ytest'); art.save!
365   - c1 = art.comments.build(:title => 'a nice comment', :body => 'anything', :author => owner); c1.save!
  366 + art = fast_create(TinyMceArticle, :profile_id => owner.id, :name => 'ytest')
  367 + c1 = Comment.create(:title => 'a nice comment', :body => 'anything', :author => owner, :source => art ); c1.save!
366 368  
367 369 assert_includes Article.find_by_contents('nice'), art
368 370 end
369 371  
370 372 should 'index comments body together with article' do
371 373 owner = create_user('testuser').person
372   - art = owner.articles.build(:name => 'ytest'); art.save!
373   - c1 = art.comments.build(:title => 'test comment', :body => 'anything', :author => owner); c1.save!
  374 + art = fast_create(TinyMceArticle, :profile_id => owner.id, :name => 'ytest')
  375 + c1 = Comment.create(:title => 'test comment', :body => 'anything', :author => owner, :source => art); c1.save!
374 376  
375 377 assert_includes Article.find_by_contents('anything'), art
376 378 end
... ...
test/unit/category_finder_test.rb
... ... @@ -188,17 +188,20 @@ class CategoryFinderTest &lt; ActiveSupport::TestCase
188 188 end
189 189  
190 190 should 'return most commented articles' do
  191 + person = create_user('testuser').person
191 192 Article.delete_all
192 193  
193   - person = create_user('testuser').person
194   - articles = (1..4).map {|n| a = person.articles.build(:name => "art #{n}", :category_ids => [@category.id]); a.save!; a }
  194 + (1..4).map {|n| create(TextileArticle, :profile_id => person.id, :name => "art #{n}", :category_ids => [@category.id]) }
  195 +
  196 + first_article = person.articles.first
  197 + 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => person, :source => first_article) }
195 198  
196   - 2.times { articles[0].comments.build(:title => 'test', :body => 'asdsad', :author => person).save! }
197   - 4.times { articles[1].comments.build(:title => 'test', :body => 'asdsad', :author => person).save! }
  199 + last_article = person.articles.last
  200 + 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => person, :source => last_article) }
198 201  
199 202 result = @finder.most_commented_articles(2)
200 203 # should respect the order (more commented comes first)
201   - assert_equal [articles[1], articles[0]], result
  204 + assert_equal [last_article, first_article], result
202 205 assert_respond_to result, :total_entries
203 206 end
204 207  
... ...
test/unit/category_test.rb
... ... @@ -260,13 +260,14 @@ class CategoryTest &lt; ActiveSupport::TestCase
260 260 a2 = person.articles.build(:name => 'art2', :category_ids => [c.id]); a2.save!
261 261 a3 = person.articles.build(:name => 'art3', :category_ids => [c.id]); a3.save!
262 262  
263   - a1.comments.build(:title => 'test', :body => 'asdsa', :author => person).save!
264   - 5.times { a2.comments.build(:title => 'test', :body => 'asdsa', :author => person).save! }
  263 + Comment.create(:title => 'test', :body => 'asdsa', :author => person, :source => a1)
  264 + 5.times { Comment.create(:title => 'test', :body => 'asdsa', :author => person, :source => a2) }
265 265  
266   - 10.times { a3.comments.build(:title => 'test', :body => 'kajsdsa', :author => person).save! }
  266 + 10.times { Comment.create(:title => 'test', :body => 'kajsdsa', :author => person, :source => a3) }
267 267  
268 268 assert_equal [a3, a2], c.most_commented_articles(2)
269 269 end
  270 +
270 271 should 'have comments' do
271 272 c = @env.categories.build(:name => 'my category'); c.save!
272 273 person = create_user('testuser').person
... ...
test/unit/comment_notifier_test.rb
... ... @@ -12,26 +12,26 @@ class CommentNotifierTest &lt; ActiveSupport::TestCase
12 12 @article = fast_create(Article, :name => 'Article test', :profile_id => @profile.id, :notify_comments => true)
13 13 end
14 14  
15   - should 'deliver mail after make aarticle commment' do
  15 + should 'deliver mail after make an article comment' do
16 16 assert_difference ActionMailer::Base.deliveries, :size do
17   - @article.comments << Comment.new(:author => @profile, :title => 'test comment', :body => 'you suck!')
  17 + Comment.create(:author => @profile, :title => 'test comment', :body => 'you suck!', :source => @article )
18 18 end
19 19 end
20 20  
21 21 should 'deliver mail to owner of article' do
22   - @article.comments << Comment.new(:author => @profile, :title => 'test comment', :body => 'you suck!')
  22 + Comment.create(:author => @profile, :title => 'test comment', :body => 'you suck!', :source => @article )
23 23 sent = ActionMailer::Base.deliveries.first
24 24 assert_equal [@profile.email], sent.to
25 25 end
26 26  
27 27 should 'display author name in delivered mail' do
28   - @article.comments << Comment.new(:author => @profile, :title => 'test comment', :body => 'you suck!')
  28 + Comment.create(:author => @profile, :title => 'test comment', :body => 'you suck!', :source => @article)
29 29 sent = ActionMailer::Base.deliveries.first
30 30 assert_match /user_comment_test/, sent.body
31 31 end
32 32  
33 33 should 'display unauthenticated author name and email in delivered mail' do
34   - @article.comments << Comment.new(:name => 'flatline', :email => 'flatline@invalid.com', :title => 'test comment', :body => 'you suck!')
  34 + Comment.create(:name => 'flatline', :email => 'flatline@invalid.com', :title => 'test comment', :body => 'you suck!', :source => @article )
35 35 sent = ActionMailer::Base.deliveries.first
36 36 assert_match /flatline/, sent.body
37 37 assert_match /flatline@invalid.com/, sent.body
... ... @@ -45,13 +45,13 @@ class CommentNotifierTest &lt; ActiveSupport::TestCase
45 45 end
46 46  
47 47 should 'include comment title in the e-mail' do
48   - @article.comments << Comment.new(:author => @profile, :title => 'comment title', :body => 'comment title')
  48 + Comment.create(:author => @profile, :title => 'comment title', :body => 'comment body', :source => @article)
49 49 sent = ActionMailer::Base.deliveries.first
50 50 assert_match /comment title/, sent.body
51 51 end
52 52  
53 53 should 'include comment text in the e-mail' do
54   - @article.comments << Comment.new(:author => @profile, :title => 'comment title', :body => 'comment body')
  54 + Comment.create(:author => @profile, :title => 'comment title', :body => 'comment body', :source => @article)
55 55 sent = ActionMailer::Base.deliveries.first
56 56 assert_match /comment body/, sent.body
57 57 end
... ...
test/unit/comment_test.rb
... ... @@ -339,8 +339,6 @@ class CommentTest &lt; ActiveSupport::TestCase
339 339 assert c.rejected?
340 340 end
341 341  
342   - should 'update activity when add a comment'
343   -
344 342 should 'update article activity when add a comment' do
345 343 profile = create_user('testuser').person
346 344 article = create(TinyMceArticle, :profile => profile)
... ...
test/unit/enterprise_test.rb
... ... @@ -451,5 +451,36 @@ class EnterpriseTest &lt; ActiveSupport::TestCase
451 451 assert_respond_to e, :production_costs
452 452 end
453 453  
454   - should 'return tracked_actions and scraps as activities'
  454 + should 'return scraps as activities' do
  455 + person = fast_create(Person)
  456 + enterprise = fast_create(Enterprise)
  457 +
  458 +
  459 + activity = ActionTracker::Record.last
  460 + scrap = Scrap.create!(defaults_for_scrap(:sender => person, :receiver => enterprise, :content => 'A scrap'))
  461 +
  462 + assert_equal [scrap], enterprise.activities.map { |a| a.klass.constantize.find(a.id) }
  463 + end
  464 +
  465 + should 'return tracked_actions of community as activities' do
  466 + person = fast_create(Person)
  467 + enterprise = fast_create(Enterprise)
  468 +
  469 + UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once
  470 + article = create(TinyMceArticle, :profile => enterprise, :name => 'An article about free software')
  471 +
  472 + assert_equal [article.activity], enterprise.activities.map { |a| a.klass.constantize.find(a.id) }
  473 + end
  474 +
  475 + should 'not return tracked_actions of other community as activities' do
  476 + person = fast_create(Person)
  477 + enterprise = fast_create(Enterprise)
  478 + enterprise2 = fast_create(Enterprise)
  479 +
  480 + UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once
  481 + article = create(TinyMceArticle, :profile => enterprise2, :name => 'Another article about free software')
  482 +
  483 + assert_not_includes enterprise.activities.map { |a| a.klass.constantize.find(a.id) }, article.activity
  484 + end
  485 +
455 486 end
... ...
test/unit/forum_helper_test.rb
... ... @@ -63,7 +63,7 @@ class ForumHelperTest &lt; ActiveSupport::TestCase
63 63 some_post.comments << Comment.new(:name => 'John', :email => 'lenon@example.com', :title => 'test', :body => 'test')
64 64 c = Comment.last
65 65 out = last_topic_update(some_post)
66   - assert_match "#{c.created_at.to_s} ago by John", out
  66 + assert_match "#{c.created_at.to_s} by John", out
67 67 assert_match 'John', out
68 68 end
69 69  
... ...
test/unit/textile_article_test.rb
... ... @@ -47,7 +47,7 @@ class TextileArticleTest &lt; ActiveSupport::TestCase
47 47 assert_equal 3, ActionTracker::Record.count
48 48 end
49 49  
50   - should 'update activity on update of an article' do
  50 + should 'not update activity on update of an article' do
51 51 ActionTracker::Record.delete_all
52 52 profile = fast_create(Profile)
53 53 article = create(TextileArticle, :profile_id => profile.id)
... ... @@ -57,7 +57,7 @@ class TextileArticleTest &lt; ActiveSupport::TestCase
57 57 article.name = 'foo'
58 58 article.save!
59 59 end
60   - assert_equal time + 1.day, article.activity.updated_at
  60 + assert_equal time, article.activity.updated_at
61 61 end
62 62  
63 63 should 'not create trackers activity when updating articles' do
... ...
test/unit/tiny_mce_article_test.rb
... ... @@ -144,7 +144,7 @@ class TinyMceArticleTest &lt; ActiveSupport::TestCase
144 144 assert_equal 3, ActionTracker::Record.count
145 145 end
146 146  
147   - should 'update activity on update of an article' do
  147 + should 'not update activity on update of an article' do
148 148 ActionTracker::Record.delete_all
149 149 profile = fast_create(Profile)
150 150 article = create(TinyMceArticle, :profile_id => profile.id)
... ... @@ -154,7 +154,7 @@ class TinyMceArticleTest &lt; ActiveSupport::TestCase
154 154 article.name = 'foo'
155 155 article.save!
156 156 end
157   - assert_equal time + 1.day, article.activity.updated_at
  157 + assert_equal time, article.activity.updated_at
158 158 end
159 159  
160 160 should 'not create trackers activity when updating articles' do
... ...
test/unit/uploaded_file_test.rb
... ... @@ -231,10 +231,10 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
231 231 should 'return a thumbnail for images' do
232 232 f = UploadedFile.new
233 233 f.expects(:image?).returns(true)
234   - f.expects(:full_filename).with(:thumb).returns(File.join(RAILS_ROOT, 'public', 'images', '0000', '0005', 'x.png'))
  234 + f.expects(:full_filename).with(:display).returns(File.join(RAILS_ROOT, 'public', 'images', '0000', '0005', 'x.png'))
235 235 assert_equal '/images/0000/0005/x.png', f.thumbnail_path
236 236 f = UploadedFile.new
237   - f.stubs(:full_filename).with(:thumb).returns(File.join(RAILS_ROOT, 'public', 'images', '0000', '0005', 'x.png'))
  237 + f.stubs(:full_filename).with(:display).returns(File.join(RAILS_ROOT, 'public', 'images', '0000', '0005', 'x.png'))
238 238 f.expects(:image?).returns(false)
239 239 assert_nil f.thumbnail_path
240 240 end
... ... @@ -330,11 +330,11 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
330 330 assert_equal 'hello_world.php.txt', file.filename
331 331 end
332 332  
333   - should 'use the gallery as the parent for action tracker' do
  333 + should 'use itself as target for action tracker' do
334 334 p = fast_create(Gallery, :profile_id => @profile.id)
335 335 f = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => p, :profile => @profile)
336   - ta = ActionTracker::Record.last(:conditions => { :verb => "upload_image" })
337   - assert_equal f.parent, ta.target
  336 + ta = f.activity
  337 + assert_equal f, ta.target
338 338 end
339 339  
340 340 end
... ...