solidus_api 2.5.2 → 2.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_api might be problematic. Click here for more details.

Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/app/controllers/spree/api/address_books_controller.rb +2 -0
  4. data/app/controllers/spree/api/addresses_controller.rb +2 -0
  5. data/app/controllers/spree/api/base_controller.rb +2 -0
  6. data/app/controllers/spree/api/checkouts_controller.rb +2 -0
  7. data/app/controllers/spree/api/classifications_controller.rb +2 -0
  8. data/app/controllers/spree/api/config_controller.rb +2 -0
  9. data/app/controllers/spree/api/countries_controller.rb +2 -0
  10. data/app/controllers/spree/api/credit_cards_controller.rb +2 -0
  11. data/app/controllers/spree/api/images_controller.rb +2 -0
  12. data/app/controllers/spree/api/inventory_units_controller.rb +2 -0
  13. data/app/controllers/spree/api/line_items_controller.rb +2 -0
  14. data/app/controllers/spree/api/option_types_controller.rb +2 -0
  15. data/app/controllers/spree/api/option_values_controller.rb +2 -0
  16. data/app/controllers/spree/api/orders_controller.rb +2 -0
  17. data/app/controllers/spree/api/payments_controller.rb +3 -1
  18. data/app/controllers/spree/api/product_properties_controller.rb +2 -0
  19. data/app/controllers/spree/api/products_controller.rb +2 -0
  20. data/app/controllers/spree/api/promotions_controller.rb +2 -0
  21. data/app/controllers/spree/api/properties_controller.rb +2 -0
  22. data/app/controllers/spree/api/resource_controller.rb +2 -0
  23. data/app/controllers/spree/api/return_authorizations_controller.rb +2 -0
  24. data/app/controllers/spree/api/shipments_controller.rb +2 -0
  25. data/app/controllers/spree/api/states_controller.rb +4 -2
  26. data/app/controllers/spree/api/stock_items_controller.rb +2 -0
  27. data/app/controllers/spree/api/stock_locations_controller.rb +2 -0
  28. data/app/controllers/spree/api/stock_movements_controller.rb +2 -0
  29. data/app/controllers/spree/api/store_credit_events_controller.rb +2 -0
  30. data/app/controllers/spree/api/stores_controller.rb +2 -0
  31. data/app/controllers/spree/api/taxonomies_controller.rb +2 -0
  32. data/app/controllers/spree/api/taxons_controller.rb +2 -0
  33. data/app/controllers/spree/api/users_controller.rb +2 -0
  34. data/app/controllers/spree/api/variants_controller.rb +2 -0
  35. data/app/controllers/spree/api/zones_controller.rb +2 -0
  36. data/app/helpers/spree/api/api_helpers.rb +6 -4
  37. data/app/models/spree/api_configuration.rb +2 -0
  38. data/app/views/spree/api/address_books/show.json.jbuilder +2 -0
  39. data/app/views/spree/api/addresses/_address.json.jbuilder +2 -0
  40. data/app/views/spree/api/addresses/show.json.jbuilder +2 -0
  41. data/app/views/spree/api/adjustments/_adjustment.json.jbuilder +2 -0
  42. data/app/views/spree/api/config/money.json.jbuilder +2 -0
  43. data/app/views/spree/api/config/show.json.jbuilder +2 -0
  44. data/app/views/spree/api/countries/index.json.jbuilder +2 -0
  45. data/app/views/spree/api/countries/show.json.jbuilder +2 -0
  46. data/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +2 -0
  47. data/app/views/spree/api/credit_cards/index.json.jbuilder +2 -0
  48. data/app/views/spree/api/credit_cards/show.json.jbuilder +2 -0
  49. data/app/views/spree/api/errors/delete_restriction.json.jbuilder +2 -0
  50. data/app/views/spree/api/errors/gateway_error.json.jbuilder +2 -0
  51. data/app/views/spree/api/errors/invalid_api_key.json.jbuilder +2 -0
  52. data/app/views/spree/api/errors/invalid_resource.json.jbuilder +2 -0
  53. data/app/views/spree/api/errors/must_specify_api_key.json.jbuilder +2 -0
  54. data/app/views/spree/api/errors/not_found.json.jbuilder +2 -0
  55. data/app/views/spree/api/errors/unauthorized.json.jbuilder +2 -0
  56. data/app/views/spree/api/images/_image.json.jbuilder +2 -0
  57. data/app/views/spree/api/images/index.json.jbuilder +2 -0
  58. data/app/views/spree/api/images/show.json.jbuilder +2 -0
  59. data/app/views/spree/api/inventory_units/show.json.jbuilder +2 -0
  60. data/app/views/spree/api/line_items/_line_item.json.jbuilder +2 -0
  61. data/app/views/spree/api/line_items/new.json.jbuilder +2 -0
  62. data/app/views/spree/api/line_items/show.json.jbuilder +2 -0
  63. data/app/views/spree/api/option_types/_option_type.json.jbuilder +2 -0
  64. data/app/views/spree/api/option_types/index.json.jbuilder +2 -0
  65. data/app/views/spree/api/option_types/show.json.jbuilder +2 -0
  66. data/app/views/spree/api/option_values/_option_value.json.jbuilder +2 -0
  67. data/app/views/spree/api/option_values/index.json.jbuilder +2 -0
  68. data/app/views/spree/api/option_values/show.json.jbuilder +2 -0
  69. data/app/views/spree/api/orders/_big.json.jbuilder +13 -5
  70. data/app/views/spree/api/orders/_order.json.jbuilder +2 -0
  71. data/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder +2 -0
  72. data/app/views/spree/api/orders/could_not_transition.json.jbuilder +2 -0
  73. data/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder +2 -0
  74. data/app/views/spree/api/orders/index.json.jbuilder +2 -0
  75. data/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder +2 -0
  76. data/app/views/spree/api/orders/mine.json.jbuilder +2 -0
  77. data/app/views/spree/api/orders/show.json.jbuilder +2 -0
  78. data/app/views/spree/api/payments/credit_over_limit.json.jbuilder +2 -0
  79. data/app/views/spree/api/payments/index.json.jbuilder +2 -0
  80. data/app/views/spree/api/payments/new.json.jbuilder +2 -0
  81. data/app/views/spree/api/payments/show.json.jbuilder +2 -0
  82. data/app/views/spree/api/payments/source_views/_check.json.jbuilder +1 -0
  83. data/app/views/spree/api/payments/source_views/_gateway.json.jbuilder +6 -0
  84. data/app/views/spree/api/payments/source_views/_storecredit.json.jbuilder +3 -0
  85. data/app/views/spree/api/payments/update_forbidden.json.jbuilder +2 -0
  86. data/app/views/spree/api/product_properties/index.json.jbuilder +2 -0
  87. data/app/views/spree/api/product_properties/new.json.jbuilder +2 -0
  88. data/app/views/spree/api/product_properties/show.json.jbuilder +2 -0
  89. data/app/views/spree/api/products/_product.json.jbuilder +2 -0
  90. data/app/views/spree/api/products/index.json.jbuilder +2 -0
  91. data/app/views/spree/api/products/new.json.jbuilder +2 -0
  92. data/app/views/spree/api/products/show.json.jbuilder +2 -0
  93. data/app/views/spree/api/promotions/handler.json.jbuilder +2 -0
  94. data/app/views/spree/api/promotions/show.json.jbuilder +2 -0
  95. data/app/views/spree/api/properties/index.json.jbuilder +2 -0
  96. data/app/views/spree/api/properties/new.json.jbuilder +2 -0
  97. data/app/views/spree/api/properties/show.json.jbuilder +2 -0
  98. data/app/views/spree/api/return_authorizations/index.json.jbuilder +2 -0
  99. data/app/views/spree/api/return_authorizations/new.json.jbuilder +2 -0
  100. data/app/views/spree/api/return_authorizations/show.json.jbuilder +2 -0
  101. data/app/views/spree/api/shared/_pagination.json.jbuilder +2 -0
  102. data/app/views/spree/api/shipments/_big.json.jbuilder +8 -4
  103. data/app/views/spree/api/shipments/_small.json.jbuilder +2 -0
  104. data/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder +2 -0
  105. data/app/views/spree/api/shipments/estimated_rates.json.jbuilder +2 -0
  106. data/app/views/spree/api/shipments/mine.json.jbuilder +2 -0
  107. data/app/views/spree/api/shipments/show.json.jbuilder +2 -0
  108. data/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder +2 -0
  109. data/app/views/spree/api/states/index.json.jbuilder +2 -0
  110. data/app/views/spree/api/states/show.json.jbuilder +2 -0
  111. data/app/views/spree/api/stock_items/_stock_item.json.jbuilder +2 -0
  112. data/app/views/spree/api/stock_items/index.json.jbuilder +2 -0
  113. data/app/views/spree/api/stock_items/show.json.jbuilder +2 -0
  114. data/app/views/spree/api/stock_locations/_stock_location.json.jbuilder +2 -0
  115. data/app/views/spree/api/stock_locations/index.json.jbuilder +2 -0
  116. data/app/views/spree/api/stock_locations/show.json.jbuilder +2 -0
  117. data/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder +2 -0
  118. data/app/views/spree/api/stock_movements/index.json.jbuilder +2 -0
  119. data/app/views/spree/api/stock_movements/show.json.jbuilder +2 -0
  120. data/app/views/spree/api/store_credit_events/mine.json.jbuilder +2 -0
  121. data/app/views/spree/api/stores/index.json.jbuilder +2 -0
  122. data/app/views/spree/api/stores/show.json.jbuilder +2 -0
  123. data/app/views/spree/api/taxonomies/_nested.json.jbuilder +2 -0
  124. data/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +2 -0
  125. data/app/views/spree/api/taxonomies/index.json.jbuilder +2 -0
  126. data/app/views/spree/api/taxonomies/jstree.json.jbuilder +2 -0
  127. data/app/views/spree/api/taxonomies/new.json.jbuilder +2 -0
  128. data/app/views/spree/api/taxonomies/show.json.jbuilder +2 -0
  129. data/app/views/spree/api/taxons/_taxon.json.jbuilder +2 -0
  130. data/app/views/spree/api/taxons/_taxons.json.jbuilder +2 -0
  131. data/app/views/spree/api/taxons/index.json.jbuilder +2 -0
  132. data/app/views/spree/api/taxons/jstree.json.jbuilder +2 -0
  133. data/app/views/spree/api/taxons/new.json.jbuilder +2 -0
  134. data/app/views/spree/api/taxons/show.json.jbuilder +2 -0
  135. data/app/views/spree/api/users/_user.json.jbuilder +2 -0
  136. data/app/views/spree/api/users/index.json.jbuilder +2 -0
  137. data/app/views/spree/api/users/new.json.jbuilder +2 -0
  138. data/app/views/spree/api/users/show.json.jbuilder +2 -0
  139. data/app/views/spree/api/variants/_big.json.jbuilder +2 -0
  140. data/app/views/spree/api/variants/_small.json.jbuilder +2 -0
  141. data/app/views/spree/api/variants/index.json.jbuilder +2 -0
  142. data/app/views/spree/api/variants/new.json.jbuilder +2 -0
  143. data/app/views/spree/api/variants/show.json.jbuilder +2 -0
  144. data/app/views/spree/api/zones/_zone.json.jbuilder +2 -0
  145. data/app/views/spree/api/zones/index.json.jbuilder +2 -0
  146. data/app/views/spree/api/zones/show.json.jbuilder +2 -0
  147. data/config/routes.rb +9 -7
  148. data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +2 -0
  149. data/db/migrate/20120411123334_resize_api_key_field.rb +2 -0
  150. data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +2 -0
  151. data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +2 -0
  152. data/lib/solidus_api.rb +2 -0
  153. data/lib/spree/api/engine.rb +2 -0
  154. data/lib/spree/api/responders/rabl_template.rb +2 -0
  155. data/lib/spree/api/responders.rb +2 -0
  156. data/lib/spree/api/testing_support/caching.rb +2 -0
  157. data/lib/spree/api/testing_support/helpers.rb +2 -0
  158. data/lib/spree/api/testing_support/setup.rb +2 -0
  159. data/lib/spree/api.rb +2 -0
  160. data/lib/spree_api.rb +2 -0
  161. data/script/rails +4 -2
  162. data/solidus_api.gemspec +4 -3
  163. data/spec/controllers/spree/api/base_controller_spec.rb +2 -0
  164. data/spec/controllers/spree/api/resource_controller_spec.rb +8 -4
  165. data/spec/features/checkout_spec.rb +2 -0
  166. data/spec/models/spree/legacy_user_spec.rb +2 -0
  167. data/spec/requests/api/address_books_spec.rb +2 -0
  168. data/spec/requests/rabl_cache_spec.rb +2 -0
  169. data/spec/requests/ransackable_attributes_spec.rb +2 -0
  170. data/spec/requests/spree/api/addresses_controller_spec.rb +2 -1
  171. data/spec/requests/spree/api/checkouts_controller_spec.rb +2 -1
  172. data/spec/requests/spree/api/classifications_controller_spec.rb +2 -0
  173. data/spec/requests/spree/api/config_controller_spec.rb +3 -1
  174. data/spec/requests/spree/api/countries_controller_spec.rb +2 -1
  175. data/spec/requests/spree/api/credit_cards_controller_spec.rb +2 -1
  176. data/spec/requests/spree/api/images_controller_spec.rb +2 -1
  177. data/spec/requests/spree/api/inventory_units_controller_spec.rb +2 -0
  178. data/spec/requests/spree/api/line_items_controller_spec.rb +2 -1
  179. data/spec/requests/spree/api/option_types_controller_spec.rb +2 -1
  180. data/spec/requests/spree/api/option_values_controller_spec.rb +3 -2
  181. data/spec/requests/spree/api/orders_controller_spec.rb +17 -13
  182. data/spec/requests/spree/api/payments_controller_spec.rb +2 -0
  183. data/spec/requests/spree/api/product_properties_controller_spec.rb +2 -1
  184. data/spec/requests/spree/api/products_controller_spec.rb +4 -3
  185. data/spec/requests/spree/api/promotion_application_spec.rb +2 -1
  186. data/spec/requests/spree/api/promotions_controller_spec.rb +2 -1
  187. data/spec/requests/spree/api/properties_controller_spec.rb +2 -1
  188. data/spec/requests/spree/api/return_authorizations_controller_spec.rb +2 -1
  189. data/spec/requests/spree/api/shipments_controller_spec.rb +13 -0
  190. data/spec/requests/spree/api/states_controller_spec.rb +2 -1
  191. data/spec/requests/spree/api/stock_items_controller_spec.rb +2 -1
  192. data/spec/requests/spree/api/stock_locations_controller_spec.rb +2 -1
  193. data/spec/requests/spree/api/stock_movements_controller_spec.rb +2 -1
  194. data/spec/requests/spree/api/store_credit_events_controller_spec.rb +2 -0
  195. data/spec/requests/spree/api/stores_controller_spec.rb +9 -6
  196. data/spec/requests/spree/api/taxonomies_controller_spec.rb +2 -1
  197. data/spec/requests/spree/api/taxons_controller_spec.rb +2 -1
  198. data/spec/requests/spree/api/unauthenticated_products_controller_spec.rb +3 -2
  199. data/spec/requests/spree/api/users_controller_spec.rb +2 -1
  200. data/spec/requests/spree/api/variants_controller_spec.rb +2 -2
  201. data/spec/requests/spree/api/zones_controller_spec.rb +2 -1
  202. data/spec/shared_examples/protect_product_actions.rb +2 -0
  203. data/spec/spec_helper.rb +3 -1
  204. data/spec/support/be_paginated_matcher.rb +2 -0
  205. data/spec/support/controller_hacks.rb +2 -0
  206. data/spec/support/database_cleaner.rb +2 -0
  207. data/spec/support/have_attributes_matcher.rb +2 -0
  208. data/spec/test_views/spree/api/widgets/_widget.json.jbuilder +2 -0
  209. data/spec/test_views/spree/api/widgets/index.json.jbuilder +3 -1
  210. data/spec/test_views/spree/api/widgets/new.json.jbuilder +2 -0
  211. data/spec/test_views/spree/api/widgets/show.json.jbuilder +2 -0
  212. metadata +27 -23
