Commit c6427402b414c67d82b6db0dff2e7e3eb31d9854
1 parent
a748e15f
Exists in
master
and in
28 other branches
refactoring more_comments and more_replies method
Showing
3 changed files
with
3 additions
and
21 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -211,8 +211,7 @@ class ProfileController < PublicController |
211 | 211 | end |
212 | 212 | |
213 | 213 | def more_comments |
214 | - activity_id = params[:activity].to_i | |
215 | - activity = ActionTracker::Record.find(:first, :conditions => {:id => activity_id, :user_id => @profile.id}) | |
214 | + activity = ActionTracker::Record.find(:first, :conditions => {:id => params[:activity], :user_id => @profile}) | |
216 | 215 | comments_count = activity.comments.count |
217 | 216 | comment_page = (params[:comment_page] || 1).to_i |
218 | 217 | comments_per_page = 5 |
... | ... | @@ -232,8 +231,7 @@ class ProfileController < PublicController |
232 | 231 | end |
233 | 232 | |
234 | 233 | def more_replies |
235 | - activity_id = params[:activity].to_i | |
236 | - activity = Scrap.find(:first, :conditions => {:id => activity_id, :receiver_id => @profile.id, :scrap_id => nil}) | |
234 | + activity = Scrap.find(:first, :conditions => {:id => params[:activity], :receiver_id => @profile, :scrap_id => nil}) | |
237 | 235 | comments_count = activity.replies.count |
238 | 236 | comment_page = (params[:comment_page] || 1).to_i |
239 | 237 | comments_per_page = 5 | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -734,7 +734,7 @@ class ProfileControllerTest < ActionController::TestCase |
734 | 734 | end |
735 | 735 | |
736 | 736 | should 'see the activities_items paginated' do |
737 | - p1= Person.first | |
737 | + p1 = create_user('some').person | |
738 | 738 | ActionTracker::Record.destroy_all |
739 | 739 | 40.times{Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1))} |
740 | 740 | login_as(p1.identifier) | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -285,22 +285,6 @@ class CommentTest < ActiveSupport::TestCase |
285 | 285 | assert_equal [c1,c3], c.reload.children |
286 | 286 | end |
287 | 287 | |
288 | - should "return activities comments as a thread" do | |
289 | - person = fast_create(Person) | |
290 | - a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body') | |
291 | - c0 = Comment.create!(:source => a, :body => 'My comment', :author => person) | |
292 | - c1 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person) | |
293 | - c2 = Comment.create!(:reply_of_id => c1.id, :source => a, :body => 'bla', :author => person) | |
294 | - c3 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person) | |
295 | - c4 = Comment.create!(:source => a, :body => 'My comment', :author => person) | |
296 | - result = a.activity.comments_as_thread | |
297 | - assert_equal c0, result[0] | |
298 | - assert_equal [c1, c3], result[0].replies | |
299 | - assert_equal [c2], result[0].replies[0].replies | |
300 | - assert_equal c4, result[1] | |
301 | - assert result[1].replies.empty? | |
302 | - end | |
303 | - | |
304 | 288 | should 'provide author url for authenticated user' do |
305 | 289 | author = Person.new |
306 | 290 | author.expects(:url).returns('http://blabla.net/author') | ... | ... |