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.
@@ -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)
@@ -20,6 +20,7 @@ module Spree
20
20
 
21
21
  def create
22
22
  authorize! :create, Product
23
+ params[:product][:available_on] ||= Time.now
23
24
  @product = Product.new(params[:product])
24
25
  if @product.save
25
26
  render :show, :status => 201
@@ -2,6 +2,6 @@ object false
2
2
  child(@orders) do
3
3
  attributes *order_attributes
4
4
  end
5
- node(:count) { @orders.total_count }
5
+ node(:count) { @orders.count }
6
6
  node(:current_page) { params[:page] || 1 }
7
7
  node(:pages) { @orders.num_pages }
@@ -16,6 +16,7 @@ module Spree
16
16
  include ActionController::MimeResponds
17
17
 
18
18
  include CanCan::ControllerAdditions
19
+ prepend_view_path Rails.root + "app/views"
19
20
  append_view_path File.expand_path("../../../app/views", File.dirname(__FILE__))
20
21
 
21
22
  respond_to :json
@@ -20,3 +20,5 @@ module Spree
20
20
  end
21
21
  end
22
22
  end
23
+
24
+
@@ -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
- it "can view all orders" do
162
- api_get :index
163
- json_response["orders"].first.should have_attributes(attributes)
164
- json_response["count"].should == 1
165
- json_response["current_page"].should == 1
166
- json_response["pages"].should == 1
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.2
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-05 00:00:00.000000000 Z
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: &70257645516340 !ruby/object:Gem::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.2
21
+ version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70257645516340
24
+ version_requirements: *70233810562560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: spree_auth
27
- requirement: &70257647891920 !ruby/object:Gem::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.2
32
+ version: 1.1.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70257647891920
35
+ version_requirements: *70233810547020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rabl
38
- requirement: &70257647891460 !ruby/object:Gem::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: *70257647891460
46
+ version_requirements: *70233810543540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &70257647891000 !ruby/object:Gem::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: *70257647891000
57
+ version_requirements: *70233810540440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: database_cleaner
60
- requirement: &70257647890620 !ruby/object:Gem::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: *70257647890620
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: 4073779173415813189
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: 4073779173415813189
204
+ hash: 1403657834469964020
205
205
  requirements: []
206
206
  rubyforge_project:
207
207
  rubygems_version: 1.8.10