@@ -0,0 +1,6 @@
1
+ attrs = [:id, :month, :year, :cc_type, :last_digits, :name]
2
+ if @current_user_roles.include?("admin")
3
+ attrs += [:gateway_customer_profile_id, :gateway_payment_profile_id]
4
+ end
5
+
6
+ json.(payment_source, *attrs)
@@ -0,0 +1,3 @@
1
+ json.(payment_source, :id, :memo, :created_at)
2
+ json.created_by payment_source.created_by.email
3
+ json.category payment_source.category, :id, :name
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:update_forbidden, state: @payment.state, scope: "spree.api.payment"))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.product_properties(@product_properties) do |product_property|
2
4
  json.(product_property, *product_property_attributes)
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*product_property_attributes])
2
4
  json.required_attributes([])
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@product_property, *product_property_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  @product_attributes ||= product_attributes
2
4
  json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do
3
5
  json.(product, *@product_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial! 'spree/api/shared/pagination', pagination: @products
2
4
  json.products(@products) do |product|
3
5
  json.partial!("spree/api/products/product", product: product)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*product_attributes])
2
4
  json.required_attributes(required_fields_for(Spree::Product))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/products/product", product: @product)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.success(@handler.success)
2
4
  json.error(@handler.error)
3
5
  json.successful(@handler.successful?)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@promotion, *promotion_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.properties(@properties) do |property|
