mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
re-adding removed tests - all green
This commit is contained in:
parent
5f5a2045b5
commit
b27b817ec5
3 changed files with 32 additions and 1 deletions
|
|
@ -50,6 +50,11 @@ class ContextXmlApiTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fails_with_401_if_not_authorized_user
|
||||||
|
authenticated_post_xml_to_context_create @@valid_postdata, 'nobody', 'nohow'
|
||||||
|
assert_response 401
|
||||||
|
end
|
||||||
|
|
||||||
def test_creates_new_context
|
def test_creates_new_context
|
||||||
assert_difference 'Context.count' do
|
assert_difference 'Context.count' do
|
||||||
authenticated_post_xml_to_context_create
|
authenticated_post_xml_to_context_create
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,11 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
||||||
assert_equal @@project_name, @controller.params[:request][:project][:name]
|
assert_equal @@project_name, @controller.params[:request][:project][:name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fails_with_401_if_not_authorized_user
|
||||||
|
authenticated_post_xml_to_project_create @@valid_postdata, 'nobody', 'nohow'
|
||||||
|
assert_response 401
|
||||||
|
end
|
||||||
|
|
||||||
def test_fails_with_too_long_name
|
def test_fails_with_too_long_name
|
||||||
invalid_with_long_name_postdata = "<request><project><name>foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo barfoobarfoobarfoobarfoobarfoobarfoobar</name></project></request>"
|
invalid_with_long_name_postdata = "<request><project><name>foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo barfoobarfoobarfoobarfoobarfoobarfoobar</name></project></request>"
|
||||||
authenticated_post_xml_to_project_create invalid_with_long_name_postdata
|
authenticated_post_xml_to_project_create invalid_with_long_name_postdata
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||||
require 'todos_controller'
|
require 'todos_controller'
|
||||||
|
|
||||||
class TodoXmlApiTest < ActionController::IntegrationTest
|
class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
fixtures :users, :contexts, :preferences, :todos
|
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
|
def setup
|
||||||
assert_test_environment_ok
|
assert_test_environment_ok
|
||||||
|
|
@ -34,6 +36,20 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
assert_no_tag :tag => "user_id"
|
assert_no_tag :tag => "user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_todo_via_xml_show_from
|
||||||
|
old_count = @user.todos.count
|
||||||
|
authenticated_post_xml_to_todo_create "
|
||||||
|
<todo>
|
||||||
|
<description>Call Warren Buffet to find out how much he makes per day</description>
|
||||||
|
<project_id>#{projects(:attendrailsconf).id}</project_id>
|
||||||
|
<context_id>#{contexts(:office_otheruser).id}</context_id>
|
||||||
|
<show-from type=\"datetime\">#{1.week.from_now.xmlschema}</show-from>
|
||||||
|
</todo>"
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_equal @user.todos.count, old_count + 1
|
||||||
|
end
|
||||||
|
|
||||||
def test_post_create_todo_with_wrong_project_and_context_id
|
def test_post_create_todo_with_wrong_project_and_context_id
|
||||||
authenticated_post_xml_to_todo_create "<todo><description>this will fail</description><context_id type='integer'>-16</context_id><project_id type='integer'>-11</project_id></todo>"
|
authenticated_post_xml_to_todo_create "<todo><description>this will fail</description><context_id type='integer'>-16</context_id><project_id type='integer'>-11</project_id></todo>"
|
||||||
assert_response 422
|
assert_response 422
|
||||||
|
|
@ -42,6 +58,11 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fails_with_401_if_not_authorized_user
|
||||||
|
authenticated_post_xml_to_todo_create '', 'nobody', 'nohow'
|
||||||
|
assert_response 401
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticated_post_xml_to_todo_create(postdata = @@valid_postdata, user = users(:other_user).login, password = 'sesame')
|
def authenticated_post_xml_to_todo_create(postdata = @@valid_postdata, user = users(:other_user).login, password = 'sesame')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue