spree_api 2.2.13 → 2.2.14

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: 3ea3a6f28040f5fa62c8e0150759609cbd3f2d7b
4
- data.tar.gz: 81c6b1f62b25e35eb98c4ea32f12a282e5a62351
3
+ metadata.gz: 3bd604d7be8b5ce2ad7e836ea4b0780fb341ba8f
4
+ data.tar.gz: ae0288be52192b331e5c5fdb5d3669b6b4d52b9b
5
5
  SHA512:
6
- metadata.gz: 15ecc4104f5cc0c5a730be2f65806262dc753a17fbf5c95ffb3aebfba8a404bea1ae7f8b09cb1d128bf5ab0fbd59e0859ec0584f95c8740a12460ce2b2a9c7a0
7
- data.tar.gz: e3409175aca6bb2805f7b229144de7a1ea76e8b90d4b5215843288a0e11303e90dc88de63e4d52b506d871d2d56d7b434a0824b4971d77d4a73445bc06c40a5d
6
+ metadata.gz: b7f5a27d73d130a2b44e2ba927dfa79b110ef821404e4494bfd9ce1703ce286dc605a1853552e5e906f2aca9f1fe2fa20531cbef4148722122a26182550ce9fd
7
+ data.tar.gz: cb40f75ca437a68f9f4d1d51d9f29910c903668fe16fde77f4ea1f46011140b1d40dec24072cbe04611f8edd8d707447c05d7bb08ed8f5b84cf281f687eddd52
@@ -84,7 +84,7 @@ module Spree
84
84
 
85
85
  @@payment_attributes = [
86
86
  :id, :source_type, :source_id, :amount, :display_amount,
87
- :payment_method_id, :response_code, :state, :avs_response, :created_at,
87
+ :payment_method_id, :state, :avs_response, :created_at,
88
88
  :updated_at
89
89
  ]
90
90
 
@@ -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, :response_code, :state, :avs_response,
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, :response_code => '99999') }
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
  json_response['current_page'].should == 1
96
96
  json_response['pages'].should == 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
- json_response['count'].should == 1
102
- json_response['payments'].first['response_code'].should 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.2.13
4
+ version: 2.2.14
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-07-28 00:00:00.000000000 Z
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.2.13
19
+ version: 2.2.14
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.2.13
26
+ version: 2.2.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -229,6 +229,7 @@ files:
229
229
  - spec/fixtures/thinking-cat.jpg
230
230
  - spec/models/spree/legacy_user_spec.rb
231
231
  - spec/requests/rabl_cache_spec.rb
232
+ - spec/requests/ransackable_attributes_spec.rb
232
233
  - spec/shared_examples/protect_product_actions.rb
233
234
  - spec/spec_helper.rb
234
235
  - spec/support/controller_hacks.rb
@@ -291,6 +292,7 @@ test_files:
291
292
  - spec/fixtures/thinking-cat.jpg
292
293
  - spec/models/spree/legacy_user_spec.rb
293
294
  - spec/requests/rabl_cache_spec.rb
295
+ - spec/requests/ransackable_attributes_spec.rb
294
296
  - spec/shared_examples/protect_product_actions.rb
295
297
  - spec/spec_helper.rb
296
298
  - spec/support/controller_hacks.rb