spree_api 2.3.13 → 2.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -43
  3. data/Gemfile +1 -1
  4. data/app/controllers/spree/api/addresses_controller.rb +1 -1
  5. data/app/controllers/spree/api/base_controller.rb +22 -9
  6. data/app/controllers/spree/api/checkouts_controller.rb +2 -2
  7. data/app/controllers/spree/api/countries_controller.rb +2 -2
  8. data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
  9. data/app/controllers/spree/api/images_controller.rb +5 -0
  10. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  11. data/app/controllers/spree/api/line_items_controller.rb +7 -7
  12. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  13. data/app/controllers/spree/api/orders_controller.rb +17 -6
  14. data/app/controllers/spree/api/payments_controller.rb +3 -11
  15. data/app/controllers/spree/api/product_properties_controller.rb +2 -2
  16. data/app/controllers/spree/api/promotions_controller.rb +26 -0
  17. data/app/controllers/spree/api/properties_controller.rb +1 -1
  18. data/app/controllers/spree/api/return_authorizations_controller.rb +0 -10
  19. data/app/controllers/spree/api/shipments_controller.rb +71 -4
  20. data/app/controllers/spree/api/states_controller.rb +3 -3
  21. data/app/controllers/spree/api/stock_items_controller.rb +1 -1
  22. data/app/controllers/spree/api/stock_movements_controller.rb +1 -1
  23. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  24. data/app/controllers/spree/api/variants_controller.rb +1 -2
  25. data/app/helpers/spree/api/api_helpers.rb +19 -5
  26. data/app/views/spree/api/images/index.v1.rabl +4 -0
  27. data/app/views/spree/api/products/show.v1.rabl +4 -1
  28. data/app/views/spree/api/promotions/handler.v1.rabl +2 -1
  29. data/app/views/spree/api/promotions/show.v1.rabl +2 -0
  30. data/app/views/spree/api/shipments/big.v1.rabl +48 -0
  31. data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
  32. data/app/views/spree/api/shipments/small.v1.rabl +1 -5
  33. data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -2
  34. data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
  35. data/app/views/spree/api/variants/big.v1.rabl +6 -1
  36. data/app/views/spree/api/variants/show.v1.rabl +1 -1
  37. data/app/views/spree/api/variants/small.v1.rabl +2 -3
  38. data/config/routes.rb +9 -0
  39. data/lib/spree/api/responders/rabl_template.rb +1 -1
  40. data/lib/spree/api/testing_support/helpers.rb +6 -6
  41. data/lib/spree/api/testing_support/setup.rb +2 -2
  42. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  43. data/spec/controllers/spree/api/base_controller_spec.rb +66 -19
  44. data/spec/controllers/spree/api/checkouts_controller_spec.rb +54 -54
  45. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  46. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  47. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  48. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  49. data/spec/controllers/spree/api/images_controller_spec.rb +37 -11
  50. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  51. data/spec/controllers/spree/api/line_items_controller_spec.rb +34 -35
  52. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  53. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  54. data/spec/controllers/spree/api/orders_controller_spec.rb +177 -161
  55. data/spec/controllers/spree/api/payments_controller_spec.rb +52 -89
  56. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  57. data/spec/controllers/spree/api/products_controller_spec.rb +103 -60
  58. data/spec/controllers/spree/api/promotion_application_spec.rb +14 -12
  59. data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
  60. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  61. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +42 -66
  62. data/spec/controllers/spree/api/shipments_controller_spec.rb +69 -21
  63. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  64. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  65. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  66. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  67. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  68. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  69. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  70. data/spec/controllers/spree/api/users_controller_spec.rb +41 -41
  71. data/spec/controllers/spree/api/variants_controller_spec.rb +47 -37
  72. data/spec/controllers/spree/api/zones_controller_spec.rb +40 -18
  73. data/spec/models/spree/legacy_user_spec.rb +5 -5
  74. data/spec/requests/rabl_cache_spec.rb +9 -9
  75. data/spec/spec_helper.rb +1 -0
  76. metadata +14 -9
  77. data/spec/requests/ransackable_attributes_spec.rb +0 -79
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Ransackable Attributes" do
4
- let(:user) { create(:user).tap(&:generate_spree_api_key!) }
5
- let(:order) { create(:order_with_line_items, user: user) }
6
- context "filtering by attributes one association away" do
7
- it "does not allow the filtering of variants by order attributes" do
8
- 2.times { create(:variant) }
9
-
10
- get "/api/variants?q[orders_email_start]=#{order.email}", token: user.spree_api_key
11
-
12
- variants_response = JSON.parse(response.body)
13
- expect(variants_response['total_count']).to eq(Spree::Variant.count)
14
- end
15
- end
16
-
17
- context "filtering by attributes two associations away" do
18
- it "does not allow the filtering of variants by user attributes" do
19
- 2.times { create(:variant) }
20
-
21
- get "/api/variants?q[orders_user_email_start]=#{order.user.email}", token: user.spree_api_key
22
-
23
- variants_response = JSON.parse(response.body)
24
- expect(variants_response['total_count']).to eq(Spree::Variant.count)
25
- end
26
- end
27
-
28
- context "it maintains desired association behavior" do
29
- it "allows filtering of variants product name" do
30
- product = create(:product, name: "Fritos")
31
- variant = create(:variant, product: product)
32
- other_variant = create(:variant)
33
-
34
- get "/api/variants?q[product_name_or_sku_cont]=fritos", token: user.spree_api_key
35
-
36
- skus = JSON.parse(response.body)['variants'].map { |variant| variant['sku'] }
37
- expect(skus).to include variant.sku
38
- expect(skus).not_to include other_variant.sku
39
- end
40
- end
41
-
42
- context "filtering by attributes" do
43
- it "most attributes are not filterable by default" do
44
- product = create(:product, description: "special product")
45
- other_product = create(:product)
46
-
47
- get "/api/products?q[description_cont]=special", token: user.spree_api_key
48
-
49
- products_response = JSON.parse(response.body)
50
- expect(products_response['total_count']).to eq(Spree::Product.count)
51
- end
52
-
53
- it "id is filterable by default" do
54
- product = create(:product)
55
- other_product = create(:product)
56
-
57
- get "/api/products?q[id_eq]=#{product.id}", token: user.spree_api_key
58
-
59
- product_names = JSON.parse(response.body)['products'].map { |product| product['name'] }
60
- expect(product_names).to include product.name
61
- expect(product_names).not_to include other_product.name
62
- end
63
- end
64
-
65
- context "filtering by whitelisted attributes" do
66
- it "filtering is supported for whitelisted attributes" do
67
- product = create(:product, name: "Fritos")
68
- other_product = create(:product)
69
-
70
- get "/api/products?q[name_cont]=fritos", token: user.spree_api_key
71
-
72
- product_names = JSON.parse(response.body)['products'].map { |product| product['name'] }
73
- expect(product_names).to include product.name
74
- expect(product_names).not_to include other_product.name
75
- end
76
- end
77
-
78
-
79
- end