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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99560ebdaf455a59e76c64abf84ae1d2da1adb30
4
- data.tar.gz: e9d198bf6d7a8a2131a7db49d55c61ae4d231b63
3
+ metadata.gz: 40d01a3bf09919e41497e15452a188bac206a1c2
4
+ data.tar.gz: 0096ccb1856282fa76364037044d210be2b33071
5
5
  SHA512:
6
- metadata.gz: 94c7b6c9613e7ee865c0cc6cc0e0b761d4b077b76d7013677dacab09b032b15dccabdb3b1cb8d746557f6b66c82864bfcfedd688848c7a16da50c94a99375ba5
7
- data.tar.gz: 1f4b86560857b5170b7566f641ace8b91d58f367d23dcc5bb4dfe8db02de637b19191825f3722ee378c96e02e53279e054d2f054fda207bb072f635acc070466
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 ! @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.4.7
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-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.4.7
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.7
26
+ version: 2.4.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement