@@ -71,13 +71,22 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
71 | context "POST /users" do |
|
71 | context "POST /users" do | |
72 | context "with valid parameters" do |
|
72 | context "with valid parameters" do | |
73 | setup do |
|
73 | setup do | |
74 | @parameters = {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net', :password => 'secret', :mail_notification => 'only_assigned'}} |
|
74 | @parameters = { | |
|
75 | :user => { | |||
|
76 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |||
|
77 | :mail => 'foo@example.net', :password => 'secret', | |||
|
78 | :mail_notification => 'only_assigned' | |||
|
79 | } | |||
|
80 | } | |||
75 | end |
|
81 | end | |
76 |
|
82 | |||
77 | context ".xml" do |
|
83 | context ".xml" do | |
78 | should_allow_api_authentication(:post, |
|
84 | should_allow_api_authentication(:post, | |
79 | '/users.xml', |
|
85 | '/users.xml', | |
80 | {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net', :password => 'secret'}}, |
|
86 | {:user => { | |
|
87 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |||
|
88 | :mail => 'foo@example.net', :password => 'secret' | |||
|
89 | }}, | |||
81 | {:success_code => :created}) |
|
90 | {:success_code => :created}) | |
82 |
|
91 | |||
83 | should "create a user with the attributes" do |
|
92 | should "create a user with the attributes" do | |
@@ -103,7 +112,10 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
103 | context ".json" do |
|
112 | context ".json" do | |
104 | should_allow_api_authentication(:post, |
|
113 | should_allow_api_authentication(:post, | |
105 | '/users.json', |
|
114 | '/users.json', | |
106 | {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net'}}, |
|
115 | {:user => { | |
|
116 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |||
|
117 | :mail => 'foo@example.net' | |||
|
118 | }}, | |||
107 | {:success_code => :created}) |
|
119 | {:success_code => :created}) | |
108 |
|
120 | |||
109 | should "create a user with the attributes" do |
|
121 | should "create a user with the attributes" do | |
@@ -141,7 +153,10 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
141 |
|
153 | |||
142 | assert_response :unprocessable_entity |
|
154 | assert_response :unprocessable_entity | |
143 | assert_equal 'application/xml', @response.content_type |
|
155 | assert_equal 'application/xml', @response.content_type | |
144 | assert_tag 'errors', :child => {:tag => 'error', :content => "First name can't be blank"} |
|
156 | assert_tag 'errors', :child => { | |
|
157 | :tag => 'error', | |||
|
158 | :content => "First name can't be blank" | |||
|
159 | } | |||
145 | end |
|
160 | end | |
146 | end |
|
161 | end | |
147 |
|
162 | |||
@@ -165,13 +180,21 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
165 | context "PUT /users/2" do |
|
180 | context "PUT /users/2" do | |
166 | context "with valid parameters" do |
|
181 | context "with valid parameters" do | |
167 | setup do |
|
182 | setup do | |
168 | @parameters = {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}} |
|
183 | @parameters = { | |
|
184 | :user => { | |||
|
185 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |||
|
186 | :mail => 'jsmith@somenet.foo' | |||
|
187 | } | |||
|
188 | } | |||
169 | end |
|
189 | end | |
170 |
|
190 | |||
171 | context ".xml" do |
|
191 | context ".xml" do | |
172 | should_allow_api_authentication(:put, |
|
192 | should_allow_api_authentication(:put, | |
173 | '/users/2.xml', |
|
193 | '/users/2.xml', | |
174 | {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}}, |
|
194 | {:user => { | |
|
195 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |||
|
196 | :mail => 'jsmith@somenet.foo' | |||
|
197 | }}, | |||
175 | {:success_code => :ok}) |
|
198 | {:success_code => :ok}) | |
176 |
|
199 | |||
177 | should "update user with the attributes" do |
|
200 | should "update user with the attributes" do | |
@@ -193,7 +216,10 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
193 | context ".json" do |
|
216 | context ".json" do | |
194 | should_allow_api_authentication(:put, |
|
217 | should_allow_api_authentication(:put, | |
195 | '/users/2.json', |
|
218 | '/users/2.json', | |
196 | {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}}, |
|
219 | {:user => { | |
|
220 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |||
|
221 | :mail => 'jsmith@somenet.foo' | |||
|
222 | }}, | |||
197 | {:success_code => :ok}) |
|
223 | {:success_code => :ok}) | |
198 |
|
224 | |||
199 | should "update user with the attributes" do |
|
225 | should "update user with the attributes" do | |
@@ -215,7 +241,12 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
215 |
|
241 | |||
216 | context "with invalid parameters" do |
|
242 | context "with invalid parameters" do | |
217 | setup do |
|
243 | setup do | |
218 | @parameters = {:user => {:login => 'jsmith', :firstname => '', :lastname => 'Lastname', :mail => 'foo'}} |
|
244 | @parameters = { | |
|
245 | :user => { | |||
|
246 | :login => 'jsmith', :firstname => '', :lastname => 'Lastname', | |||
|
247 | :mail => 'foo' | |||
|
248 | } | |||
|
249 | } | |||
219 | end |
|
250 | end | |
220 |
|
251 | |||
221 | context ".xml" do |
|
252 | context ".xml" do | |
@@ -226,7 +257,10 class ApiTest::UsersTest < ActionController::IntegrationTest | |||||
226 |
|
257 | |||
227 | assert_response :unprocessable_entity |
|
258 | assert_response :unprocessable_entity | |
228 | assert_equal 'application/xml', @response.content_type |
|
259 | assert_equal 'application/xml', @response.content_type | |
229 | assert_tag 'errors', :child => {:tag => 'error', :content => "First name can't be blank"} |
|
260 | assert_tag 'errors', :child => { | |
|
261 | :tag => 'error', | |||
|
262 | :content => "First name can't be blank" | |||
|
263 | } | |||
230 | end |
|
264 | end | |
231 | end |
|
265 | end | |
232 |
|
266 |
General Comments 0
You need to be logged in to leave comments.
Login now