From 0d710239a765787f10de304edc438de2dfaa9824 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 20:45:29 -0500 Subject: make a session model as well as controller --- test/controllers/sessions_controller_test.rb | 48 ++++++++++++++++++++++++++-- test/fixtures/sessions.yml | 7 ++++ test/models/session_test.rb | 7 ++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/sessions.yml create mode 100644 test/models/session_test.rb (limited to 'test') diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index d30ebc3..a5cc8cb 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -1,7 +1,49 @@ require 'test_helper' class SessionsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end + setup do + @session = sessions(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sessions) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create session" do + assert_difference('Session.count') do + post :create, session: { user_id: @session.user_id } + end + + assert_redirected_to session_path(assigns(:session)) + end + + test "should show session" do + get :show, id: @session + assert_response :success + end + + test "should get edit" do + get :edit, id: @session + assert_response :success + end + + test "should update session" do + patch :update, id: @session, session: { user_id: @session.user_id } + assert_redirected_to session_path(assigns(:session)) + end + + test "should destroy session" do + assert_difference('Session.count', -1) do + delete :destroy, id: @session + end + + assert_redirected_to sessions_path + end end diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml new file mode 100644 index 0000000..d9098d9 --- /dev/null +++ b/test/fixtures/sessions.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + user_id: + +two: + user_id: diff --git a/test/models/session_test.rb b/test/models/session_test.rb new file mode 100644 index 0000000..2d1bc1b --- /dev/null +++ b/test/models/session_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SessionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- cgit v1.2.3