2022-11-21 12:49:53 +01:00
|
|
|
require 'swagger_helper'
|
|
|
|
|
2022-11-21 15:59:20 +01:00
|
|
|
describe 'User', type: :request do
|
2022-11-21 12:49:53 +01:00
|
|
|
include ApiHelper
|
|
|
|
|
|
|
|
path '/user' do
|
|
|
|
get 'info about the currently logged-in user' do
|
|
|
|
tags 'User'
|
|
|
|
produces 'application/json'
|
|
|
|
let(:api_scopes) { ['user:read'] }
|
|
|
|
let(:other_user1) { create :user }
|
|
|
|
let(:user) { create :user }
|
|
|
|
let(:other_user2) { create :user }
|
|
|
|
|
|
|
|
response '200', 'success' do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
|
|
|
user: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: :string,
|
|
|
|
description: 'full name'
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
type: :string,
|
|
|
|
description: 'email address'
|
|
|
|
},
|
|
|
|
locale: {
|
|
|
|
type: :string,
|
|
|
|
description: 'language code'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
required: %w[id name email]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data['user']['id']).to eq(user.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_handles_invalid_token_and_scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/user/financial_overview' do
|
|
|
|
get 'financial summary about the currently logged-in user' do
|
2022-12-12 12:28:06 +01:00
|
|
|
tags 'User', 'Financial Transaction'
|
2022-11-21 12:49:53 +01:00
|
|
|
produces 'application/json'
|
2022-12-01 17:57:02 +01:00
|
|
|
let(:user) { create :user, :ordergroup }
|
|
|
|
FinancialTransactionClass.create(name: 'TestTransaction')
|
2022-11-21 12:49:53 +01:00
|
|
|
|
|
|
|
response 200, 'success' do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
2022-12-01 17:57:02 +01:00
|
|
|
financial_overview: {
|
2022-11-21 12:49:53 +01:00
|
|
|
type: :object,
|
|
|
|
properties: {
|
2022-12-01 17:57:02 +01:00
|
|
|
|
|
|
|
account_balance: {
|
|
|
|
type: :number,
|
|
|
|
description: 'booked accout balance of ordergroup'
|
2022-11-21 12:49:53 +01:00
|
|
|
},
|
2022-12-01 17:57:02 +01:00
|
|
|
available_funds: {
|
2022-11-21 12:49:53 +01:00
|
|
|
type: :number,
|
2022-12-01 17:57:02 +01:00
|
|
|
description: 'fund available to order articles'
|
2022-11-21 12:49:53 +01:00
|
|
|
},
|
2022-12-01 17:57:02 +01:00
|
|
|
financial_transaction_class_sums: {
|
|
|
|
type: :array,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
description: 'id of the financial transaction class'
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: :string,
|
|
|
|
description: 'name of the financial transaction class'
|
|
|
|
},
|
|
|
|
amount: {
|
|
|
|
type: :number,
|
|
|
|
description: 'sum of the amounts belonging to the financial transaction class'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
required: %w[id name amount]
|
|
|
|
}
|
2022-11-21 12:49:53 +01:00
|
|
|
},
|
|
|
|
required: %w[account_balance available_funds financial_transaction_class_sums]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:api_scopes) { ['finance:user'] }
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
|
|
|
|
it_handles_invalid_token_and_scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|