|
9 | 9 |
|
10 | 10 | class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
11 | 11 | describe DeviseTokenAuth::RegistrationsController do
|
| 12 | + describe 'Validate non-empty body' do |
| 13 | + before do |
| 14 | + # need to post empty data |
| 15 | + post '/auth', {} |
| 16 | + |
| 17 | + @resource = assigns(:resource) |
| 18 | + @data = JSON.parse(response.body) |
| 19 | + end |
| 20 | + |
| 21 | + test 'request should fail' do |
| 22 | + assert_equal 422, response.status |
| 23 | + end |
| 24 | + |
| 25 | + test 'returns error message' do |
| 26 | + assert_not_empty @data['errors'] |
| 27 | + end |
| 28 | + |
| 29 | + test 'return error status' do |
| 30 | + assert_equal 'error', @data['status'] |
| 31 | + end |
| 32 | + |
| 33 | + test 'user should not have been saved' do |
| 34 | + assert @resource.nil? |
| 35 | + end |
| 36 | + end |
| 37 | + |
12 | 38 | describe "Successful registration" do
|
13 | 39 | before do
|
14 | 40 | @mails_sent = ActionMailer::Base.deliveries.count
|
@@ -416,6 +442,33 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
416 | 442 | end
|
417 | 443 | end
|
418 | 444 |
|
| 445 | + describe 'validate non-empty body' do |
| 446 | + before do |
| 447 | + # get the email so we can check it wasn't updated |
| 448 | + @email = @existing_user.email |
| 449 | + put '/auth', {}, @auth_headers |
| 450 | + |
| 451 | + @data = JSON.parse(response.body) |
| 452 | + @existing_user.reload |
| 453 | + end |
| 454 | + |
| 455 | + test 'request should fail' do |
| 456 | + assert_equal 422, response.status |
| 457 | + end |
| 458 | + |
| 459 | + test 'returns error message' do |
| 460 | + assert_not_empty @data['errors'] |
| 461 | + end |
| 462 | + |
| 463 | + test 'return error status' do |
| 464 | + assert_equal 'error', @data['status'] |
| 465 | + end |
| 466 | + |
| 467 | + test 'user should not have been saved' do |
| 468 | + assert_equal @email, @existing_user.email |
| 469 | + end |
| 470 | + end |
| 471 | + |
419 | 472 | describe "error" do
|
420 | 473 | before do
|
421 | 474 | # test invalid update param
|
|
0 commit comments