Commit 41793608 by ivan Lan

Fix POST /orders

parent 17f8ea6e
...@@ -211,7 +211,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta ...@@ -211,7 +211,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
meta: { type: :object }, meta: { type: :object },
incr_snapshot_ids: { type: :array }, incr_snapshot_ids: { type: :array },
}, },
snapshots: { snapshot: {
type: :object, properties: { type: :object, properties: {
shotengai_series_id: { type: :integer }, shotengai_series_id: { type: :integer },
count: { type: :integer }, count: { type: :integer },
...@@ -229,7 +229,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta ...@@ -229,7 +229,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
user_remark: 'user remark ...', user_remark: 'user remark ...',
incr_snapshot_ids: [ @snapshot_2.id ], incr_snapshot_ids: [ @snapshot_2.id ],
}, },
snapshots: { snapshot: {
shotengai_series_id: @series_1.id, shotengai_series_id: @series_1.id,
count: 10, count: 10,
} }
......
...@@ -38,15 +38,16 @@ module Shotengai ...@@ -38,15 +38,16 @@ module Shotengai
end end
end end
def buy_it_immediately snapshots_param, order_params def buy_it_immediately snapshot_param, order_params
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
order = self.#{collection_name}.create!(order_params) order = self.#{collection_name}.create!(order_params)
snapshots_param && Shotengai::Series.find(snapshots_param[:shotengai_series_id]).snapshots.create!( snapshot_param && Shotengai::Series.find(snapshot_param[:shotengai_series_id]).snapshots.create!(
snapshots_param.merge({ snapshot_param.merge({
shotengai_order: order shotengai_order: order
}) })
) )
order order
end end
end end
") ")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment