Phase 2 CTs implementation and tests, with config parameter

This commit is contained in:
Matt Amos 2011-03-22 10:26:10 +00:00 committed by Tom Hughes
parent 82db7eccc8
commit 8b12abd5bb
11 changed files with 102 additions and 15 deletions

View file

@ -11,6 +11,7 @@ normal_user:
home_lat: 12.1
home_lon: 12.1
home_zoom: 3
terms_seen: true
public_user:
id: 2
@ -24,6 +25,7 @@ public_user:
home_lat: 12
home_lon: 12
home_zoom: 12
terms_seen: true
inactive_user:
id: 3
@ -37,6 +39,7 @@ inactive_user:
home_lat: 123.4
home_lon: 12.34
home_zoom: 15
terms_seen: true
second_public_user:
id: 4
@ -50,6 +53,7 @@ second_public_user:
home_lat: 89
home_lon: 87
home_zoom: 12
terms_seen: true
moderator_user:
id: 5
@ -59,6 +63,7 @@ moderator_user:
creation_time: "2008-05-01 01:23:45"
display_name: moderator
data_public: true
terms_seen: true
administrator_user:
id: 6
@ -68,3 +73,14 @@ administrator_user:
creation_time: "2008-05-01 01:23:45"
display_name: administrator
data_public: true
terms_seen: true
terms_not_seen_user:
id: 7
email: not_agreed@example.com
status: active
pass_crypt: <%= Digest::MD5.hexdigest('test') %>
creation_time: "2011-03-22 00:23:45"
display_name: not_agreed
data_public: true
terms_seen: false

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class DiaryEntryControllerTest < ActionController::TestCase
fixtures :users, :diary_entries, :diary_comments
fixtures :users, :diary_entries, :diary_comments, :languages
include ActionView::Helpers::NumberHelper

View file

@ -0,0 +1,45 @@
require File.dirname(__FILE__) + '/../test_helper'
class UserTermsSeenTest < ActionController::IntegrationTest
fixtures :users
def auth_header(user, pass)
{"HTTP_AUTHORIZATION" => "Basic %s" % Base64.encode64("#{user}:#{pass}")}
end
def test_api_blocked
user = users(:terms_not_seen_user)
get "/api/#{API_VERSION}/user/details", nil, auth_header(user.display_name, "test")
assert_response :forbidden
# touch it so that the user has seen the terms
user.terms_seen = true
user.save
get "/api/#{API_VERSION}/user/details", nil, auth_header(user.display_name, "test")
assert_response :success
end
def test_terms_presented_at_login
user = users(:terms_not_seen_user)
# try to log in
get_via_redirect "/login"
assert_response :success
assert_template 'user/login'
post "/login", {'user[email]' => user.email, 'user[password]' => 'test', :referer => "/"}
assert_response :redirect
# but now we need to look at the terms
assert_redirected_to "controller" => "user", "action" => "terms", :referer => "/"
follow_redirect!
assert_response :success
# don't agree to the terms, but hit decline
# should be carried through to a normal login
end
end