solidus_api 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_api might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a5d9ad65766d57b6e668c543035339ba715129
|
4
|
+
data.tar.gz: 867a41c74f427ebe79572a9f1794bf11d8a19905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38037983b84aa6132810cb4d25559c82f10c4ddb116fbf4b09679357923c7fb9e386074e6f0b28d0b6625219dd38107d26c17f8070f5dd908de4cb441c5defaa
|
7
|
+
data.tar.gz: e6c21c9dda1779187bc03c9380cdf12e010ab383669fd1c4ec1707d62ff27a84f7221d53ff15f74c2ada177a11a9705dcb806ac878830805955891f4160c187a
|
@@ -93,7 +93,7 @@ module Spree
|
|
93
93
|
|
94
94
|
@@payment_attributes = [
|
95
95
|
:id, :source_type, :source_id, :amount, :display_amount,
|
96
|
-
:payment_method_id, :
|
96
|
+
:payment_method_id, :state, :avs_response, :created_at,
|
97
97
|
:updated_at
|
98
98
|
]
|
99
99
|
|
@@ -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 } }
|
@@ -107,7 +107,7 @@ module Spree
|
|
107
107
|
end
|
108
108
|
|
109
109
|
context "multiple payments" do
|
110
|
-
before { @payment = create(:payment, :order => order
|
110
|
+
before { @payment = create(:payment, :order => order) }
|
111
111
|
|
112
112
|
it "can view all payments on an order" do
|
113
113
|
api_get :index
|
@@ -120,12 +120,6 @@ module Spree
|
|
120
120
|
expect(json_response['current_page']).to eq(1)
|
121
121
|
expect(json_response['pages']).to eq(2)
|
122
122
|
end
|
123
|
-
|
124
|
-
it 'can query the results through a paramter' do
|
125
|
-
api_get :index, :q => { :response_code_cont => '999' }
|
126
|
-
expect(json_response['count']).to eq(1)
|
127
|
-
expect(json_response['payments'].first['response_code']).to eq @payment.response_code
|
128
|
-
end
|
129
123
|
end
|
130
124
|
|
131
125
|
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: solidus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.
|
19
|
+
version: 1.0.1
|
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: 1.0.
|
26
|
+
version: 1.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- spec/fixtures/thinking-cat.jpg
|
254
254
|
- spec/models/spree/legacy_user_spec.rb
|
255
255
|
- spec/requests/rabl_cache_spec.rb
|
256
|
+
- spec/requests/ransackable_attributes_spec.rb
|
256
257
|
- spec/shared_examples/protect_product_actions.rb
|
257
258
|
- spec/spec_helper.rb
|
258
259
|
- spec/support/controller_hacks.rb
|
@@ -321,6 +322,7 @@ test_files:
|
|
321
322
|
- spec/fixtures/thinking-cat.jpg
|
322
323
|
- spec/models/spree/legacy_user_spec.rb
|
323
324
|
- spec/requests/rabl_cache_spec.rb
|
325
|
+
- spec/requests/ransackable_attributes_spec.rb
|
324
326
|
- spec/shared_examples/protect_product_actions.rb
|
325
327
|
- spec/spec_helper.rb
|
326
328
|
- spec/support/controller_hacks.rb
|