2
4
  json.(property, *property_attributes)
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*property_attributes])
2
4
  json.required_attributes([])
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@property, *property_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.return_authorizations(@return_authorizations) do |return_authorization|
2
4
  json.(return_authorization, *return_authorization_attributes)
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*return_authorization_attributes])
2
4
  json.required_attributes(required_fields_for(Spree::ReturnAuthorization))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@return_authorization, *return_authorization_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.count pagination.count
2
4
  json.total_count pagination.total_count
3
5
  json.current_page pagination.current_page
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, shipment] do
2
4
  json.(shipment, *shipment_attributes)
3
5
  json.selected_shipping_rate do
@@ -40,10 +42,12 @@ json.cache! [I18n.locale, shipment] do
40
42
  end
41
43
  json.payments(shipment.order.payments) do |payment|
42
44
  json.(payment, :id, :amount, :display_amount, :state)
43
- json.source do
44
- attrs = [:id]
45
- (attrs << :cc_type) if payment.source.respond_to?(:cc_type)
46
- json.(payment.source, *attrs)
45
+ if payment.source
46
+ json.source do
47
+ attrs = [:id]
48
+ (attrs << :cc_type) if payment.source.respond_to?(:cc_type)
49
+ json.(payment.source, *attrs)
50
+ end
47
51
  end
