Sha256: ec7063024943064879b39e574131cbf95af1f2288df1c43b472a8b894f53aefa
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
require 'test_helper' ActionController::Routing::Routes.draw do |map| map.resources :widgets end class ApplicationController < ActionController::Base def rescue_action(e) raise e end # Returns id of hypothetical current user def current_user 153 end end class WidgetsController < ApplicationController def create @widget = Widget.create params[:widget] head :ok end def update @widget = Widget.find params[:id] @widget.update_attributes params[:widget] head :ok end def destroy @widget = Widget.find params[:id] @widget.destroy head :ok end end class PaperTrailControllerTest < ActionController::TestCase tests WidgetsController 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 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 end test 'destroy' do w = Widget.create :name => 'Roundel' assert_equal 1, w.versions.length delete :destroy, :id => w.id widget = assigns(:widget) assert_equal 2, widget.versions.length assert_equal 153, widget.versions.last.whodunnit.to_i end end
Version data entries
4 entries across 4 versions & 1 rubygems