Skip to content

Commit 9fa0442

Browse files
authored
chore: merge master into beta
2 parents d58a2e0 + 1594807 commit 9fa0442

File tree

14 files changed

+105
-26
lines changed

14 files changed

+105
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# NOTICE: Handles code coverage reporting to Code Climate
2323
before_install:
2424
- gem install bundler -v '1.17.3'
25-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25+
- curl -L $CC_TEST_REPORTER_URL > ./cc-test-reporter
2626
- chmod +x ./cc-test-reporter
2727
after_script:
2828
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## [5.4.3](https://github.com/ForestAdmin/forest-rails/compare/v5.4.2...v5.4.3) (2021-01-28)
2+
3+
4+
### Bug Fixes
5+
6+
* use update instead of update_attribute to ensure rails 6.1 compatibility ([#417](https://github.com/ForestAdmin/forest-rails/issues/417)) ([41f9afb](https://github.com/ForestAdmin/forest-rails/commit/41f9afb8b2e45b2c26147f5f7bfe1941a38b3fd7))
7+
8+
## [5.4.2](https://github.com/ForestAdmin/forest-rails/compare/v5.4.1...v5.4.2) (2021-01-27)
9+
10+
11+
### Bug Fixes
12+
13+
* **stripe:** fix serialization issues on invoices ([#412](https://github.com/ForestAdmin/forest-rails/issues/412)) ([d9595bf](https://github.com/ForestAdmin/forest-rails/commit/d9595bfc79a46a9471f87154a023e35c4fd7d423))
14+
15+
## [5.4.1](https://github.com/ForestAdmin/forest-rails/compare/v5.4.0...v5.4.1) (2021-01-21)
16+
17+
18+
### Bug Fixes
19+
20+
* **smart-action-hook:** value injected to an enum field of type is now correctly handled ([#414](https://github.com/ForestAdmin/forest-rails/issues/414)) ([ef90105](https://github.com/ForestAdmin/forest-rails/commit/ef90105659f57c4c8531b0c4d576f345bc976b33))
21+
122
# [6.0.0-beta.4](https://github.com/ForestAdmin/forest-rails/compare/v6.0.0-beta.3...v6.0.0-beta.4) (2021-01-15)
223

324

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This project has been designed with scalability in mind to fit requirements from
3131
## How it works
3232

3333
<p align="center" style="margin: 60px 0">
34-
<img width="100%" src="https://www.forestadmin.com/public/img/illustrations-dev/schema-1.png" alt="Howitworks">
34+
<img width="100%" src="https://www.forestadmin.com/public/img/rails/schemas/schema-1.png" alt="Howitworks">
3535
</p>
3636

3737
Forest Admin consists of two components:

app/controllers/forest_liana/actions_controller.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,20 @@ def handle_result(result, formatted_fields, action)
5555
# Apply result on fields (transform the object back to an array), preserve order.
5656
fields = action.fields.map do |field|
5757
updated_field = result[field[:field]]
58+
5859
# Reset `value` when not present in `enums` (which means `enums` has changed).
59-
if updated_field[:enums].is_a?(Array) && !updated_field[:enums].include?(updated_field[:value])
60-
updated_field[:value] = nil
60+
if updated_field[:enums].is_a?(Array)
61+
# `value` can be an array if the type of fields is `[x]`
62+
if updated_field[:type].is_a?(Array) && updated_field[:value].is_a?(Array) && !(updated_field[:value] - updated_field[:enums]).empty?
63+
updated_field[:value] = nil
64+
end
65+
66+
# `value` can be any other value
67+
if !updated_field[:type].is_a?(Array) && !updated_field[:enums].include?(updated_field[:value])
68+
updated_field[:value] = nil
69+
end
6170
end
71+
6272
updated_field
6373
end
6474

app/serializers/forest_liana/stripe_invoice_serializer.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ class StripeInvoiceSerializer
33
include JSONAPI::Serializer
44

55
attribute :amount_due
6+
attribute :amount_paid
7+
attribute :amount_remaining
8+
attribute :application_fee_amount
69
attribute :attempt_count
710
attribute :attempted
8-
attribute :closed
911
attribute :currency
10-
attribute :date
11-
attribute :forgiven
12+
attribute :due_date
1213
attribute :paid
1314
attribute :period_end
1415
attribute :period_start
16+
attribute :status
1517
attribute :subtotal
1618
attribute :total
17-
attribute :application_fee
1819
attribute :tax
19-
attribute :tax_percent
2020

2121
has_one :customer
2222

app/services/forest_liana/resource_creator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def set_has_many_relationships
5353
end
5454

5555
def has_strong_parameter
56-
Rails::VERSION::MAJOR > 5 || @resource.instance_method(:update_attributes!).arity == 1
56+
Rails::VERSION::MAJOR > 5 || @resource.instance_method(:update!).arity == 1
5757
end
5858
end
5959
end

app/services/forest_liana/resource_updater.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def perform
1414
@record = @resource.find(@params[:id])
1515

1616
if has_strong_parameter
17-
@record.update_attributes(resource_params)
17+
@record.update(resource_params)
1818
else
19-
@record.update_attributes(resource_params, without_protection: true)
19+
@record.update(resource_params, without_protection: true)
2020
end
2121
rescue ActiveRecord::StatementInvalid => exception
2222
# NOTICE: SQL request cannot be executed properly
@@ -33,7 +33,7 @@ def resource_params
3333
end
3434

3535
def has_strong_parameter
36-
Rails::VERSION::MAJOR > 5 || @resource.instance_method(:update_attributes!).arity == 1
36+
Rails::VERSION::MAJOR > 5 || @resource.instance_method(:update!).arity == 1
3737
end
3838
end
3939
end

app/services/forest_liana/stripe_invoice_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def perform
1111
query = {}
1212
@record = ::Stripe::Invoice.retrieve(@params[:invoice_id])
1313

14-
@record.date = Time.at(@record.date).to_datetime
14+
@record.due_date = Time.at(@record.due_date).to_datetime unless @record.due_date.nil?
1515
@record.period_start = Time.at(@record.period_start).to_datetime
1616
@record.period_end = Time.at(@record.period_end).to_datetime
1717
@record.subtotal /= 100.00

app/services/forest_liana/stripe_invoices_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def perform
3232
end
3333

3434
@records = @invoices.data.map do |d|
35-
d.date = Time.at(d.date).to_datetime
35+
d.date = Time.at(d.created).to_datetime
3636
d.period_start = Time.at(d.period_start).to_datetime
3737
d.period_end = Time.at(d.period_end).to_datetime
3838
d.subtotal /= 100.00

app/services/forest_liana/stripe_source_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def perform
1212
customer = resource[field]
1313

1414
@record = ::Stripe::Customer
15-
.retrieve(customer)
15+
.retrieve({ id: customer, expand: ['sources'] })
1616
.sources.retrieve(@params[:objectId])
1717

1818
query = {}

0 commit comments

Comments
 (0)