Sha256: 0a9eeb427251597d604b4fd91b6629c8864110e3c400691629d8c81a517ba748

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

require 'test_helper'

class ControllerTest < ActionController::TestCase
  tests WidgetsController

  setup do
    @request.env['REMOTE_ADDR'] = '127.0.0.1'
  end

  test 'create' do
    post :create, :widget => { :name => 'Flugel' }
    widget = assigns(:widget)
    assert_equal 1, widget.versions.length
    assert_equal 153, widget.versions.last.whodunnit.to_i
    assert_equal '127.0.0.1', widget.versions.last.ip
    assert_equal 'Rails Testing', widget.versions.last.user_agent
  end

  test 'update' do
    w = Widget.create :name => 'Duvel'
    assert_equal 1, w.versions.length
    put :update, :id => w.id, :widget => { :name => 'Bugle' }
    widget = assigns(:widget)
    assert_equal 2, widget.versions.length
    assert_equal 153, widget.versions.last.whodunnit.to_i
    assert_equal '127.0.0.1', widget.versions.last.ip
    assert_equal 'Rails Testing', widget.versions.last.user_agent
  end

  test 'destroy' do
    w = Widget.create :name => 'Roundel'
    assert_equal 1, w.versions.length
    delete :destroy, :id => w.id
    widget = assigns(:widget)
    versions_for_widget = Version.with_item_keys('Widget', w.id)
    assert_equal 2,               versions_for_widget.length
    assert_equal 153,             versions_for_widget.last.whodunnit.to_i
    assert_equal '127.0.0.1',     versions_for_widget.last.ip
    assert_equal 'Rails Testing', versions_for_widget.last.user_agent
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
paper_trail-2.1.1 test/functional/controller_test.rb
paper_trail-2.1.0 test/functional/controller_test.rb
paper_trail-2.0.2 test/functional/controller_test.rb
paper_trail-2.0.1 test/functional/controller_test.rb
paper_trail-2.0.0 test/functional/controller_test.rb