Sha256: 504183f76bffb5c788b2b728cd562e5944ab73851b00d2b5d905781f08d8e728

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

require 'spec_helper'

RSpec.describe 'Request integration', type: :request do
  let(:token) { Visa::Token.create tokenable: User.create }

  it 'accepts valid tokens' do
    get '/', access_token: "#{token.client_id}#{token.secret}"

    expect(response.status).to eq(200)
  end

  it 'returns 401 when the token is invalid' do
    get '/', access_token: "#{token.client_id}this-is-invalid"

    expect(response.status).to eq(401)
  end

  it 'returns 401 when the token has not been used in two weeks' do
    token.update_column :last_requested_at, 15.days.ago

    get '/', access_token: "#{token.client_id}#{token.secret}"

    expect(response.status).to eq(401)
  end

  it 'updates the last_requested_at column' do
    get '/', access_token: "#{token.client_id}#{token.secret}"

    token.reload

    expect(token.last_requested_at).to_not be_nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
visa-0.0.2 spec/requests/requests_spec.rb
visa-0.0.1 spec/requests/requests_spec.rb