spree_api 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/base_controller.rb +2 -2
  3. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  4. data/app/controllers/spree/api/shipments_controller.rb +2 -2
  5. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  6. data/app/helpers/spree/api/api_helpers.rb +0 -2
  7. data/app/views/spree/api/shipments/small.v1.rabl +4 -0
  8. data/app/views/spree/api/variants/small.v1.rabl +2 -0
  9. data/lib/spree/api/testing_support/helpers.rb +6 -6
  10. data/lib/spree/api/testing_support/setup.rb +2 -2
  11. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  12. data/spec/controllers/spree/api/base_controller_spec.rb +20 -20
  13. data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
  14. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  15. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  16. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  17. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  18. data/spec/controllers/spree/api/images_controller_spec.rb +11 -11
  19. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  20. data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
  21. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  22. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  23. data/spec/controllers/spree/api/orders_controller_spec.rb +170 -132
  24. data/spec/controllers/spree/api/payments_controller_spec.rb +46 -46
  25. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  26. data/spec/controllers/spree/api/products_controller_spec.rb +67 -67
  27. data/spec/controllers/spree/api/promotion_application_spec.rb +11 -11
  28. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  29. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +40 -40
  30. data/spec/controllers/spree/api/shipments_controller_spec.rb +53 -30
  31. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  32. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  33. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  34. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  35. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  36. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  37. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  38. data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
  39. data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
  40. data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
  41. data/spec/models/spree/legacy_user_spec.rb +5 -5
  42. data/spec/requests/rabl_cache_spec.rb +9 -9
  43. data/spec/spec_helper.rb +0 -1
  44. metadata +4 -4
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::ZonesController do
4
+ describe Api::ZonesController, :type => :controller do
5
5
  render_views
6
6
 
7
7
  let!(:attributes) { [:id, :name, :zone_members] }
@@ -13,29 +13,29 @@ module Spree
13
13
 
14
14
  it "gets list of zones" do
15
15
  api_get :index
16
- json_response['zones'].first.should have_attributes(attributes)
16
+ expect(json_response['zones'].first).to have_attributes(attributes)
17
17
  end
18
18
 
19
19
  it 'can control the page size through a parameter' do
20
20
  create(:zone)
21
21
  api_get :index, :per_page => 1
22
- json_response['count'].should == 1
23
- json_response['current_page'].should == 1
24
- json_response['pages'].should == 2
22
+ expect(json_response['count']).to eq(1)
23
+ expect(json_response['current_page']).to eq(1)
24
+ expect(json_response['pages']).to eq(2)
25
25
  end
26
26
 
27
27
  it 'can query the results through a paramter' do
28
28
  expected_result = create(:zone, :name => 'South America')
29
29
  api_get :index, :q => { :name_cont => 'south' }
30
- json_response['count'].should == 1
31
- json_response['zones'].first['name'].should eq expected_result.name
30
+ expect(json_response['count']).to eq(1)
31
+ expect(json_response['zones'].first['name']).to eq expected_result.name
32
32
  end
33
33
 
34
34
  it "gets a zone" do
35
35
  api_get :show, :id => @zone.id
36
- json_response.should have_attributes(attributes)
37
- json_response['name'].should eq @zone.name
38
- json_response['zone_members'].size.should eq @zone.zone_members.count
36
+ expect(json_response).to have_attributes(attributes)
37
+ expect(json_response['name']).to eq @zone.name
38
+ expect(json_response['zone_members'].size).to eq @zone.zone_members.count
39
39
  end
40
40
 
41
41
  context "specifying a rabl template to use" do
@@ -50,13 +50,13 @@ module Spree
50
50
  it "uses the specified template" do
51
51
  request.headers['X-Spree-Template'] = 'show'
52
52
  api_get :custom_show, :id => @zone.id
53
- response.should render_template('spree/api/zones/show')
53
+ expect(response).to render_template('spree/api/zones/show')
54
54
  end
55
55
 
56
56
  it "falls back to the default template if the specified template does not exist" do
57
57
  request.headers['X-Spree-Template'] = 'invoice'
58
58
  api_get :show, :id => @zone.id
59
- response.should render_template('spree/api/zones/show')
59
+ expect(response).to render_template('spree/api/zones/show')
60
60
  end
61
61
  end
62
62
 
@@ -77,9 +77,9 @@ module Spree
77
77
  }
