spree_api 2.3.12 → 2.3.13
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66783ac8d7fc4ed56b7b502f4b06deac327c166
|
4
|
+
data.tar.gz: e3e18787faa84ccb9f866ebd3edc1fe60ed25680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 618499c336b0c81307853586db653855fa7657a23a0c18a88ce621419e2402bcf7f4eaa890466cdc2cefac1ddb11d7a5aa0c41094a7614064f54554f2b70caed
|
7
|
+
data.tar.gz: a22ce4bbbbbd21d6f2bb43745e357a3e3391f73b5e22c96508bf32d6fd8265ab3263d3a936eb6eeab6155efb324f24129b01e02e9e406f0954de45eb5772445f
|
@@ -83,7 +83,7 @@ module Spree
|
|
83
83
|
|
84
84
|
@@payment_attributes = [
|
85
85
|
:id, :source_type, :source_id, :amount, :display_amount,
|
86
|
-
:payment_method_id, :
|
86
|
+
:payment_method_id, :state, :avs_response, :created_at,
|
87
87
|
:updated_at
|
88
88
|
]
|
89
89
|
|
@@ -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.3.
|
4
|
+
version: 2.3.13
|
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.3.
|
19
|
+
version: 2.3.13
|
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.3.
|
26
|
+
version: 2.3.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- spec/fixtures/thinking-cat.jpg
|
232
232
|
- spec/models/spree/legacy_user_spec.rb
|
233
233
|
- spec/requests/rabl_cache_spec.rb
|
234
|
+
- spec/requests/ransackable_attributes_spec.rb
|
234
235
|
- spec/shared_examples/protect_product_actions.rb
|
235
236
|
- spec/spec_helper.rb
|
236
237
|
- spec/support/controller_hacks.rb
|
@@ -294,6 +295,7 @@ test_files:
|
|
294
295
|
- spec/fixtures/thinking-cat.jpg
|
295
296
|
- spec/models/spree/legacy_user_spec.rb
|
296
297
|
- spec/requests/rabl_cache_spec.rb
|
298
|
+
- spec/requests/ransackable_attributes_spec.rb
|
297
299
|
- spec/shared_examples/protect_product_actions.rb
|
298
300
|
- spec/spec_helper.rb
|
299
301
|
- spec/support/controller_hacks.rb
|