summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 20:45:29 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 20:45:29 -0500
commit0d710239a765787f10de304edc438de2dfaa9824 (patch)
tree69f60c7b7f6909b6bc4d4805d5473d56cffa3e81 /test
parent11e4de6fd8235b1877b1725d53a98f017130c768 (diff)
make a session model as well as controller
Diffstat (limited to 'test')
-rw-r--r--test/controllers/sessions_controller_test.rb48
-rw-r--r--test/fixtures/sessions.yml7
-rw-r--r--test/models/session_test.rb7
3 files changed, 59 insertions, 3 deletions
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