@@ -1,16 +1,16 | |||
|
1 | 1 | # Redmine - project management software |
|
2 |
# Copyright (C) 2006-201 |
|
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -19,11 +19,11 require File.expand_path('../../../test_helper', __FILE__) | |||
|
19 | 19 | |
|
20 | 20 | class ApiTest::TimeEntriesTest < ActionController::IntegrationTest |
|
21 | 21 | fixtures :all |
|
22 | ||
|
22 | ||
|
23 | 23 | def setup |
|
24 | 24 | Setting.rest_api_enabled = '1' |
|
25 | 25 | end |
|
26 | ||
|
26 | ||
|
27 | 27 | context "GET /time_entries.xml" do |
|
28 | 28 | should "return time entries" do |
|
29 | 29 | get '/time_entries.xml', {}, :authorization => credentials('jsmith') |
@@ -32,7 +32,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
32 | 32 | assert_tag :tag => 'time_entries', |
|
33 | 33 | :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}} |
|
34 | 34 | end |
|
35 | ||
|
35 | ||
|
36 | 36 | context "with limit" do |
|
37 | 37 | should "return limited results" do |
|
38 | 38 | get '/time_entries.xml?limit=2', {}, :authorization => credentials('jsmith') |
@@ -43,7 +43,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
43 | 43 | end |
|
44 | 44 | end |
|
45 | 45 | end |
|
46 | ||
|
46 | ||
|
47 | 47 | context "GET /time_entries/2.xml" do |
|
48 | 48 | should "return requested time entry" do |
|
49 | 49 | get '/time_entries/2.xml', {}, :authorization => credentials('jsmith') |
@@ -53,7 +53,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
53 | 53 | :child => {:tag => 'id', :content => '2'} |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | ||
|
56 | ||
|
57 | 57 | context "POST /time_entries.xml" do |
|
58 | 58 | context "with issue_id" do |
|
59 | 59 | should "return create time entry" do |
@@ -62,7 +62,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
62 | 62 | end |
|
63 | 63 | assert_response :created |
|
64 | 64 | assert_equal 'application/xml', @response.content_type |
|
65 | ||
|
65 | ||
|
66 | 66 | entry = TimeEntry.first(:order => 'id DESC') |
|
67 | 67 | assert_equal 'jsmith', entry.user.login |
|
68 | 68 | assert_equal Issue.find(1), entry.issue |
@@ -72,7 +72,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
72 | 72 | assert_equal TimeEntryActivity.find(11), entry.activity |
|
73 | 73 | end |
|
74 | 74 | end |
|
75 | ||
|
75 | ||
|
76 | 76 | context "with project_id" do |
|
77 | 77 | should "return create time entry" do |
|
78 | 78 | assert_difference 'TimeEntry.count' do |
@@ -80,7 +80,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
80 | 80 | end |
|
81 | 81 | assert_response :created |
|
82 | 82 | assert_equal 'application/xml', @response.content_type |
|
83 | ||
|
83 | ||
|
84 | 84 | entry = TimeEntry.first(:order => 'id DESC') |
|
85 | 85 | assert_equal 'jsmith', entry.user.login |
|
86 | 86 | assert_nil entry.issue |
@@ -90,7 +90,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
90 | 90 | assert_equal TimeEntryActivity.find(11), entry.activity |
|
91 | 91 | end |
|
92 | 92 | end |
|
93 | ||
|
93 | ||
|
94 | 94 | context "with invalid parameters" do |
|
95 | 95 | should "return errors" do |
|
96 | 96 | assert_no_difference 'TimeEntry.count' do |
@@ -103,7 +103,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
103 | 103 | end |
|
104 | 104 | end |
|
105 | 105 | end |
|
106 | ||
|
106 | ||
|
107 | 107 | context "PUT /time_entries/2.xml" do |
|
108 | 108 | context "with valid parameters" do |
|
109 | 109 | should "update time entry" do |
@@ -127,7 +127,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
127 | 127 | end |
|
128 | 128 | end |
|
129 | 129 | end |
|
130 | ||
|
130 | ||
|
131 | 131 | context "DELETE /time_entries/2.xml" do |
|
132 | 132 | should "destroy time entry" do |
|
133 | 133 | assert_difference 'TimeEntry.count', -1 do |
@@ -137,7 +137,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
137 | 137 | assert_nil TimeEntry.find_by_id(2) |
|
138 | 138 | end |
|
139 | 139 | end |
|
140 | ||
|
140 | ||
|
141 | 141 | def credentials(user, password=nil) |
|
142 | 142 | ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) |
|
143 | 143 | end |
General Comments 0
You need to be logged in to leave comments.
Login now