spree_api 2.3.10 → 2.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/payments_controller.rb +1 -1
- data/lib/spree/api/responders/rabl_template.rb +1 -1
- data/spec/controllers/spree/api/payments_controller_spec.rb +24 -13
- data/spec/controllers/spree/api/products_controller_spec.rb +0 -28
- data/spec/controllers/spree/api/zones_controller_spec.rb +0 -22
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed0a530c08a01e75e353b91d68dffab34f9b8b6f
|
4
|
+
data.tar.gz: 406c9153f3dba06a9e2f3a726d554af79cb7896a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f6627eb12601b97b6634fc974b2b219a73c2436561c2a51f50ca412636df492866eb482706c542146d7dc1fbc6d9e1a56cd8355dc479165d1168170fb04bc05
|
7
|
+
data.tar.gz: db2c6d8019058c36930f5e774fb8017ba082e27990f9f4095f8ef5065714f00800c02d475dd7a6852b625b19805238009f31bad23bc4b1e69cb287c9c81370fa
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
|
27
27
|
def update
|
28
28
|
authorize! params[:action], @payment
|
29
|
-
if
|
29
|
+
if !@payment.editable?
|
30
30
|
render 'update_forbidden', status: 403
|
31
31
|
elsif @payment.update_attributes(payment_params)
|
32
32
|
respond_with(@payment, default_template: :show)
|
@@ -105,26 +105,37 @@ module Spree
|
|
105
105
|
|
106
106
|
context "for a given payment" do
|
107
107
|
context "updating" do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
context "when the state is checkout" do
|
109
|
+
it "can update" do
|
110
|
+
payment.update_attributes(state: 'checkout')
|
111
|
+
api_put(:update, id: payment.to_param, payment: { amount: 2.01 })
|
112
|
+
expect(response.status).to be(200)
|
113
|
+
expect(payment.reload.amount).to eq(2.01)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "when the state is pending" do
|
118
|
+
it "can update" do
|
119
|
+
payment.update_attributes(state: 'pending')
|
120
|
+
api_put(:update, id: payment.to_param, payment: { amount: 2.01 })
|
121
|
+
expect(response.status).to be(200)
|
122
|
+
expect(payment.reload.amount).to eq(2.01)
|
123
|
+
end
|
113
124
|
end
|
114
125
|
|
115
126
|
context "update fails" do
|
116
127
|
it "returns a 422 status when the amount is invalid" do
|
117
|
-
payment.update_attributes(:
|
118
|
-
api_put
|
119
|
-
expect(response.status).to
|
120
|
-
expect(json_response[
|
128
|
+
payment.update_attributes(state: 'pending')
|
129
|
+
api_put(:update, id: payment.to_param, payment: { amount: 'invalid' })
|
130
|
+
expect(response.status).to be(422)
|
131
|
+
expect(json_response['error']).to eql('Invalid resource. Please fix errors and try again.')
|
121
132
|
end
|
122
133
|
|
123
134
|
it "returns a 403 status when the payment is not pending" do
|
124
|
-
payment.update_attributes(:
|
125
|
-
api_put
|
126
|
-
expect(response.status).to
|
127
|
-
expect(json_response[
|
135
|
+
payment.update_attributes(state: 'completed')
|
136
|
+
api_put(:update, id: payment.to_param, payment: { amount: 2.01 })
|
137
|
+
expect(response.status).to be(403)
|
138
|
+
expect(json_response['error']).to eql('This payment cannot be updated because it is completed.')
|
128
139
|
end
|
129
140
|
end
|
130
141
|
end
|
@@ -67,34 +67,6 @@ module Spree
|
|
67
67
|
expect(json_response["per_page"]).to eq(Kaminari.config.default_per_page)
|
68
68
|
end
|
69
69
|
|
70
|
-
context "specifying a rabl template for a custom action" do
|
71
|
-
before do
|
72
|
-
Spree::Api::ProductsController.class_eval do
|
73
|
-
def custom_show
|
74
|
-
@product = find_product(params[:id])
|
75
|
-
respond_with(@product)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "uses the specified custom template through the request header" do
|
81
|
-
request.headers['X-Spree-Template'] = 'show'
|
82
|
-
api_get :custom_show, :id => product.id
|
83
|
-
expect(response).to render_template('spree/api/products/show')
|
84
|
-
end
|
85
|
-
|
86
|
-
it "uses the specified custom template through the template URL parameter" do
|
87
|
-
api_get :custom_show, :id => product.id, :template => 'show'
|
88
|
-
expect(response).to render_template('spree/api/products/show')
|
89
|
-
end
|
90
|
-
|
91
|
-
it "falls back to the default template if the specified template does not exist" do
|
92
|
-
request.headers['X-Spree-Template'] = 'invoice'
|
93
|
-
api_get :show, :id => product.id
|
94
|
-
expect(response).to render_template('spree/api/products/show')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
70
|
context "product has more than one price" do
|
99
71
|
before { product.master.prices.create currency: "EUR", amount: 22 }
|
100
72
|
|
@@ -38,28 +38,6 @@ module Spree
|
|
38
38
|
expect(json_response['zone_members'].size).to eq @zone.zone_members.count
|
39
39
|
end
|
40
40
|
|
41
|
-
context "specifying a rabl template to use" do
|
42
|
-
before do
|
43
|
-
Spree::Api::ZonesController.class_eval do
|
44
|
-
def custom_show
|
45
|
-
respond_with(zone)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "uses the specified template" do
|
51
|
-
request.headers['X-Spree-Template'] = 'show'
|
52
|
-
api_get :custom_show, :id => @zone.id
|
53
|
-
expect(response).to render_template('spree/api/zones/show')
|
54
|
-
end
|
55
|
-
|
56
|
-
it "falls back to the default template if the specified template does not exist" do
|
57
|
-
request.headers['X-Spree-Template'] = 'invoice'
|
58
|
-
api_get :show, :id => @zone.id
|
59
|
-
expect(response).to render_template('spree/api/zones/show')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
41
|
context "as an admin" do
|
64
42
|
sign_in_as_admin!
|
65
43
|
|
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.11
|
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-07-20 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.11
|
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.11
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|