spree_api 2.4.0.rc3 → 2.4.0

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: b712d43706678d3c8d2bdc20f8d43fff8c97bd2e
4
- data.tar.gz: cd84829e4d96b32d0da411588a7531b6855668a4
3
+ metadata.gz: 2bebe4795d7751605292a86a15274c44a7c09ffc
4
+ data.tar.gz: b062e7c4ab428d02d25ffdfaf5f18b25d046ddf1
5
5
  SHA512:
6
- metadata.gz: ba4fb81a81896f4851cc69fd23a3816b77ef4b8ec7f484cb08dcfbc78a39a9ce136d3b64bcce8610a97b34a497e259b8a2e8724af4fad664d73bbf426acb1218
7
- data.tar.gz: 8be64b301511026a1b6c22f938a1dc7d42b8ea651c65c70ba180a07437ae7be511decfdac3c5327d1480b0e8fe14bb2e081162fc59e10d027c79defd19bc432c
6
+ metadata.gz: 4f5db8d5263f27997792eb1e719df569caaa66cbb92f9a315df7fe545ffaffad417b1398d9f0051e2697dbe07f32edd1912fd16db16a3ed7e2ee7a992afb032c
7
+ data.tar.gz: 7570289fbe966a629e81c814e18c0a27205c25176e74df4b54794b2217041118d6cc3162f3d3e37797007ce4a72458f85464a72166666dd9eb1cacdc84d7df3e
@@ -101,8 +101,8 @@ module Spree
101
101
 
102
102
  error_notifier.call(exception, self) if error_notifier
103
103
 
104
- render :text => { :exception => exception.message }.to_json,
105
- :status => 422 and return
104
+ render text: { exception: exception.message }.to_json,
105
+ status: 422 and return
106
106
  end
107
107
 
108
108
  def gateway_error(exception)
@@ -24,7 +24,7 @@ module Spree
24
24
 
25
25
  def destroy
26
26
  @line_item = find_line_item
27
- variant = Spree::Variant.find(@line_item.variant_id)
27
+ variant = Spree::Variant.unscoped.find(@line_item.variant_id)
28
28
  @order.contents.remove(variant, @line_item.quantity)
29
29
  respond_with(@line_item, status: 204)
30
30
  end
@@ -53,4 +53,4 @@ module Spree
53
53
  end
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -6,9 +6,9 @@ module Spree
6
6
  @taxons = taxonomy.root.children
7
7
  else
8
8
  if params[:ids]
9
- @taxons = Spree::Taxon.includes(:children).accessible_by(current_ability, :read).where(id: params[:ids].split(','))
9
+ @taxons = Spree::Taxon.accessible_by(current_ability, :read).where(id: params[:ids].split(','))
10
10
  else
11
- @taxons = Spree::Taxon.includes(:children).accessible_by(current_ability, :read).order(:taxonomy_id, :lft).ransack(params[:q]).result
11
+ @taxons = Spree::Taxon.accessible_by(current_ability, :read).order(:taxonomy_id, :lft).ransack(params[:q]).result
12
12
  end
13
13
  end
14
14
 
@@ -46,7 +46,3 @@ end
46
46
  node :permissions do
47
47
  { can_update: current_ability.can?(:update, root_object) }
48
48
  end
49
-
50
- child :valid_credit_cards => :credit_cards do
51
- extends "spree/api/credit_cards/show"
52
- end
@@ -22,6 +22,10 @@ child :product_properties => :product_properties do
22
22
  attributes *product_property_attributes
23
23
  end
24
24
 
25
- child :taxons => :taxons do
26
- extends "spree/api/taxons/show"
25
+ child :classifications => :classifications do
26
+ attributes :taxon_id, :position
27
+
28
+ child(:taxon) do
29
+ extends "spree/api/taxons/show"
30
+ end
27
31
  end
@@ -5,6 +5,9 @@ attributes *variant_attributes
5
5
  node(:display_price) { |p| p.display_price.to_s }
6
6
  node(:options_text) { |v| v.options_text }
7
7
  node(:in_stock) { |v| v.in_stock? }
8
+ node(:is_backorderable) { |v| v.is_backorderable? }
9
+ node(:total_on_hand) { |v| v.total_on_hand }
10
+ node(:is_destroyed) { |v| v.destroyed? }
8
11
 
9
12
  child :option_values => :option_values do
10
13
  attributes *option_value_attributes
@@ -18,14 +18,6 @@ module Spree
18
18
 
19
19
  let(:address_params) { { :country_id => Country.first.id, :state_id => State.first.id } }
20
20
 
21
- let(:billing_address) { { :firstname => "Tiago", :lastname => "Motta", :address1 => "Av Paulista",
22
- :city => "Sao Paulo", :zipcode => "35762", :phone => "12345678",
23
- :country_id => Country.first.id, :state_id => State.first.id} }
24
-
25
- let(:shipping_address) { { :firstname => "Tiago", :lastname => "Motta", :address1 => "Av Paulista",
26
- :city => "Sao Paulo", :zipcode => "35762", :phone => "12345678",
27
- :country_id => Country.first.id, :state_id => State.first.id} }
28
-
29
21
  let(:current_api_user) do
30
22
  user = Spree.user_class.new(:email => "spree@example.com")
31
23
  user.generate_spree_api_key!
