spree_api 2.3.13 → 2.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -43
  3. data/Gemfile +1 -1
  4. data/app/controllers/spree/api/addresses_controller.rb +1 -1
  5. data/app/controllers/spree/api/base_controller.rb +22 -9
  6. data/app/controllers/spree/api/checkouts_controller.rb +2 -2
  7. data/app/controllers/spree/api/countries_controller.rb +2 -2
  8. data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
  9. data/app/controllers/spree/api/images_controller.rb +5 -0
  10. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  11. data/app/controllers/spree/api/line_items_controller.rb +7 -7
  12. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  13. data/app/controllers/spree/api/orders_controller.rb +17 -6
  14. data/app/controllers/spree/api/payments_controller.rb +3 -11
  15. data/app/controllers/spree/api/product_properties_controller.rb +2 -2
  16. data/app/controllers/spree/api/promotions_controller.rb +26 -0
  17. data/app/controllers/spree/api/properties_controller.rb +1 -1
  18. data/app/controllers/spree/api/return_authorizations_controller.rb +0 -10
  19. data/app/controllers/spree/api/shipments_controller.rb +71 -4
  20. data/app/controllers/spree/api/states_controller.rb +3 -3
  21. data/app/controllers/spree/api/stock_items_controller.rb +1 -1
  22. data/app/controllers/spree/api/stock_movements_controller.rb +1 -1
  23. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  24. data/app/controllers/spree/api/variants_controller.rb +1 -2
  25. data/app/helpers/spree/api/api_helpers.rb +19 -5
  26. data/app/views/spree/api/images/index.v1.rabl +4 -0
  27. data/app/views/spree/api/products/show.v1.rabl +4 -1
  28. data/app/views/spree/api/promotions/handler.v1.rabl +2 -1
  29. data/app/views/spree/api/promotions/show.v1.rabl +2 -0
  30. data/app/views/spree/api/shipments/big.v1.rabl +48 -0
  31. data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
  32. data/app/views/spree/api/shipments/small.v1.rabl +1 -5
  33. data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -2
  34. data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
  35. data/app/views/spree/api/variants/big.v1.rabl +6 -1
  36. data/app/views/spree/api/variants/show.v1.rabl +1 -1
  37. data/app/views/spree/api/variants/small.v1.rabl +2 -3
  38. data/config/routes.rb +9 -0
  39. data/lib/spree/api/responders/rabl_template.rb +1 -1
  40. data/lib/spree/api/testing_support/helpers.rb +6 -6
  41. data/lib/spree/api/testing_support/setup.rb +2 -2
  42. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  43. data/spec/controllers/spree/api/base_controller_spec.rb +66 -19
  44. data/spec/controllers/spree/api/checkouts_controller_spec.rb +54 -54
  45. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  46. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  47. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  48. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  49. data/spec/controllers/spree/api/images_controller_spec.rb +37 -11
  50. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  51. data/spec/controllers/spree/api/line_items_controller_spec.rb +34 -35
  52. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  53. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  54. data/spec/controllers/spree/api/orders_controller_spec.rb +177 -161
  55. data/spec/controllers/spree/api/payments_controller_spec.rb +52 -89
  56. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  57. data/spec/controllers/spree/api/products_controller_spec.rb +103 -60
  58. data/spec/controllers/spree/api/promotion_application_spec.rb +14 -12
  59. data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
  60. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  61. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +42 -66
  62. data/spec/controllers/spree/api/shipments_controller_spec.rb +69 -21
  63. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  64. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  65. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  66. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  67. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  68. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  69. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  70. data/spec/controllers/spree/api/users_controller_spec.rb +41 -41
  71. data/spec/controllers/spree/api/variants_controller_spec.rb +47 -37
  72. data/spec/controllers/spree/api/zones_controller_spec.rb +40 -18
  73. data/spec/models/spree/legacy_user_spec.rb +5 -5
  74. data/spec/requests/rabl_cache_spec.rb +9 -9
  75. data/spec/spec_helper.rb +1 -0
  76. metadata +14 -9
  77. data/spec/requests/ransackable_attributes_spec.rb +0 -79
@@ -1,51 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::UsersController, :type => :controller do
4
+ describe Api::UsersController do
5
5
  render_views
