spree_api 2.4.7 → 2.4.8
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: 40d01a3bf09919e41497e15452a188bac206a1c2
|
4
|
+
data.tar.gz: 0096ccb1856282fa76364037044d210be2b33071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ccecb22f194fee13d0524e7fd3c5715d5f953e93f8470d11795c60ae8b11df04af4d5ae32de2190c3823573aba944caeaaf9ba36acc019790df8f96b38b5652
|
7
|
+
data.tar.gz: 90aed06d9f038a35a86d7b07107f6b4f960de1dbae48a2f894f8ffa4cffec1347057ade007d158c5f423a50b6b791aba82225c91fbe29fed719d366ca11af1ad
|
@@ -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.4.
|
4
|
+
version: 2.4.8
|
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.4.
|
19
|
+
version: 2.4.8
|
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.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|