agenda-libre-ruby/test/controllers/notes_controller_test.rb

50 lines
1.1 KiB
Ruby

require 'test_helper'
class NotesControllerTest < ActionController::TestCase
setup do
@note = notes(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:notes)
end
test "should get new" do
get :new
assert_response :success
end
test "should create note" do
assert_difference('Note.count') do
post :create, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event }
end
assert_redirected_to note_path(assigns(:note))
end
test "should show note" do
get :show, id: @note
assert_response :success
end
test "should get edit" do
get :edit, id: @note
assert_response :success
end
test "should update note" do
patch :update, id: @note, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event }
assert_redirected_to note_path(assigns(:note))
end
test "should destroy note" do
assert_difference('Note.count', -1) do
delete :destroy, id: @note
end
assert_redirected_to notes_path
end
end