6
6
 
7
- let(:user) { create(:user, spree_api_key: rand.to_s) }
7
+ let(:user) { create(:user) }
8
8
  let(:stranger) { create(:user, :email => 'stranger@example.com') }
9
9
  let(:attributes) { [:id, :email, :created_at, :updated_at] }
10
10
 
11
+ before { stub_authentication! }
12
+
11
13
  context "as a normal user" do
14
+ before do
15
+ controller.stub :try_spree_current_user => user
16
+ end
17
+
12
18
  it "can get own details" do
13
- api_get :show, id: user.id, token: user.spree_api_key
19
+ api_get :show, :id => user.id
14
20
 
15
- expect(json_response['email']).to eq user.email
21
+ json_response['email'].should eq user.email
16
22
  end
17
23
 
18
24
  it "cannot get other users details" do
19
- api_get :show, id: stranger.id, token: user.spree_api_key
25
+ api_get :show, :id => stranger.id
20
26
 
21
27
  assert_not_found!
22
28
  end
23
29
 
24
30
  it "can learn how to create a new user" do
25
- api_get :new, token: user.spree_api_key
26
- expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
31
+ api_get :new
32
+ json_response["attributes"].should == attributes.map(&:to_s)
27
33
  end
28
34
 
29
35
  it "can create a new user" do
30
- user_params = {
31
- :email => 'new@example.com', :password => 'spree123', :password_confirmation => 'spree123'
32
- }
33
-
34
- api_post :create, :user => user_params, token: user.spree_api_key
35
- expect(json_response['email']).to eq 'new@example.com'
36
+ api_post :create, :user => { :email => 'new@example.com', :password => 'spree123', :password_confirmation => 'spree123' }
37
+ json_response['email'].should eq 'new@example.com'
36
38
  end
37
39
 
38
40
  # there's no validations on LegacyUser?
39
41
  xit "cannot create a new user with invalid attributes" do
40
- api_post :create, :user => {}, token: user.spree_api_key
41
- expect(response.status).to eq(422)
42
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
42
+ api_post :create, :user => {}
43
+ response.status.should == 422
44
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
43
45
  errors = json_response["errors"]
44
46
  end
45
47
 
46
48
  it "can update own details" do
47
49
  country = create(:country)
