spree_api 2.4.9 → 2.4.10
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 632c3f3af60db8e2033c1fadf69ab81d11aae659
|
4
|
+
data.tar.gz: e80451f21adb1335d2be39bf4ffe33fece0c62ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75341ff16ac40cdb8eb1e2c44e34f27ba3a934bb3ed9a216d99540ae3519d168c52d63d6ba71d25e89cf0bd3f0d91aa9fd46791604b9f94d1cc1e00df1593750
|
7
|
+
data.tar.gz: 2922b722b993fef6bf874d4092a3864794185e8caa90b910e539ae7f3744eacddcba049891dbb0621c37c79c3f7da2ccebea69d69a15832267560172a20f4d64
|
@@ -85,7 +85,7 @@ module Spree
|
|
85
85
|
|
86
86
|
@@payment_attributes = [
|
87
87
|
:id, :source_type, :source_id, :amount, :display_amount,
|
88
|
-
:payment_method_id, :
|
88
|
+
:payment_method_id, :state, :avs_response, :created_at,
|
89
89
|
:updated_at
|
90
90
|
]
|
91
91
|
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
let!(:order) { create(:order) }
|
7
7
|
let!(:payment) { create(:payment, :order => order) }
|
8
8
|
let!(:attributes) { [:id, :source_type, :source_id, :amount, :display_amount,
|
9
|
-
:payment_method_id, :
|
9
|
+
:payment_method_id, :state, :avs_response,
|
10
10
|
:created_at, :updated_at] }
|
11
11
|
|
12
12
|
let(:resource_scoping) { { :order_id => order.to_param } }
|
@@ -82,7 +82,7 @@ module Spree
|
|
82
82
|
end
|
83
83
|
|
84
84
|
context "multiple payments" do
|
85
|
-
before { @payment = create(:payment, :order => order
|
85
|
+
before { @payment = create(:payment, :order => order) }
|
86
86
|
|
87
87
|
it "can view all payments on an order" do
|
88
88
|
api_get :index
|
@@ -95,12 +95,6 @@ module Spree
|
|
95
95
|
expect(json_response['current_page']).to eq(1)
|
96
96
|
expect(json_response['pages']).to eq(2)
|
97
97
|
end
|
98
|
-
|
99
|
-
it 'can query the results through a paramter' do
|
100
|
-
api_get :index, :q => { :response_code_cont => '999' }
|
101
|
-
expect(json_response['count']).to eq(1)
|
102
|
-
expect(json_response['payments'].first['response_code']).to eq @payment.response_code
|
103
|
-
end
|
104
98
|
end
|
105
99
|
|
106
100
|
context "for a given payment" do
|
@@ -0,0 +1,79 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.4.
|
19
|
+
version: 2.4.10
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.4.
|
26
|
+
version: 2.4.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -241,6 +241,7 @@ files:
|
|
241
241
|
- spec/fixtures/thinking-cat.jpg
|
242
242
|
- spec/models/spree/legacy_user_spec.rb
|
243
243
|
- spec/requests/rabl_cache_spec.rb
|
244
|
+
- spec/requests/ransackable_attributes_spec.rb
|
244
245
|
- spec/shared_examples/protect_product_actions.rb
|
245
246
|
- spec/spec_helper.rb
|
246
247
|
- spec/support/controller_hacks.rb
|
@@ -306,6 +307,7 @@ test_files:
|
|
306
307
|
- spec/fixtures/thinking-cat.jpg
|
307
308
|
- spec/models/spree/legacy_user_spec.rb
|
308
309
|
- spec/requests/rabl_cache_spec.rb
|
310
|
+
- spec/requests/ransackable_attributes_spec.rb
|
309
311
|
- spec/shared_examples/protect_product_actions.rb
|
310
312
|
- spec/spec_helper.rb
|
311
313
|
- spec/support/controller_hacks.rb
|