Sha256: faf92f1991d9e7c4f3b5a6c96300a8b25665903d8c4a079f47b6694f42a67e5a
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require File.dirname(__FILE__) + '/../test_helper' class PostsControllerTest < ActionController::TestCase load_schema def setup @post = Post.create(:title => "Hello", :body => "Hello World") end def test_should_audit_changes put :update, :id => @post.to_param, :post => { :title => "Changed" } @post.reload expected_change = { "title" => ["Hello", "Changed"]} assert_equal "Changed", @post.title assert_equal 1, @post.audits.count assert_equal expected_change, @post.audits.desc.first.change_set end def test_should_respect_current_user User.delete_all @user = User.create!(:name => "ControllerTest") User.create!(:name => "Someone Else") put :update, :id => @post.to_param, :post => { :title => "Changed User Test"}, :user_id => @user.id @post.reload audit = @post.audits.desc.first assert_equal @user.id, audit.user_id end def test_should_not_fail_if_current_user_nil User.delete_all put :update, :id => @post.to_param, :post => { :title => "Changed User Test"}, :user_id => nil @post.reload audit = @post.audits.desc.first assert_equal nil, audit.user_id end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
track_changes-1.0.1 | test/functional/posts_controller_test.rb |
track_changes-1.0.0 | test/functional/posts_controller_test.rb |