48
- api_put :update, id: user.id, token: user.spree_api_key, user: {
50
+ api_put :update, id: user.id, user: {
49
51
  email: "mine@example.com",
50
52
  bill_address_attributes: {
51
53
  first_name: 'First',
@@ -74,78 +76,76 @@ module Spree
74
76
  end
75
77
 
76
78
  it "cannot update other users details" do
77
- api_put :update, id: stranger.id, token: user.spree_api_key, user: { :email => "mine@example.com" }
79
+ api_put :update, :id => stranger.id, :user => { :email => "mine@example.com" }
78
80
  assert_not_found!
79
81
  end
80
82
 
81
83
  it "can delete itself" do
82
- api_delete :destroy, id: user.id, token: user.spree_api_key
83
- expect(response.status).to eq(204)
84
+ api_delete :destroy, :id => user.id
85
+ response.status.should == 204
84
86
  end
85
87
 
86
88
  it "cannot delete other user" do
87
- api_delete :destroy, id: stranger.id, token: user.spree_api_key
89
+ api_delete :destroy, :id => stranger.id
88
90
  assert_not_found!
89
91
  end
90
92
 
91
93
  it "should only get own details on index" do
92
94
  2.times { create(:user) }
93
- api_get :index, token: user.spree_api_key
95
+ api_get :index
94
96
 
95
- expect(Spree.user_class.count).to eq 3
96
- expect(json_response['count']).to eq 1
97
- expect(json_response['users'].size).to eq 1
97
+ Spree.user_class.count.should eq 3
98
+ json_response['count'].should eq 1
99
+ json_response['users'].size.should eq 1
98
100
  end
99
101
  end
100
102
 
101
103
  context "as an admin" do
102
- before { stub_authentication! }
103
-
104
104
  sign_in_as_admin!
105
105
 
106
106
  it "gets all users" do
107
- allow(Spree::LegacyUser).to receive(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
107
+ Spree::LegacyUser.stub(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
108
108
 
109
109
  2.times { create(:user) }
110
110
 
111
111
  api_get :index
112
- expect(Spree.user_class.count).to eq 2
113
- expect(json_response['count']).to eq 2
114
- expect(json_response['users'].size).to eq 2
112
+ Spree.user_class.count.should eq 2
113
+ json_response['count'].should eq 2
114
+ json_response['users'].size.should eq 2
115
115
  end
116
116
 
117
117
  it 'can control the page size through a parameter' do
118
118
  2.times { create(:user) }
119
119
  api_get :index, :per_page => 1
120
- expect(json_response['count']).to eq(1)
121
- expect(json_response['current_page']).to eq(1)
122
- expect(json_response['pages']).to eq(2)
120
+ json_response['count'].should == 1
121
+ json_response['current_page'].should == 1
122
+ json_response['pages'].should == 2
123
123
  end
124
124
 
125
125
  it 'can query the results through a paramter' do
126
126
  expected_result = create(:user, :email => 'brian@spreecommerce.com')
127
127
  api_get :index, :q => { :email_cont => 'brian' }
128
- expect(json_response['count']).to eq(1)
129
- expect(json_response['users'].first['email']).to eq expected_result.email
128
+ json_response['count'].should == 1
129
+ json_response['users'].first['email'].should eq expected_result.email
130
130
  end
131
131
 
132
132
  it "can create" do
133
133
  api_post :create, :user => { :email => "new@example.com", :password => 'spree123', :password_confirmation => 'spree123' }
134
- expect(json_response).to have_attributes(attributes)
135
- expect(response.status).to eq(201)
134
+ json_response.should have_attributes(attributes)
135
+ response.status.should == 201
136
136
  end
137
137
 
138
138
  it "can destroy user without orders" do
139
139
  user.orders.destroy_all
140
140
  api_delete :destroy, :id => user.id
141
- expect(response.status).to eq(204)
141
+ response.status.should == 204
142
142
  end
143
143
 
144
144
  it "cannot destroy user with orders" do
145
145
  create(:completed_order_with_totals, :user => user)
146
146
  api_delete :destroy, :id => user.id
147
- expect(json_response["exception"]).to eq "Spree::Core::DestroyWithOrdersError"
148
- expect(response.status).to eq(422)
147
+ json_response["exception"].should eq "Spree::Core::DestroyWithOrdersError"
148
+ response.status.should == 422
149
149
  end
150
150
 
151
151
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::VariantsController, :type => :controller do
4
+ describe Api::VariantsController do
5
5
  render_views
6
6
 
7
7
  let!(:product) { create(:product) }
@@ -22,32 +22,32 @@ module Spree
22
22
  it "can see a paginated list of variants" do
23
23
  api_get :index
24
24
  first_variant = json_response["variants"].first
25
- expect(first_variant).to have_attributes(show_attributes)
26
- expect(first_variant["stock_items"]).to be_present
27
- expect(json_response["count"]).to eq(1)
28
- expect(json_response["current_page"]).to eq(1)
29
- expect(json_response["pages"]).to eq(1)
25
+ first_variant.should have_attributes(show_attributes)
26
+ first_variant["stock_items"].should be_present
27
+ json_response["count"].should == 1
28
+ json_response["current_page"].should == 1
29
+ json_response["pages"].should == 1
30
30
  end
31
31
 
32
32
  it 'can control the page size through a parameter' do
33
33
  create(:variant)
34
34
  api_get :index, :per_page => 1
35
- expect(json_response['count']).to eq(1)
36
- expect(json_response['current_page']).to eq(1)
37
- expect(json_response['pages']).to eq(3)
35
+ json_response['count'].should == 1
36
+ json_response['current_page'].should == 1
37
+ json_response['pages'].should == 3
38
38
  end
39
39
 
40
- it 'can query the results through a paramter' do
40
+ it 'can query the results through a parameter' do
41
41
  expected_result = create(:variant, :sku => 'FOOBAR')
42
42
  api_get :index, :q => { :sku_cont => 'FOO' }
43
- expect(json_response['count']).to eq(1)
44
- expect(json_response['variants'].first['sku']).to eq expected_result.sku
43
+ json_response['count'].should == 1
44
+ json_response['variants'].first['sku'].should eq expected_result.sku
45
45
  end
46
46
 
47
47
  it "variants returned contain option values data" do
48
48
  api_get :index
49
49
  option_values = json_response["variants"].last["option_values"]
50
- expect(option_values.first).to have_attributes([:name,
50
+ option_values.first.should have_attributes([:name,
51
51
  :presentation,
52
52
  :option_type_name,
53
53
  :option_type_id])
@@ -58,8 +58,8 @@ module Spree
58
58
 
59
59
  api_get :index
60
60
 
61
- expect(json_response["variants"].last).to have_attributes([:images])
62
- expect(json_response['variants'].first['images'].first).to have_attributes([:attachment_file_name,
61
+ json_response["variants"].last.should have_attributes([:images])
62
+ json_response['variants'].first['images'].first.should have_attributes([:attachment_file_name,
63
63
  :attachment_width,
64
64
  :attachment_height,
65
65
  :attachment_content_type,
@@ -70,6 +70,11 @@ module Spree
70
70
 
71
71
  end
72
72
 
73
+ it 'variants returned do not contain cost price data' do
74
+ api_get :index
75
+ expect(json_response["variants"].first.has_key?(:cost_price)).to eq false
76
+ end
77
+
73
78
  # Regression test for #2141
74
79
  context "a deleted variant" do
75
80
  before do
@@ -78,12 +83,12 @@ module Spree
78
83
 
79
84
  it "is not returned in the results" do
80
85
  api_get :index
81
- expect(json_response["variants"].count).to eq(0)
86
+ json_response["variants"].count.should == 0
82
87
  end
83
88
 
84
89
  it "is not returned even when show_deleted is passed" do
85
90
  api_get :index, :show_deleted => true
86
- expect(json_response["variants"].count).to eq(0)
91
+ json_response["variants"].count.should == 0
87
92
  end
88
93
  end
89
94
 
@@ -91,19 +96,19 @@ module Spree
91
96
  it "can select the next page of variants" do
92
97
  second_variant = create(:variant)
93
98
  api_get :index, :page => 2, :per_page => 1
94
- expect(json_response["variants"].first).to have_attributes(show_attributes)
95
- expect(json_response["total_count"]).to eq(3)
96
- expect(json_response["current_page"]).to eq(2)
97
- expect(json_response["pages"]).to eq(3)
99
+ json_response["variants"].first.should have_attributes(show_attributes)
100
+ json_response["total_count"].should == 3
101
+ json_response["current_page"].should == 2
102
+ json_response["pages"].should == 3
98
103
  end
99
104
  end
100
105
 
101
106
  it "can see a single variant" do
102
107
  api_get :show, :id => variant.to_param
103
- expect(json_response).to have_attributes(show_attributes)
104
- expect(json_response["stock_items"]).to be_present
108
+ json_response.should have_attributes(show_attributes)
109
+ json_response["stock_items"].should be_present
105
110
  option_values = json_response["option_values"]
106
- expect(option_values.first).to have_attributes([:name,
111
+ option_values.first.should have_attributes([:name,
107
112
  :presentation,
108
113
  :option_type_name,
109
114
  :option_type_id])
@@ -114,9 +119,9 @@ module Spree
114
119
 
115
120
  api_get :show, :id => variant.to_param
116
121
 
117
- expect(json_response).to have_attributes(show_attributes + [:images])
122
+ json_response.should have_attributes(show_attributes + [:images])
118
123
  option_values = json_response["option_values"]
119
- expect(option_values.first).to have_attributes([:name,
124
+ option_values.first.should have_attributes([:name,
120
125
  :presentation,
121
126
  :option_type_name,
122
127
  :option_type_id])
@@ -124,8 +129,8 @@ module Spree
124
129
 
125
130
  it "can learn how to create a new variant" do
126
131
  api_get :new
127
- expect(json_response["attributes"]).to eq(new_attributes.map(&:to_s))
128
- expect(json_response["required_attributes"]).to be_empty
132
+ json_response["attributes"].should == new_attributes.map(&:to_s)
133
+ json_response["required_attributes"].should be_empty
129
134
  end
130
135
 
131
136
  it "cannot create a new variant if not an admin" do
@@ -141,7 +146,7 @@ module Spree
141
146
  it "cannot delete a variant" do
142
147
  api_delete :destroy, :id => variant.to_param
143
148
  assert_not_found!
144
- expect { variant.reload }.not_to raise_error
149
+ lambda { variant.reload }.should_not raise_error
145
150
  end
146
151
 
147
152
  context "as an admin" do
@@ -156,28 +161,33 @@ module Spree
156
161
 
157
162
  it "are visible by admin" do
158
163
  api_get :index, :show_deleted => 1
159
- expect(json_response["variants"].count).to eq(1)
164
+ json_response["variants"].count.should == 1
160
165
  end
161
166
  end
162
167
 
163
168
  it "can create a new variant" do
164
169
  api_post :create, :variant => { :sku => "12345" }
165
- expect(json_response).to have_attributes(new_attributes)
166
- expect(response.status).to eq(201)
167
- expect(json_response["sku"]).to eq("12345")
170
+ json_response.should have_attributes(new_attributes)
171
+ response.status.should == 201
172
+ json_response["sku"].should == "12345"
168
173
 
169
- expect(variant.product.variants.count).to eq(1)
174
+ variant.product.variants.count.should == 1
170
175
  end
171
176
 
172
177
  it "can update a variant" do
173
178
  api_put :update, :id => variant.to_param, :variant => { :sku => "12345" }
174
- expect(response.status).to eq(200)
179
+ response.status.should == 200
175
180
  end
176
181
 
177
182
  it "can delete a variant" do
178
183
  api_delete :destroy, :id => variant.to_param
179
- expect(response.status).to eq(204)
180
- expect { Spree::Variant.find(variant.id) }.to raise_error(ActiveRecord::RecordNotFound)
184
+ response.status.should == 204
185
+ lambda { Spree::Variant.find(variant.id) }.should raise_error(ActiveRecord::RecordNotFound)
186
+ end
187
+
188
+ it 'variants returned contain cost price data' do
189
+ api_get :index
190
+ expect(json_response["variants"].first.has_key?(:cost_price)).to eq true
181
191
  end
182
192
  end
183
193
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::ZonesController, :type => :controller do
4
+ describe Api::ZonesController do
5
5
  render_views
6
6
 
7
7
  let!(:attributes) { [:id, :name, :zone_members] }
@@ -13,29 +13,51 @@ module Spree
13
13
 
14
14
  it "gets list of zones" do
15
15
  api_get :index
16
- expect(json_response['zones'].first).to have_attributes(attributes)
16
+ json_response['zones'].first.should 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
- expect(json_response['count']).to eq(1)
23
- expect(json_response['current_page']).to eq(1)
24
- expect(json_response['pages']).to eq(2)
22
+ json_response['count'].should == 1
23
+ json_response['current_page'].should == 1
24
+ json_response['pages'].should == 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
- expect(json_response['count']).to eq(1)
31
- expect(json_response['zones'].first['name']).to eq expected_result.name
30
+ json_response['count'].should == 1
31
+ json_response['zones'].first['name'].should 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
- 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
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
39
+ end
40
+
41
+ context "specifying a rabl template to use" do
42
+ before do
43
+ Spree::Api::ZonesController.class_eval do
44
+ def custom_show
45
+ respond_with(zone)
46
+ end
47
+ end
48
+ end
49
+
50
+ it "uses the specified template" do
51
+ request.headers['X-Spree-Template'] = 'show'
52
+ api_get :custom_show, :id => @zone.id
53
+ response.should render_template('spree/api/zones/show')
54
+ end
55
+
56
+ it "falls back to the default template if the specified template does not exist" do
57
+ request.headers['X-Spree-Template'] = 'invoice'
58
+ api_get :show, :id => @zone.id
59
+ response.should render_template('spree/api/zones/show')
60
+ end
39
61
  end
40
62
 
41
63
  context "as an admin" do
@@ -55,9 +77,9 @@ module Spree
55
77
  }
56
78
 
57
79
  api_post :create, params
58
- expect(response.status).to eq(201)
59
- expect(json_response).to have_attributes(attributes)
60
- expect(json_response["zone_members"]).not_to be_empty
80
+ response.status.should == 201
81
+ json_response.should have_attributes(attributes)
82
+ json_response["zone_members"].should_not be_empty
61
83
  end
62
84
 
63
85
  it "updates a zone" do
@@ -74,15 +96,15 @@ module Spree
74
96
  }
75
97
 
76
98
  api_put :update, params
77
- expect(response.status).to eq(200)
78
- expect(json_response['name']).to eq 'North Pole'
79
- expect(json_response['zone_members']).not_to be_blank
99
+ response.status.should == 200
100
+ json_response['name'].should eq 'North Pole'
101
+ json_response['zone_members'].should_not be_blank
80
102
  end
81
103
 
82
104
  it "can delete a zone" do
83
105
  api_delete :destroy, :id => @zone.id
84
- expect(response.status).to eq(204)
85
- expect { @zone.reload }.to raise_error(ActiveRecord::RecordNotFound)
106
+ response.status.should == 204
107
+ lambda { @zone.reload }.should raise_error(ActiveRecord::RecordNotFound)
86
108
  end
87
109
  end
88
110
  end
@@ -1,19 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe LegacyUser, :type => :model do
4
+ describe LegacyUser do
5
5
  let(:user) { LegacyUser.new }
6
6
 
7
7
  it "can generate an API key" do
8
- expect(user).to receive(:save!)
8
+ user.should_receive(:save!)
9
9
  user.generate_spree_api_key!
10
- expect(user.spree_api_key).not_to be_blank
10
+ user.spree_api_key.should_not be_blank
11
11
  end
12
12
 
13
13
  it "can clear an API key" do
14
- expect(user).to receive(:save!)
14
+ user.should_receive(:save!)
15
15
  user.clear_spree_api_key!
16
- expect(user.spree_api_key).to be_blank
16
+ user.spree_api_key.should 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", :type => :request, :caching => true do
3
+ describe "Rabl Cache", :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
- expect(Spree::Product.count).to eq(1)
9
+ Spree::Product.count.should == 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
- expect(response.status).to eq(200)
14
+ response.status.should == 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
- expect(variant_a['is_master']).to be false
22
- expect(variant_a['stock_items']).not_to be_nil
21
+ variant_a['is_master'].should be false
22
+ variant_a['stock_items'].should_not be_nil
23
23
 
24
24
  get "/api/products/#{Spree::Product.first.id}", :token => user.spree_api_key
25
- expect(response.status).to eq(200)
25
+ response.status.should == 200
26
26
  variant_b = JSON.parse(response.body)['variants'].last
27
- expect(variant_b['is_master']).to be false
27
+ variant_b['is_master'].should be false
28
28
 
29
- expect(variant_a['id']).to eq(variant_b['id'])
30
- expect(variant_b['stock_items']).to be_nil
29
+ variant_a['id'].should == variant_b['id']
30
+ variant_b['stock_items'].should be_nil
31
31
  end
32
32
  end
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ rescue LoadError
22
22
  end
23
23
 
24
24
  require 'rspec/rails'
25
+ require 'rspec/autorun'
25
26
  require 'ffaker'
26
27
 
27
28
  # 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.13
4
+ version: 2.4.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2014-10-09 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.13
19
+ version: 2.4.0.rc1
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.13
26
+ version: 2.4.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,7 @@ files:
80
80
  - app/controllers/spree/api/payments_controller.rb
81
81
  - app/controllers/spree/api/product_properties_controller.rb
82
82
  - app/controllers/spree/api/products_controller.rb
83
+ - app/controllers/spree/api/promotions_controller.rb
83
84
  - app/controllers/spree/api/properties_controller.rb
84
85
  - app/controllers/spree/api/return_authorizations_controller.rb
85
86
  - app/controllers/spree/api/shipments_controller.rb
@@ -109,6 +110,7 @@ files:
109
110
  - app/views/spree/api/errors/must_specify_api_key.v1.rabl
110
111
  - app/views/spree/api/errors/not_found.v1.rabl
111
112
  - app/views/spree/api/errors/unauthorized.v1.rabl
113
+ - app/views/spree/api/images/index.v1.rabl
112
114
  - app/views/spree/api/images/show.v1.rabl
113
115
  - app/views/spree/api/inventory_units/show.rabl
114
116
  - app/views/spree/api/line_items/new.v1.rabl
@@ -142,6 +144,7 @@ files:
142
144
  - app/views/spree/api/products/product.v1.rabl
143
145
  - app/views/spree/api/products/show.v1.rabl
144
146
  - app/views/spree/api/promotions/handler.v1.rabl
147
+ - app/views/spree/api/promotions/show.v1.rabl
145
148
  - app/views/spree/api/properties/index.v1.rabl
146
149
  - app/views/spree/api/properties/new.v1.rabl
147
150
  - app/views/spree/api/properties/show.v1.rabl
@@ -149,7 +152,9 @@ files:
149
152
  - app/views/spree/api/return_authorizations/new.v1.rabl
150
153
  - app/views/spree/api/return_authorizations/show.v1.rabl
151
154
  - app/views/spree/api/shared/stock_location_required.v1.rabl
155
+ - app/views/spree/api/shipments/big.v1.rabl
152
156
  - app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl
157
+ - app/views/spree/api/shipments/mine.v1.rabl
153
158
  - app/views/spree/api/shipments/show.v1.rabl
154
159
  - app/views/spree/api/shipments/small.v1.rabl
155
160
  - app/views/spree/api/shipping_rates/show.v1.rabl
@@ -215,6 +220,7 @@ files:
215
220
  - spec/controllers/spree/api/product_properties_controller_spec.rb
216
221
  - spec/controllers/spree/api/products_controller_spec.rb
217
222
  - spec/controllers/spree/api/promotion_application_spec.rb
223
+ - spec/controllers/spree/api/promotions_controller_spec.rb
218
224
  - spec/controllers/spree/api/properties_controller_spec.rb
219
225
  - spec/controllers/spree/api/return_authorizations_controller_spec.rb
220
226
  - spec/controllers/spree/api/shipments_controller_spec.rb
@@ -231,7 +237,6 @@ files:
231
237
  - spec/fixtures/thinking-cat.jpg
232
238
  - spec/models/spree/legacy_user_spec.rb
233
239
  - spec/requests/rabl_cache_spec.rb
234
- - spec/requests/ransackable_attributes_spec.rb
235
240
  - spec/shared_examples/protect_product_actions.rb
236
241
  - spec/spec_helper.rb
237
242
  - spec/support/controller_hacks.rb
@@ -252,12 +257,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
257
  version: '0'
253
258
  required_rubygems_version: !ruby/object:Gem::Requirement
254
259
  requirements:
255
- - - ">="
260
+ - - ">"
256
261
  - !ruby/object:Gem::Version
257
- version: '0'
262
+ version: 1.3.1
258
263
  requirements: []
259
264
  rubyforge_project:
260
- rubygems_version: 2.4.5
265
+ rubygems_version: 2.2.2
261
266
  signing_key:
262
267
  specification_version: 4
263
268
  summary: Spree's API
@@ -279,6 +284,7 @@ test_files:
279
284
  - spec/controllers/spree/api/product_properties_controller_spec.rb
280
285
  - spec/controllers/spree/api/products_controller_spec.rb
281
286
  - spec/controllers/spree/api/promotion_application_spec.rb
287
+ - spec/controllers/spree/api/promotions_controller_spec.rb
282
288
  - spec/controllers/spree/api/properties_controller_spec.rb
283
289
  - spec/controllers/spree/api/return_authorizations_controller_spec.rb
284
290
  - spec/controllers/spree/api/shipments_controller_spec.rb
@@ -295,7 +301,6 @@ test_files:
295
301
  - spec/fixtures/thinking-cat.jpg
296
302
  - spec/models/spree/legacy_user_spec.rb
297
303
  - spec/requests/rabl_cache_spec.rb
298
- - spec/requests/ransackable_attributes_spec.rb
299
304
  - spec/shared_examples/protect_product_actions.rb
300
305
  - spec/spec_helper.rb
301
306
  - spec/support/controller_hacks.rb