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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -43
- data/Gemfile +1 -1
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/base_controller.rb +22 -9
- data/app/controllers/spree/api/checkouts_controller.rb +2 -2
- data/app/controllers/spree/api/countries_controller.rb +2 -2
- data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
- data/app/controllers/spree/api/images_controller.rb +5 -0
- data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
- data/app/controllers/spree/api/line_items_controller.rb +7 -7
- data/app/controllers/spree/api/option_types_controller.rb +2 -2
- data/app/controllers/spree/api/orders_controller.rb +17 -6
- data/app/controllers/spree/api/payments_controller.rb +3 -11
- data/app/controllers/spree/api/product_properties_controller.rb +2 -2
- data/app/controllers/spree/api/promotions_controller.rb +26 -0
- data/app/controllers/spree/api/properties_controller.rb +1 -1
- data/app/controllers/spree/api/return_authorizations_controller.rb +0 -10
- data/app/controllers/spree/api/shipments_controller.rb +71 -4
- data/app/controllers/spree/api/states_controller.rb +3 -3
- data/app/controllers/spree/api/stock_items_controller.rb +1 -1
- data/app/controllers/spree/api/stock_movements_controller.rb +1 -1
- data/app/controllers/spree/api/taxons_controller.rb +1 -1
- data/app/controllers/spree/api/variants_controller.rb +1 -2
- data/app/helpers/spree/api/api_helpers.rb +19 -5
- data/app/views/spree/api/images/index.v1.rabl +4 -0
- data/app/views/spree/api/products/show.v1.rabl +4 -1
- data/app/views/spree/api/promotions/handler.v1.rabl +2 -1
- data/app/views/spree/api/promotions/show.v1.rabl +2 -0
- data/app/views/spree/api/shipments/big.v1.rabl +48 -0
- data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
- data/app/views/spree/api/shipments/small.v1.rabl +1 -5
- data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -2
- data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
- data/app/views/spree/api/variants/big.v1.rabl +6 -1
- data/app/views/spree/api/variants/show.v1.rabl +1 -1
- data/app/views/spree/api/variants/small.v1.rabl +2 -3
- data/config/routes.rb +9 -0
- data/lib/spree/api/responders/rabl_template.rb +1 -1
- data/lib/spree/api/testing_support/helpers.rb +6 -6
- data/lib/spree/api/testing_support/setup.rb +2 -2
- data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
- data/spec/controllers/spree/api/base_controller_spec.rb +66 -19
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +54 -54
- data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
- data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
- data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
- data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/images_controller_spec.rb +37 -11
- data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
- data/spec/controllers/spree/api/line_items_controller_spec.rb +34 -35
- data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/orders_controller_spec.rb +177 -161
- data/spec/controllers/spree/api/payments_controller_spec.rb +52 -89
- data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/products_controller_spec.rb +103 -60
- data/spec/controllers/spree/api/promotion_application_spec.rb +14 -12
- data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
- data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +42 -66
- data/spec/controllers/spree/api/shipments_controller_spec.rb +69 -21
- data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
- data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
- data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
- data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
- data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
- data/spec/controllers/spree/api/users_controller_spec.rb +41 -41
- data/spec/controllers/spree/api/variants_controller_spec.rb +47 -37
- data/spec/controllers/spree/api/zones_controller_spec.rb +40 -18
- data/spec/models/spree/legacy_user_spec.rb +5 -5
- data/spec/requests/rabl_cache_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -0
- metadata +14 -9
- 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
|