Commit 389f05f470561e237719c916ee0bcec12a1fa06c
1 parent
04576c7e
Exists in
master
and in
29 other branches
Fix scrap tests
Tests in scrap_test were failing in some random executions. It was caused by the way that action_tracker gets the current user when there is no custom_user setted in track_actions calls. The current logged in used is obtained with ActionTracker::Record.current_user but it's not setted from unit tests. The solution is to set the custom_user as the scrap sender, since that it will always be the same user that is logged in when a scrap is created.
Showing
3 changed files
with
5 additions
and
4 deletions
Show diff stats
app/models/scrap.rb
... | ... | @@ -22,11 +22,11 @@ class Scrap < ActiveRecord::Base |
22 | 22 | |
23 | 23 | scope :not_replies, :conditions => {:scrap_id => nil} |
24 | 24 | |
25 | - track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target | |
25 | + track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target, :custom_user => :sender | |
26 | 26 | |
27 | - track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver} | |
27 | + track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver}, :custom_user => :sender | |
28 | 28 | |
29 | - track_actions :reply_scrap_on_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender != s.receiver && s.sender == s.top_root.receiver} | |
29 | + track_actions :reply_scrap_on_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender != s.receiver && s.sender == s.top_root.receiver}, :custom_user => :sender | |
30 | 30 | |
31 | 31 | after_create :send_notification |
32 | 32 | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -943,7 +943,7 @@ class ProfileControllerTest < ActionController::TestCase |
943 | 943 | @controller.stubs(:current_user).returns(user) |
944 | 944 | Person.any_instance.stubs(:follows?).returns(true) |
945 | 945 | get :index, :profile => p1.identifier |
946 | - assert_equal [s3,s2], assigns(:activities).map(&:activity) | |
946 | + assert_equal [s3,s2], assigns(:activities).map(&:activity).select {|a| a.kind_of?(Scrap)} | |
947 | 947 | end |
948 | 948 | |
949 | 949 | should 'the activities be the received scraps in community profile' do | ... | ... |