spree_api 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/spree/api/v1/orders_controller.rb +2 -1
- data/app/controllers/spree/api/v1/products_controller.rb +1 -0
- data/app/views/spree/api/v1/orders/index.rabl +1 -1
- data/lib/spree/api/controller_setup.rb +1 -0
- data/lib/spree/api/engine.rb +2 -0
- data/spec/controllers/spree/api/v1/orders_controller_spec.rb +27 -6
- metadata +16 -16
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
def index
|
9
9
|
# should probably look at turning this into a CanCan step
|
10
10
|
raise CanCan::AccessDenied unless current_api_user.has_role?("admin")
|
11
|
-
@orders = Order.page(params[:page])
|
11
|
+
@orders = Order.page(params[:page]).per(params[:per_page])
|
12
12
|
end
|
13
13
|
|
14
14
|
def show
|
@@ -27,6 +27,7 @@ module Spree
|
|
27
27
|
def update
|
28
28
|
authorize! :update, Order
|
29
29
|
if order.update_attributes(@nested_params)
|
30
|
+
order.update!
|
30
31
|
render :show
|
31
32
|
else
|
32
33
|
invalid_resource!(order)
|
data/lib/spree/api/engine.rb
CHANGED
@@ -120,6 +120,13 @@ module Spree
|
|
120
120
|
json_response["errors"]["bill_address.firstname"].should_not be_blank
|
121
121
|
end
|
122
122
|
|
123
|
+
it "can add line items" do
|
124
|
+
api_put :update, :id => order.to_param, :order => { :line_items => [{:variant_id => create(:variant).id, :quantity => 2}] }
|
125
|
+
|
126
|
+
response.status.should == 200
|
127
|
+
json_response['order']['item_total'].to_f.should_not == order.item_total.to_f
|
128
|
+
end
|
129
|
+
|
123
130
|
context "with a line item" do
|
124
131
|
before do
|
125
132
|
order.line_items << create(:line_item)
|
@@ -158,12 +165,26 @@ module Spree
|
|
158
165
|
context "as an admin" do
|
159
166
|
sign_in_as_admin!
|
160
167
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
168
|
+
context "with two orders" do
|
169
|
+
before { create(:order) }
|
170
|
+
|
171
|
+
it "can view all orders" do
|
172
|
+
api_get :index
|
173
|
+
json_response["orders"].first.should have_attributes(attributes)
|
174
|
+
json_response["count"].should == 2
|
175
|
+
json_response["current_page"].should == 1
|
176
|
+
json_response["pages"].should == 1
|
177
|
+
end
|
178
|
+
|
179
|
+
# Test for #1763
|
180
|
+
it "can control the page size through a parameter" do
|
181
|
+
api_get :index, :per_page => 1
|
182
|
+
json_response["orders"].count.should == 1
|
183
|
+
json_response["orders"].first.should have_attributes(attributes)
|
184
|
+
json_response["count"].should == 1
|
185
|
+
json_response["current_page"].should == 1
|
186
|
+
json_response["pages"].should == 2
|
187
|
+
end
|
167
188
|
end
|
168
189
|
|
169
190
|
context "can cancel an order" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70233810562560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.1.
|
21
|
+
version: 1.1.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70233810562560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spree_auth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70233810547020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.1.
|
32
|
+
version: 1.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70233810547020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rabl
|
38
|
-
requirement: &
|
38
|
+
requirement: &70233810543540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70233810543540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &70233810540440 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - =
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.9.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70233810540440
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: database_cleaner
|
60
|
-
requirement: &
|
60
|
+
requirement: &70233810539000 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70233810539000
|
69
69
|
description: Spree's API
|
70
70
|
email:
|
71
71
|
- ryan@spreecommerce.com
|
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash:
|
195
|
+
hash: 1403657834469964020
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
none: false
|
198
198
|
requirements:
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
segments:
|
203
203
|
- 0
|
204
|
-
hash:
|
204
|
+
hash: 1403657834469964020
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
207
|
rubygems_version: 1.8.10
|