Sha256: 7202470e9ce0a9dc8b715af9a436e9ed73ce159c754f2e4c038c17d29b41eef8

Contents?: true

Size: 1.42 KB

Versions: 16

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

module Workarea
  module Api
    module Storefront
      class AccountsIntegrationTest < IntegrationTest
        include AuthenticationTest

        def test_show
          set_current_user(create_user(first_name: 'Ben', last_name: 'Crouse'))
          get storefront_api.account_path

          results = JSON.parse(response.body)
          assert_equal('Ben', results['first_name'])
          assert_equal('Crouse', results['last_name'])
        end

        def test_create
          assert_difference 'User.count', 1 do
            post storefront_api.account_path,
              params: { email: 'bcrouse@weblinc.com', password: 'aP@ssw0rd!' }
          end

          assert(response.ok?)
          results = JSON.parse(response.body)

          assert_equal('bcrouse@weblinc.com', results['account']['email'])
          assert(results['authentication_token'].present?)
        end

        def test_update
          user = create_user(first_name: 'Ben', last_name: 'Crouse')
          set_current_user(user)

          put storefront_api.account_path,
            params: { first_name: 'Bob', last_name: 'Clams' }

          results = JSON.parse(response.body)
          assert_equal('Bob', results['first_name'])
          assert_equal('Clams', results['last_name'])

          user.reload
          assert_equal('Bob', user.first_name)
          assert_equal('Clams', user.last_name)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
workarea-api-4.5.6 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.6 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.5.5 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.5 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.5.4 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.4 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.5.3 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.3 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.5.2 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.2 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.5.0 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.5.0 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.4.7 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.4.7 test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-4.4.6 storefront/test/integration/workarea/api/storefront/accounts_integration_test.rb
workarea-api-storefront-4.4.6 test/integration/workarea/api/storefront/accounts_integration_test.rb