discourse/spec/integration/user_api_keys_spec.rb
Daniel Waterworth e219588142 DEV: Prefabrication (test optimization) (#7414)
* Introduced fab!, a helper that creates database state for a group

It's almost identical to let_it_be, except:

 1. It creates a new object for each test by default,
 2. You can disable it using PREFABRICATION=0
2019-05-07 13:12:20 +10:00

19 lines
446 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe 'user api keys integration' do
fab!(:user_api_key) { Fabricate(:readonly_user_api_key) }
it 'updates last used time on use' do
user_api_key.update_columns(last_used_at: 7.days.ago)
freeze_time
get '/session/current.json', headers: {
HTTP_USER_API_KEY: user_api_key.key,
}
expect(user_api_key.reload.last_used_at).to eq_time(Time.zone.now)
end
end