spree_api 2.3.10 → 2.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22e6d6368a0b553bae43005f73d2d28c9fe0af71
4
- data.tar.gz: 2ca37e342f06bb3ebae960483d1772ec6ca53d38
3
+ metadata.gz: ed0a530c08a01e75e353b91d68dffab34f9b8b6f
4
+ data.tar.gz: 406c9153f3dba06a9e2f3a726d554af79cb7896a
5
5
  SHA512:
6
- metadata.gz: bd7fd7f4eb054222112e8c9b9505a5b216e6688d44e897b56958c00aaca830cbba72769b27483c390319f645742e1a1807489f67f7be500be46f5f4a048a2322
7
- data.tar.gz: dbcf2f5d1f0086ba98f0100ad730541d1bc8016fc691c03c67ce5de940650f8cf0d92f209d2aabe714f6882ab2ffe957c12f8c76b42b0c55941d05d102b01f5c
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 ! @payment.pending?
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)
@@ -14,7 +14,7 @@ module Spree
14
14
  end
15
15
 
16
16
  def template
17
- request.headers['X-Spree-Template'] || controller.params[:template] || options[:default_template]
17
+ options[:default_template]
18
18
  end
19
19
 
20
20
  def api_behavior(error)
@@ -105,26 +105,37 @@ module Spree
105
105
 
106
106
  context "for a given payment" do
107
107
  context "updating" do
108
- it "can update" do
109
- payment.update_attributes(:state => 'pending')
110
- api_put :update, :id => payment.to_param, :payment => { :amount => 2.01 }
111
- expect(response.status).to eq(200)
112
- expect(payment.reload.amount).to eq(2.01)
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(:state => 'pending')
118
- api_put :update, :id => payment.to_param, :payment => { :amount => 'invalid' }
119
- expect(response.status).to eq(422)
120
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
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(:state => 'completed')
125
- api_put :update, :id => payment.to_param, :payment => { :amount => 2.01 }
126
- expect(response.status).to eq(403)
127
- expect(json_response["error"]).to eq("This payment cannot be updated because it is completed.")
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.10
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-05-05 00:00:00.000000000 Z
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.10
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.10
26
+ version: 2.3.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement