all non-cucumber tests are passing

This commit is contained in:
Reinier Balt 2012-04-27 14:22:16 +02:00
parent 13b58f3a10
commit 63175c115b
46 changed files with 248 additions and 505 deletions

View file

@ -1,19 +1,15 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'todos_controller'
class TodoXmlApiTest < ActionController::IntegrationTest
fixtures :users, :contexts, :preferences, :todos, :projects
@@valid_postdata = "<todo><description>this will succeed</description><context_id type='integer'>10</context_id><project_id type='integer'>4</project_id></todo>"
def setup
assert_test_environment_ok
@user = users(:admin_user)
@password = 'abracadabra'
end
def test_get_tickler_succeeds
authenticated_get_xml "/tickler", @user.login, @password, {}
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
assert_response 200
end
@ -21,18 +17,18 @@ class TodoXmlApiTest < ActionController::IntegrationTest
get '/tickler.xml', {}, {}
assert_response 401
get "/tickler", {}, {'AUTHORIZATION' => "Basic " + Base64.encode64("wrong:wrong"),'ACCEPT' => 'application/xml'}
get "/tickler.xml", {}, {'HTT_AUTHORIZATION' => "Basic " + Base64.encode64("wrong:wrong"),'ACCEPT' => 'application/xml'}
assert_response 401
end
def test_get_tickler_returns_all_deferred_and_pending_todos
number = @user.todos.deferred.count + @user.todos.pending.count
authenticated_get_xml "/tickler", @user.login, @password, {}
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
assert_tag :tag => "todos", :children => { :count => number }
end
def test_get_tickler_omits_user_id
authenticated_get_xml "/tickler", @user.login, @password, {}
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
assert_no_tag :tag => "user_id"
end
@ -225,7 +221,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
assert_not_nil todo
assert_not_nil todo.project
assert_equal projects(:timemachine).name, todo.project.name
assert 1, @user.projects.all(:conditions => ["projects.name = ?", projects(:timemachine).name]).count # no duplication of project
assert_equal 1, @user.projects.where("projects.name" => projects(:timemachine).name).count # no duplication of project
end
def test_post_create_todo_with_wrong_project_and_context_id
@ -235,7 +231,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
<context_id type='integer'>-16</context_id>
<project_id type='integer'>-11</project_id>
</todo>"
assert_response 422
assert_response 409
assert_xml_select 'errors' do
assert_select 'error', 2
end
@ -249,7 +245,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
private
def authenticated_post_xml_to_todo_create(postdata = @@valid_postdata, user = @user.login, password = @password)
authenticated_post_xml "/todos", user, password, postdata
authenticated_post_xml "/todos.xml", user, password, postdata
end
end