New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Currency#enabled (aka #visible, closes #818) #855
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec/factories/currencies.rb
Outdated
@@ -66,5 +66,15 @@ | |||
transaction_url_template: 'https://bithomp.com/explorer/#{address}', | |||
deposit_confirmations: 1 | |||
end | |||
|
|||
trait :invisible do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh This is not good and should be removed. We seed currencies and markets before every example so it is not possible to use factories for currencies or markets as usually. Please use before
& after
callback for the spec.
let(:account) { member.accounts.with_currency(currency).first } | ||
|
||
before { account.update!(balance: 1.2) } | ||
|
||
after { Currency.destroy(invisible_currency) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh This should be removed too.
@@ -107,6 +129,12 @@ def request | |||
expect(account.reload.balance).to eq(1.2 - amount) | |||
expect(account.reload.locked).to eq amount | |||
end | |||
|
|||
it 'validates currency visibility' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh Better to use validates visibility of currency
@@ -84,10 +97,19 @@ def request | |||
amount: amount, | |||
rid: Faker::Bitcoin.address } | |||
end | |||
let :bad_data do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh Use context 'invisible currency'
and before
after
changing visibility instead of producing lot of magic lets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context 'invisible currency' do
before { currency.update!(visible: false) }
after { currency.update!(visible: true) }
it '...' do
# ...
end
end
spec/api/api_v2/solvency_spec.rb
Outdated
@@ -19,6 +24,13 @@ | |||
expect(response.code).to eq '422' | |||
end | |||
|
|||
it 'should validate currency visibility' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh Don't use should
, just it 'validates visibility of currency'
.
@yivo rebased on master. |
@ashanaakh Please, change base to 1-8-stable. |
@yivo Done 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
before { Currency.first.update!(visible: false) } | ||
after { Currency.first.update!(visible: true) } | ||
it 'validates visibility of currency' do | ||
params = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh In this call we don't need amount and rid since is returns collection.
params = { | ||
uid: member.authentications.first.uid, | ||
currency: Currency.first.code, | ||
amount: 0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh No need for field amount for this call.
app/models/currency.rb
Outdated
@@ -106,8 +105,8 @@ def as_json(*) | |||
end | |||
|
|||
def summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashanaakh This is used in admin panel on dashboard page. Admin should see all accounts.
@ashanaakh Yesterday we discussed this with QA. We found some bugs with address generation. I will submit them later. Also we found that name |
@@ -12,7 +12,7 @@ class Deposits < Grape::API | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.