spree_api 2.4.10 → 3.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -2
  3. data/app/controllers/spree/api/base_controller.rb +9 -3
  4. data/app/controllers/spree/api/checkouts_controller.rb +4 -4
  5. data/app/controllers/spree/api/countries_controller.rb +3 -3
  6. data/app/controllers/spree/api/images_controller.rb +2 -2
  7. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  8. data/app/controllers/spree/api/option_values_controller.rb +1 -1
  9. data/app/controllers/spree/api/orders_controller.rb +6 -14
  10. data/app/controllers/spree/api/payments_controller.rb +5 -5
  11. data/app/controllers/spree/api/product_properties_controller.rb +1 -1
  12. data/app/controllers/spree/api/products_controller.rb +5 -5
  13. data/app/controllers/spree/api/properties_controller.rb +2 -2
  14. data/app/controllers/spree/api/return_authorizations_controller.rb +4 -4
  15. data/app/controllers/spree/api/shipments_controller.rb +4 -4
  16. data/app/controllers/spree/api/states_controller.rb +2 -2
  17. data/app/controllers/spree/api/stock_items_controller.rb +4 -4
  18. data/app/controllers/spree/api/stock_locations_controller.rb +5 -5
  19. data/app/controllers/spree/api/stock_movements_controller.rb +3 -3
  20. data/app/controllers/spree/api/stores_controller.rb +5 -5
  21. data/app/controllers/spree/api/taxonomies_controller.rb +4 -4
  22. data/app/controllers/spree/api/taxons_controller.rb +3 -3
  23. data/app/controllers/spree/api/users_controller.rb +3 -3
  24. data/app/controllers/spree/api/variants_controller.rb +3 -3
  25. data/app/controllers/spree/api/zones_controller.rb +7 -4
  26. data/app/helpers/spree/api/api_helpers.rb +1 -1
  27. data/app/views/spree/api/config/money.v1.rabl +0 -4
  28. data/app/views/spree/api/orders/payment.v1.rabl +1 -1
  29. data/app/views/spree/api/orders/show.v1.rabl +5 -1
  30. data/app/views/spree/api/products/show.v1.rabl +1 -0
  31. data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
  32. data/app/views/spree/api/variants/big.v1.rabl +6 -0
  33. data/app/views/spree/api/variants/small.v1.rabl +0 -1
  34. data/config/routes.rb +5 -1
  35. data/lib/spree/api/responders/rabl_template.rb +3 -4
  36. data/lib/spree/api/testing_support/helpers.rb +1 -1
  37. data/spec/controllers/spree/api/base_controller_spec.rb +16 -2
  38. data/spec/controllers/spree/api/config_controller_spec.rb +1 -5
  39. data/spec/controllers/spree/api/line_items_controller_spec.rb +3 -4
  40. data/spec/controllers/spree/api/orders_controller_spec.rb +1 -28
  41. data/spec/controllers/spree/api/payments_controller_spec.rb +21 -26
  42. data/spec/controllers/spree/api/product_properties_controller_spec.rb +1 -1
  43. data/spec/controllers/spree/api/products_controller_spec.rb +54 -7
  44. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +2 -2
  45. data/spec/controllers/spree/api/stock_items_controller_spec.rb +4 -2
  46. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +0 -6
  47. data/spec/controllers/spree/api/users_controller_spec.rb +17 -17
  48. data/spec/controllers/spree/api/variants_controller_spec.rb +2 -5
  49. data/spec/controllers/spree/api/zones_controller_spec.rb +26 -0
  50. data/spec/spec_helper.rb +3 -4
  51. data/spec/support/controller_hacks.rb +7 -5
  52. data/spree_api.gemspec +2 -1
  53. metadata +9 -10
  54. 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