2023-05-12 11:11:48 +02:00
|
|
|
require 'swagger_helper'
|
|
|
|
|
2023-05-12 13:01:12 +02:00
|
|
|
describe 'User' do
|
2023-05-12 11:11:48 +02: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'] }
|
2023-05-12 13:01:12 +02:00
|
|
|
let(:other_user1) { create(:user) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:other_user2) { create(:user) }
|
2023-05-12 11:11:48 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
tags 'User', 'Financial Transaction'
|
|
|
|
produces 'application/json'
|
2023-05-12 13:01:12 +02:00
|
|
|
let(:user) { create(:user, :ordergroup) }
|
2023-05-12 11:11:48 +02:00
|
|
|
let(:api_scopes) { ['finance:user'] }
|
|
|
|
FinancialTransactionClass.create(name: 'TestTransaction')
|
|
|
|
|
|
|
|
response 200, 'success' do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
|
|
|
financial_overview: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
account_balance: {
|
|
|
|
type: :number,
|
|
|
|
description: 'booked accout balance of ordergroup'
|
|
|
|
},
|
|
|
|
available_funds: {
|
|
|
|
type: :number,
|
|
|
|
description: 'fund available to order articles'
|
|
|
|
},
|
|
|
|
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]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
required: %w[account_balance available_funds financial_transaction_class_sums]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
|
|
|
|
it_handles_invalid_token_and_scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|