48
52
  json.payment_method { json.(payment.payment_method, :id, :name) }
49
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, shipment] do
2
4
  json.(shipment, *shipment_attributes)
3
5
  json.order_id(shipment.order.number)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:cannot_ready, scope: "spree.api.shipment"))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.shipping_rates @shipping_rates do |shipping_rate|
2
4
  json.(shipping_rate, :name, :cost, :shipping_method_id, :shipping_method_code)
3
5
  json.display_cost(shipping_rate.display_cost.to_s)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial! 'spree/api/shared/pagination', pagination: @shipments
2
4
  json.shipments(@shipments) do |shipment|
3
5
  json.partial!("spree/api/shipments/big", shipment: shipment)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, @shipment] do
2
4
  json.(@shipment, *shipment_attributes)
3
5
  json.order_id(@shipment.order.number)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(shipping_rate, :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code)
2
4
  json.display_cost(shipping_rate.display_cost.to_s)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.states_required(@country.states_required) if @country
2
4
  json.states(@states) { |state| json.(state, *state_attributes) }
3
5
  if @states.respond_to?(:total_pages)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@state, *state_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(stock_item, *stock_item_attributes)
2
4
  json.variant do
3
5
  json.partial!("spree/api/variants/small", variant: stock_item.variant)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.stock_items(@stock_items) do |stock_item|
