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.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/base_controller.rb +2 -2
- data/app/controllers/spree/api/option_types_controller.rb +2 -2
- data/app/controllers/spree/api/shipments_controller.rb +2 -2
- data/app/controllers/spree/api/taxons_controller.rb +1 -1
- data/app/helpers/spree/api/api_helpers.rb +0 -2
- data/app/views/spree/api/shipments/small.v1.rabl +4 -0
- data/app/views/spree/api/variants/small.v1.rabl +2 -0
- data/lib/spree/api/testing_support/helpers.rb +6 -6
- data/lib/spree/api/testing_support/setup.rb +2 -2
- data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
- data/spec/controllers/spree/api/base_controller_spec.rb +20 -20
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
- data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
- data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
- data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
- data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/images_controller_spec.rb +11 -11
- data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
- data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
- data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/orders_controller_spec.rb +170 -132
- data/spec/controllers/spree/api/payments_controller_spec.rb +46 -46
- data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/products_controller_spec.rb +67 -67
- data/spec/controllers/spree/api/promotion_application_spec.rb +11 -11
- data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +40 -40
- data/spec/controllers/spree/api/shipments_controller_spec.rb +53 -30
- data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
- data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
- data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
- data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
- data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
- data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
- data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
- data/spec/models/spree/legacy_user_spec.rb +5 -5
- data/spec/requests/rabl_cache_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -1
- 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.
|
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'].
|
23
|
-
json_response['current_page'].
|
24
|
-
json_response['pages'].
|
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'].
|
31
|
-
json_response['zones'].first['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.
|
37
|
-
json_response['name'].
|
38
|
-
json_response['zone_members'].size.
|
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.
|
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.
|
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.
|
81
|
-
json_response.
|
82
|
-
json_response["zone_members"].
|
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.
|
100
|
-
json_response['name'].
|
101
|
-
json_response['zone_members'].
|
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.
|
107
|
-
|
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.
|
8
|
+
expect(user).to receive(:save!)
|
9
9
|
user.generate_spree_api_key!
|
10
|
-
user.spree_api_key.
|
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.
|
14
|
+
expect(user).to receive(:save!)
|
15
15
|
user.clear_spree_api_key!
|
16
|
-
user.spree_api_key.
|
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.
|
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.
|
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'].
|
22
|
-
variant_a['stock_items'].
|
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.
|
25
|
+
expect(response.status).to eq(200)
|
26
26
|
variant_b = JSON.parse(response.body)['variants'].last
|
27
|
-
variant_b['is_master'].
|
27
|
+
expect(variant_b['is_master']).to be false
|
28
28
|
|
29
|
-
variant_a['id'].
|
30
|
-
variant_b['stock_items'].
|
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
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
|
+
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-
|
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.
|
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.
|
26
|
+
version: 2.3.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|