scinote-web/spec/support/api_helper.rb

18 lines
387 B
Ruby
Raw Normal View History

2017-08-30 00:49:07 +08:00
module ApiHelper
def generate_token(user_id)
Api::CoreJwt.encode(user_id: user_id)
end
def generate_expired_token(user_id)
Api::CoreJwt.encode({ user_id: user_id }, (Time.now.to_i - 300))
end
def decode_token(token)
Api::CoreJwt.decode(token)['user_id'].to_i
end
def json
ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(response.body))
2017-08-30 00:49:07 +08:00
end
end