2
4
  json.partial!("spree/api/stock_items/stock_item", stock_item: stock_item)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/stock_items/stock_item", stock_item: @stock_item)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(stock_location, *stock_location_attributes)
2
4
  json.country do
3
5
  if stock_location.country
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.stock_locations(@stock_locations) do |stock_location|
2
4
  json.partial!("spree/api/stock_locations/stock_location", stock_location: stock_location)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/stock_locations/stock_location", stock_location: @stock_location)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(stock_movement, *stock_movement_attributes)
2
4
  json.stock_item do
3
5
  json.partial!("spree/api/stock_items/stock_item", stock_item: stock_movement.stock_item)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.stock_movements(@stock_movements) do |stock_movement|
2
4
  json.partial!("spree/api/stock_movements/stock_movement", stock_movement: stock_movement)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/stock_movements/stock_movement", stock_movement: @stock_movement)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.store_credit_events(@store_credit_events) do |store_credit_event|
2
4
  json.(store_credit_event, *store_credit_history_attributes)
3
5
  json.order_number(store_credit_event.order.try(:number))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.stores(@stores) { |store| json.(store, *store_attributes) }
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@store, *store_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(taxonomy, *taxonomy_attributes)
2
4
  json.root do
3
5
  json.(taxonomy.root, *taxon_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if params[:set] == "nested"
2
4
  json.partial!("spree/api/taxonomies/nested", taxonomy: taxonomy)
3
5
  else
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.taxonomies(@taxonomies) do |taxonomy|
2
4
  json.partial!("spree/api/taxonomies/taxonomy", taxonomy: taxonomy)
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.data @taxonomy.root.name
2
4
  json.attr do
3
5
  json.id @taxonomy.root.id
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*taxonomy_attributes])
2
4
  json.required_attributes(required_fields_for(Spree::Taxonomy))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/taxonomies/taxonomy", taxonomy: @taxonomy)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(taxon, *taxon_attributes)