78
78
 
79
79
  api_post :create, params
80
- response.status.should == 201
81
- json_response.should have_attributes(attributes)
82
- json_response["zone_members"].should_not be_empty
80
+ expect(response.status).to eq(201)
81
+ expect(json_response).to have_attributes(attributes)
82
+ expect(json_response["zone_members"]).not_to be_empty
83
83
  end
84
84
 
85
85
  it "updates a zone" do
@@ -96,15 +96,15 @@ module Spree
96
96
  }
97
97
 
98
98
  api_put :update, params
99
- response.status.should == 200
100
- json_response['name'].should eq 'North Pole'
101
- json_response['zone_members'].should_not be_blank
99
+ expect(response.status).to eq(200)
100
+ expect(json_response['name']).to eq 'North Pole'
101
+ expect(json_response['zone_members']).not_to be_blank
102
102
  end
103
103
 
104
104
  it "can delete a zone" do
105
105
  api_delete :destroy, :id => @zone.id
106
- response.status.should == 204
107
- lambda { @zone.reload }.should raise_error(ActiveRecord::RecordNotFound)
106
+ expect(response.status).to eq(204)
107
+ expect { @zone.reload }.to raise_error(ActiveRecord::RecordNotFound)
108
108
  end
109
109
  end
110
110
  end
@@ -1,19 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe LegacyUser do
4
+ describe LegacyUser, :type => :model do
5
5
  let(:user) { LegacyUser.new }
6
6
 
7
7
  it "can generate an API key" do
8
- user.should_receive(:save!)
8
+ expect(user).to receive(:save!)
9
9
  user.generate_spree_api_key!
10
- user.spree_api_key.should_not be_blank
10
+ expect(user.spree_api_key).not_to be_blank
11
11
  end
12
12
 
13
13
  it "can clear an API key" do
14
- user.should_receive(:save!)
14
+ expect(user).to receive(:save!)
15
15
  user.clear_spree_api_key!
16
- user.spree_api_key.should be_blank
16
+ expect(user.spree_api_key).to be_blank
17
17
  end
18
18
  end
19
19
  end
@@ -1,32 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Rabl Cache", :caching => true do
3
+ describe "Rabl Cache", :type => :request, :caching => true do
4
4
  let!(:user) { create(:admin_user) }
5
5
 
6
6
  before do
7
7
  create(:variant)
8
8
  user.generate_spree_api_key!
9
- Spree::Product.count.should == 1
9
+ expect(Spree::Product.count).to eq(1)
10
10
  end
11
11
 
12
12
  it "doesn't create a cache key collision for models with different rabl templates" do
13
13
  get "/api/variants", :token => user.spree_api_key
14
- response.status.should == 200
14
+ expect(response.status).to eq(200)
15
15
 
16
16
  # Make sure we get a non master variant
17
17
  variant_a = JSON.parse(response.body)['variants'].select do |v|
18
18
  !v['is_master']
19
19
  end.first
20
20
 
21
- variant_a['is_master'].should be false
22
- variant_a['stock_items'].should_not be_nil
21
+ expect(variant_a['is_master']).to be false
22
+ expect(variant_a['stock_items']).not_to be_nil
23
23
 
24
24
  get "/api/products/#{Spree::Product.first.id}", :token => user.spree_api_key
25
- response.status.should == 200
25
+ expect(response.status).to eq(200)
26
26
  variant_b = JSON.parse(response.body)['variants'].last
27
- variant_b['is_master'].should be false
27
+ expect(variant_b['is_master']).to be false
28
28
 
29
- variant_a['id'].should == variant_b['id']
30
- variant_b['stock_items'].should be_nil
29
+ expect(variant_a['id']).to eq(variant_b['id'])
30
+ expect(variant_b['stock_items']).to be_nil
31
31
  end
32
32
  end
data/spec/spec_helper.rb CHANGED
@@ -22,7 +22,6 @@ rescue LoadError
22
22
  end
23
23
 
24
24
  require 'rspec/rails'
25
- require 'rspec/autorun'
26
25
  require 'ffaker'
27
26
 
28
27
  # Requires supporting ruby files with custom matchers and macros, etc,
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.4
4
+ version: 2.3.5
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-10-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.3.4
19
+ version: 2.3.5
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.4
26
+ version: 2.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement