Sha256: 40efb9b2dea21dd1b3ae3acbf66d28b14338f05c77c753012f15c7f651dedeb1

Contents?: true

Size: 1.63 KB

Versions: 12

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

class Custom::RegistrationsControllerTest < ActionDispatch::IntegrationTest

  describe Custom::RegistrationsController do

    setup do
      @create_params = {
        email: Faker::Internet.email,
        password: "secret123",
        password_confirmation: "secret123",
        confirm_success_url: Faker::Internet.url,
        unpermitted_param: '(x_x)'
      }

      @existing_user = nice_users(:confirmed_email_user)
      @auth_headers  = @existing_user.create_new_auth_token
      @client_id     = @auth_headers['client']

      # ensure request is not treated as batch request
      age_token(@existing_user, @client_id)
    end

    test "yield resource to block on create success" do
      post '/nice_user_auth', @create_params
      assert @controller.create_block_called?, "create failed to yield resource to provided block"
    end

    test "yield resource to block on create success with custom json" do
      post '/nice_user_auth', @create_params

      @data = JSON.parse(response.body)

      assert @controller.create_block_called?, "create failed to yield resource to provided block"
      assert_equal @data["custom"], "foo"
    end

    test "yield resource to block on update success" do
      put '/nice_user_auth', {
        nickname: "Ol' Sunshine-face",
      }, @auth_headers
      assert @controller.update_block_called?, "update failed to yield resource to provided block"
    end

    test "yield resource to block on destroy success" do
      delete '/nice_user_auth', @auth_headers
      assert @controller.destroy_block_called?, "destroy failed to yield resource to provided block"
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
devise_token_auth-0.1.42 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.41 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.40 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.39 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.38 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.37 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.37.beta4 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.37.beta3 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.37.beta2 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.37.beta1 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.36 test/controllers/custom/custom_registrations_controller_test.rb
devise_token_auth-0.1.35 test/controllers/custom/custom_registrations_controller_test.rb