2
4
  json.taxons(taxon.children) { |taxon| json.(taxon, *taxon_attributes) }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.taxons(taxon.children) do |taxon|
2
4
  json.(taxon, *taxon_attributes)
3
5
  json.partial!("spree/api/taxons/taxons", taxon: taxon)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial! 'spree/api/shared/pagination', pagination: @taxons
2
4
  json.taxons(@taxons) do |taxon|
3
5
  json.(taxon, *taxon_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array!(@taxon.children) do |taxon|
2
4
  json.data taxon.name
3
5
  json.attr do
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*taxon_attributes])
2
4
  json.required_attributes(required_fields_for(Spree::Taxon))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/taxons/taxon", taxon: @taxon)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(user, *user_attributes)
2
4
  json.bill_address do
3
5
  if user.bill_address
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.users(@users) do |user|
2
4
  json.partial!("spree/api/users/user", user: user)
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*user_attributes])
2
4
  json.required_attributes(required_fields_for(Spree.user_class))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/users/user", user: @user)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
2
4
  json.(variant, *variant_attributes)
3
5
  json.partial!("spree/api/variants/small", variant: variant)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, variant] do
2
4
  json.(variant, *variant_attributes)
3
5
  json.display_price(variant.display_price.to_s)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial! 'spree/api/shared/pagination', pagination: @variants
2
4
  json.variants(@variants) do |variant|
3
5
  json.partial!("spree/api/variants/big", variant: variant)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*variant_attributes])
