1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserTermsSeenTest < ActionController::IntegrationTest
6 def auth_header(user, pass)
7 {"HTTP_AUTHORIZATION" => "Basic %s" % Base64.encode64("#{user}:#{pass}")}
11 user = users(:terms_not_seen_user)
13 get "/api/#{API_VERSION}/user/details", nil, auth_header(user.display_name, "test")
14 assert_response :forbidden
16 # touch it so that the user has seen the terms
17 user.terms_seen = true
20 get "/api/#{API_VERSION}/user/details", nil, auth_header(user.display_name, "test")
21 assert_response :success
24 def test_terms_presented_at_login
25 user = users(:terms_not_seen_user)
28 get_via_redirect "/login"
29 assert_response :success
30 assert_template 'user/login'
31 post "/login", {'user[email]' => user.email, 'user[password]' => 'test', :referer => "/"}
32 assert_response :redirect
33 # but now we need to look at the terms
34 assert_redirected_to "controller" => "user", "action" => "terms", :referer => "/"
36 assert_response :success
38 # don't agree to the terms, but hit decline
40 # should be carried through to a normal login