Skip to content

Commit

Permalink
Fix sweeper when #current_user method is private
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Sep 29, 2009
1 parent 8560f0e commit cb4fc7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/acts_as_audited/audit_sweeper.rb
Expand Up @@ -73,7 +73,7 @@ def before_update(record)
end

def current_user
controller.send :current_user if controller.respond_to?(:current_user)
controller.send :current_user if controller.respond_to?(:current_user, true)
end

end
5 changes: 3 additions & 2 deletions test/audit_sweeper_test.rb
Expand Up @@ -2,13 +2,14 @@

class AuditsController < ActionController::Base
audit Company
attr_accessor :current_user

def audit
@company = Company.create
render :nothing => true
end

private
attr_accessor :current_user
end
AuditsController.view_paths = [File.dirname(__FILE__)]
ActionController::Routing::Routes.draw {|m| m.connect ':controller/:action/:id' }
Expand All @@ -20,7 +21,7 @@ class AuditsControllerTest < ActionController::TestCase
end

should "audit user" do
user = @controller.current_user = create_user
user = @controller.send(:current_user=, create_user)
lambda { post :audit }.should change { Audit.count }
assigns(:company).audits.last.user.should == user
end
Expand Down

0 comments on commit cb4fc7a

Please sign in to comment.