2
4
  json.required_attributes([])
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/variants/big", variant: @variant)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(zone, :id, :name, :description)
2
4
  json.zone_members(zone.zone_members) do |zone_member|
3
5
  json.(zone_member, :id, :name, :zoneable_type, :zoneable_id)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.zones(@zones) do |zone|
2
4
  json.partial!("spree/api/zones/zone", zone: zone)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/zones/zone", zone: @zone)
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Spree::Core::Engine.routes.draw do
2
4
  namespace :admin do
3
5
  resources :users do
@@ -18,12 +20,6 @@ Spree::Core::Engine.routes.draw do
18
20
  end
19
21
 
20
22
  concern :order_routes do
21
- member do
22
- put :cancel
23
- put :empty
24
- put :apply_coupon_code
25
- end
26
-
27
23
  resources :line_items
28
24
  resources :payments do
29
25
  member do
@@ -67,7 +63,13 @@ Spree::Core::Engine.routes.draw do
67
63
  get '/orders/mine', to: 'orders#mine', as: 'my_orders'
68
64
  get "/orders/current", to: "orders#current", as: "current_order"
69
65
 
70
- resources :orders, concerns: :order_routes
66
+ resources :orders, concerns: :order_routes do
67
+ member do
68
+ put :cancel
69
+ put :empty
70
+ put :apply_coupon_code
71
+ end
72
+ end
71
73
 
72
74
  resources :zones
73
75
  resources :countries, only: [:index, :show] do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddApiKeyToSpreeUsers < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  unless defined?(User)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ResizeApiKeyField < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  unless defined?(User)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RenameApiKeyToSpreeApiKey < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  unless defined?(User)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddIndexToUserSpreeApiKey < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  unless defined?(User)
data/lib/solidus_api.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree_api'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/engine'
2
4
 
3
5
  module Spree
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  module Responders
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/api/responders/rabl_template'
2
4
 
3
5
  module Spree
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.before(:each, caching: true) do
3
5
  ActionController::Base.perform_caching = true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  module TestingSupport
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  module TestingSupport
data/lib/spree/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/core'
2
4
 
3
5
  require 'responders'
data/lib/spree_api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/api'
2
4
  require 'spree/api/responders'
3
5
  require 'jbuilder'
data/script/rails CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
5
 
4
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
- ENGINE_PATH = File.expand_path('../../lib/spree/api/engine', __FILE__)
6
+ ENGINE_ROOT = File.expand_path('..', __dir__)
7
+ ENGINE_PATH = File.expand_path('../lib/spree/api/engine', __dir__)
6
8
 
7
9
  require 'rails/all'
8
10
  require 'rails/engine/commands'
data/solidus_api.gemspec CHANGED
@@ -1,4 +1,5 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative '../core/lib/spree/core/version.rb'
3
4
 
4
5
  Gem::Specification.new do |gem|
@@ -20,8 +21,8 @@ Gem::Specification.new do |gem|
20
21
  gem.required_ruby_version = '>= 2.2.2'
21
22
  gem.required_rubygems_version = '>= 1.8.23'
22
23
 
23
- gem.add_dependency 'solidus_core', gem.version
24
- gem.add_dependency 'responders'
25
24
  gem.add_dependency 'jbuilder', '~> 2.6'
26
25
  gem.add_dependency 'kaminari-activerecord', '~> 1.1'
26
+ gem.add_dependency 'responders'
27
+ gem.add_dependency 'solidus_core', gem.version
27
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class FakesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Spree
@@ -59,10 +61,12 @@ module Spree
59
61
  it "returns widgets" do
60
62
  get :index, params: { token: admin_user.spree_api_key }, as: :json
61
63
  expect(response).to be_successful
62
- expect(json_response['widgets']).to include(hash_including(
63
- 'name' => 'a widget',
64
- 'position' => 1
65
- ))
64
+ expect(json_response['widgets']).to include(
65
+ hash_including(
66
+ 'name' => 'a widget',
67
+ 'position' => 1
68
+ )
69
+ )
66
70
  end
67
71
 
68
72
  context "specifying ids" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Spree