@@ -167,24 +159,42 @@ module Spree
167
159
  expect(json_response["adjustments"]).to be_empty
168
160
  end
169
161
 
170
- context 'when shipment adjustments are present' do
162
+ describe 'GET #show' do
163
+ let(:order) { create :order_with_line_items }
171
164
  let(:adjustment) { FactoryGirl.create(:adjustment, order: order) }
172
165
 
166
+ subject { api_get :show, id: order.to_param }
167
+
173
168
  before do
174
169
  allow_any_instance_of(Order).to receive_messages :user => current_api_user
175
- shipment = FactoryGirl.create(:shipment, order: order)
176
- shipment.adjustments << adjustment
177
170
  end
178
171
 
179
- subject { api_get :show, :id => order.to_param }
172
+ context 'when inventory information is present' do
173
+ it 'contains stock information on variant' do
174
+ subject
175
+ variant = json_response['line_items'][0]['variant']
176
+ expect(variant).to_not be_nil
177
+ expect(variant['in_stock']).to eq(false)
178
+ expect(variant['total_on_hand']).to eq(0)
179
+ expect(variant['is_backorderable']).to eq(true)
180
+ expect(variant['is_destroyed']).to eq(false)
181
+ end
182
+ end
180
183
 
181
- it 'contains adjustments in JSON' do
182
- subject
183
- # Test to insure shipment has adjustments
184
- shipment = json_response['shipments'][0]
185
- expect(shipment).to_not be_nil
186
- expect(shipment['adjustments'][0]).not_to be_empty
187
- expect(shipment['adjustments'][0]['label']).to eq(adjustment.label)
184
+ context 'when shipment adjustments are present' do
185
+ before do
186
+ order.shipments.first.adjustments << adjustment
187
+ end
188
+
189
+ it 'contains adjustments on shipment' do
190
+ subject
191
+
192
+ # Test to insure shipment has adjustments
193
+ shipment = json_response['shipments'][0]
194
+ expect(shipment).to_not be_nil
195
+ expect(shipment['adjustments'][0]).not_to be_empty
196
+ expect(shipment['adjustments'][0]['label']).to eq(adjustment.label)
197
+ end
188
198
  end
189
199
  end
190
200
 
@@ -341,17 +351,17 @@ module Spree
341
351
  let!(:line_item) { order.contents.add(variant, 1) }
342
352
  let!(:payment_method) { create(:check_payment_method) }
343
353
 
344
- let(:address_params) { { :country_id => Country.first.id, :state_id => State.first.id } }
354
+ let(:address_params) { { :country_id => country.id } }
345
355
  let(:billing_address) { { :firstname => "Tiago", :lastname => "Motta", :address1 => "Av Paulista",
346
- :city => "Sao Paulo", :zipcode => "35762", :phone => "12345678",
347
- :country_id => Country.first.id, :state_id => State.first.id} }
356
+ :city => "Sao Paulo", :zipcode => "01310-300", :phone => "12345678",
357
+ :country_id => country.id} }
348
358
  let(:shipping_address) { { :firstname => "Tiago", :lastname => "Motta", :address1 => "Av Paulista",
349
- :city => "Sao Paulo", :zipcode => "35762", :phone => "12345678",
350
- :country_id => Country.first.id, :state_id => State.first.id} }
359
+ :city => "Sao Paulo", :zipcode => "01310-300", :phone => "12345678",
360
+ :country_id => country.id} }
361
+ let(:country) { create(:country, {name: "Brazil", iso_name: "BRAZIL", iso: "BR", iso3: "BRA", numcode: 76 })}
351
362
 
352
363
  before do
353
- allow(Spree::LineItem).to receive(:find_by_id).and_return(Spree::LineItem.new)
354
- allow_any_instance_of(Order).to receive_messages :user => current_api_user
364
+ allow_any_instance_of(Order).to receive_messages user: current_api_user
355
365
  order.next # Switch from cart to address
356
366
  order.bill_address = nil
357
367
  order.ship_address = nil
@@ -196,7 +196,8 @@ module Spree
196
196
  :product_id,
197
197
  :property_name])
198
198
 
199
- expect(json_response["taxons"].first).to have_attributes([:id, :name, :pretty_name, :permalink, :taxonomy_id, :parent_id])
199
+ expect(json_response["classifications"].first).to have_attributes([:taxon_id, :position, :taxon])
200
+ expect(json_response["classifications"].first['taxon']).to have_attributes([:id, :name, :pretty_name, :permalink, :taxonomy_id, :parent_id])
200
201
  end
201
202
 
202
203
  context "tracking is disabled" do
@@ -372,7 +373,7 @@ module Spree
372
373
  end
373
374
 
374
375
  it "cannot create a new product with invalid attributes" do
375
- api_post :create, :product => {}
376
+ api_post :create, product: {}
376
377
  expect(response.status).to eq(422)
377
378
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
378
379
  errors = json_response["errors"]
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.0.rc3
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2014-11-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.0.rc3
19
+ version: 2.4.0
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.0.rc3
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -257,9 +257,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  requirements:
260
- - - ">"
260
+ - - ">="
261
261
  - !ruby/object:Gem::Version
262
- version: 1.3.1
262
+ version: '0'
263
263
  requirements: []
264
264
  rubyforge_project:
265
265
  rubygems_version: 2.2.2