solidus_api 1.0.0.pre2 → 1.0.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solidus_api might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/base_controller.rb +4 -10
- data/app/controllers/spree/api/checkouts_controller.rb +1 -1
- data/app/controllers/spree/api/countries_controller.rb +0 -1
- data/app/controllers/spree/api/credit_cards_controller.rb +18 -1
- data/app/controllers/spree/api/orders_controller.rb +37 -50
- data/app/controllers/spree/api/states_controller.rb +0 -2
- data/app/views/spree/api/credit_cards/show.v1.rabl +4 -0
- data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
- data/config/routes.rb +2 -0
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +7 -5
- data/spec/controllers/spree/api/credit_cards_controller_spec.rb +84 -52
- data/spec/controllers/spree/api/orders_controller_spec.rb +111 -21
- data/spec/features/checkout_spec.rb +1 -0
- data/spec/support/controller_hacks.rb +0 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc84533efe45262ccaba47a9b25f28945ee08dcc
|
4
|
+
data.tar.gz: ce8a1e2811b9e94a69f0f91b9d381add04438543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4249505d8a2bcbaa5e14d799ca5d6b2d273e97c17e336eaa7c1d36ea0de088565d7508499405633b713b394f90573ad0996b00fb3ff0a9e730f6cbc6a75761cf
|
7
|
+
data.tar.gz: 4dfbe553d6a0fea7ef9434159fab80dfb0f689e56d49fec6f5da67890e3d229b15ebb66519d84ca0056c86cd3991a06729917ce65cbc682a5bc1d665b2f2e3b6
|
@@ -42,23 +42,17 @@ module Spree
|
|
42
42
|
end.with_indifferent_access
|
43
43
|
end
|
44
44
|
|
45
|
+
private
|
46
|
+
|
45
47
|
# users should be able to set price when importing orders via api
|
46
48
|
def permitted_line_item_attributes
|
47
|
-
if
|
49
|
+
if can?(:admin, Spree::LineItem)
|
48
50
|
super + admin_line_item_attributes
|
49
51
|
else
|
50
52
|
super
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
protected
|
55
|
-
|
56
|
-
def is_admin?
|
57
|
-
current_api_user && current_api_user.has_spree_role?("admin")
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
56
|
def set_content_type
|
63
57
|
content_type = case params[:format]
|
64
58
|
when "json"
|
@@ -148,7 +142,7 @@ module Spree
|
|
148
142
|
end
|
149
143
|
|
150
144
|
def product_scope
|
151
|
-
if
|
145
|
+
if can?(:admin, Spree::Product)
|
152
146
|
scope = Product.with_deleted.accessible_by(current_ability, :read).includes(*product_includes)
|
153
147
|
|
154
148
|
unless params[:show_deleted]
|
@@ -52,7 +52,7 @@ module Spree
|
|
52
52
|
authorize! :update, @order, order_token
|
53
53
|
|
54
54
|
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
|
55
|
-
if
|
55
|
+
if can?(:admin, @order) && user_id.present?
|
56
56
|
@order.associate_user!(Spree.user_class.find(user_id))
|
57
57
|
end
|
58
58
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
module Api
|
3
3
|
class CreditCardsController < Spree::Api::BaseController
|
4
|
-
before_action :user
|
4
|
+
before_action :user, only: [:index]
|
5
|
+
before_action :find_credit_card, only: [:update]
|
5
6
|
|
6
7
|
def index
|
7
8
|
@credit_cards = user
|
@@ -12,6 +13,14 @@ module Spree
|
|
12
13
|
respond_with(@credit_cards)
|
13
14
|
end
|
14
15
|
|
16
|
+
def update
|
17
|
+
if @credit_card.update_attributes(credit_card_update_params)
|
18
|
+
respond_with(@credit_card, default_template: :show)
|
19
|
+
else
|
20
|
+
invalid_resource!(@credit_card)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
15
24
|
private
|
16
25
|
|
17
26
|
def user
|
@@ -20,6 +29,14 @@ module Spree
|
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
32
|
+
def find_credit_card
|
33
|
+
@credit_card = Spree::CreditCard.find(params[:id])
|
34
|
+
authorize! :update, @credit_card
|
35
|
+
end
|
36
|
+
|
37
|
+
def credit_card_update_params
|
38
|
+
params.require(:credit_card).permit(permitted_credit_card_update_attributes)
|
39
|
+
end
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
@@ -5,14 +5,11 @@ module Spree
|
|
5
5
|
self.admin_shipment_attributes = [:shipping_method, :stock_location, :inventory_units => [:variant_id, :sku]]
|
6
6
|
|
7
7
|
class_attribute :admin_order_attributes
|
8
|
-
self.admin_order_attributes = [:import, :number, :completed_at, :locked_at, :channel]
|
8
|
+
self.admin_order_attributes = [:import, :number, :completed_at, :locked_at, :channel, :user_id]
|
9
9
|
|
10
|
-
skip_before_action :check_for_user_or_api_key, only: :apply_coupon_code
|
11
10
|
skip_before_action :authenticate_user, only: :apply_coupon_code
|
12
11
|
|
13
|
-
before_action :find_order, except: [:create, :mine, :current, :index
|
14
|
-
|
15
|
-
before_filter :find_order, except: [:create, :mine, :current, :index]
|
12
|
+
before_action :find_order, except: [:create, :mine, :current, :index]
|
16
13
|
around_filter :lock_order, except: [:create, :mine, :current, :index]
|
17
14
|
|
18
15
|
# Dynamically defines our stores checkout steps to ensure we check authorization on each step.
|
@@ -30,13 +27,14 @@ module Spree
|
|
30
27
|
|
31
28
|
def create
|
32
29
|
authorize! :create, Order
|
33
|
-
|
30
|
+
|
31
|
+
order_user = if order_params[:user_id]
|
34
32
|
Spree.user_class.find(order_params[:user_id])
|
35
33
|
else
|
36
34
|
current_api_user
|
37
35
|
end
|
38
36
|
|
39
|
-
import_params = if
|
37
|
+
import_params = if can?(:admin, Spree::Order)
|
40
38
|
params[:order].present? ? params[:order].permit! : {}
|
41
39
|
else
|
42
40
|
order_params
|
@@ -66,17 +64,9 @@ module Spree
|
|
66
64
|
def update
|
67
65
|
authorize! :update, @order, order_token
|
68
66
|
|
69
|
-
|
70
|
-
# This will update the order without a checkout reset.
|
71
|
-
@order.update_attributes(order_params)
|
72
|
-
else
|
73
|
-
# This will reset checkout back to address and delete all shipments.
|
74
|
-
@order.contents.update_cart(order_params)
|
75
|
-
end
|
76
|
-
|
77
|
-
if result
|
67
|
+
if @order.contents.update_cart(order_params)
|
78
68
|
user_id = params[:order][:user_id]
|
79
|
-
if
|
69
|
+
if can?(:admin, @order) && user_id
|
80
70
|
@order.associate_user!(Spree.user_class.find(user_id))
|
81
71
|
end
|
82
72
|
respond_with(@order, default_template: :show)
|
@@ -110,46 +100,43 @@ module Spree
|
|
110
100
|
end
|
111
101
|
|
112
102
|
private
|
113
|
-
def order_params
|
114
|
-
if params[:order]
|
115
|
-
normalize_params
|
116
|
-
params.require(:order).permit(permitted_order_attributes)
|
117
|
-
else
|
118
|
-
{}
|
119
|
-
end
|
120
|
-
end
|
121
103
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
params
|
126
|
-
|
127
|
-
|
104
|
+
def order_params
|
105
|
+
if params[:order]
|
106
|
+
normalize_params
|
107
|
+
params.require(:order).permit(permitted_order_attributes)
|
108
|
+
else
|
109
|
+
{}
|
128
110
|
end
|
111
|
+
end
|
129
112
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
113
|
+
def normalize_params
|
114
|
+
params[:order][:payments_attributes] = params[:order].delete(:payments) if params[:order][:payments]
|
115
|
+
params[:order][:shipments_attributes] = params[:order].delete(:shipments) if params[:order][:shipments]
|
116
|
+
params[:order][:line_items_attributes] = params[:order].delete(:line_items) if params[:order][:line_items]
|
117
|
+
params[:order][:ship_address_attributes] = params[:order].delete(:ship_address) if params[:order][:ship_address].present?
|
118
|
+
params[:order][:bill_address_attributes] = params[:order].delete(:bill_address) if params[:order][:bill_address].present?
|
119
|
+
end
|
137
120
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
else
|
142
|
-
super
|
143
|
-
end
|
144
|
-
end
|
121
|
+
def permitted_order_attributes
|
122
|
+
can?(:admin, Spree::Order) ? (super + admin_order_attributes) : super
|
123
|
+
end
|
145
124
|
|
146
|
-
|
147
|
-
|
125
|
+
def permitted_shipment_attributes
|
126
|
+
if can?(:admin, Spree::Shipment)
|
127
|
+
super + admin_shipment_attributes
|
128
|
+
else
|
129
|
+
super
|
148
130
|
end
|
131
|
+
end
|
149
132
|
|
150
|
-
|
151
|
-
|
152
|
-
|
133
|
+
def find_order(lock = false)
|
134
|
+
@order = Spree::Order.find_by!(number: params[:id])
|
135
|
+
end
|
136
|
+
|
137
|
+
def order_id
|
138
|
+
super || params[:id]
|
139
|
+
end
|
153
140
|
end
|
154
141
|
end
|
155
142
|
end
|
data/config/routes.rb
CHANGED
@@ -308,7 +308,13 @@ module Spree
|
|
308
308
|
context "#{action}" do
|
309
309
|
context "with order in confirm state" do
|
310
310
|
subject do
|
311
|
-
|
311
|
+
if action == :next
|
312
|
+
ActiveSupport::Deprecation.silence do
|
313
|
+
api_put action, params
|
314
|
+
end
|
315
|
+
else
|
316
|
+
api_put action, params
|
317
|
+
end
|
312
318
|
end
|
313
319
|
|
314
320
|
let(:params) { {id: order.to_param, order_token: order.guest_token} }
|
@@ -316,10 +322,6 @@ module Spree
|
|
316
322
|
|
317
323
|
before do
|
318
324
|
order.update_column(:state, "confirm")
|
319
|
-
|
320
|
-
if action == :next
|
321
|
-
#ActiveSupport::Deprecation.should_receive(:warn).once
|
322
|
-
end
|
323
325
|
end
|
324
326
|
|
325
327
|
it "can transition from confirm to complete" do
|
@@ -2,78 +2,110 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
describe Api::CreditCardsController, :type => :controller do
|
5
|
-
|
5
|
+
describe '#index' do
|
6
|
+
render_views
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
let!(:normal_user) do
|
15
|
-
user = Spree.user_class.new(:email => "spree2@example.com", :id => 2)
|
16
|
-
user.generate_spree_api_key!
|
17
|
-
user
|
18
|
-
end
|
8
|
+
let!(:admin_user) do
|
9
|
+
user = Spree.user_class.new(:email => "spree@example.com", :id => 1)
|
10
|
+
user.generate_spree_api_key!
|
11
|
+
allow(user).to receive(:has_spree_role?).with('admin').and_return(true)
|
12
|
+
user
|
13
|
+
end
|
19
14
|
|
20
|
-
|
15
|
+
let!(:normal_user) do
|
16
|
+
user = Spree.user_class.new(:email => "spree2@example.com", :id => 2)
|
17
|
+
user.generate_spree_api_key!
|
18
|
+
user
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
stub_authentication!
|
24
|
-
end
|
21
|
+
let!(:card) { create(:credit_card, :user_id => admin_user.id, gateway_customer_profile_id: "random") }
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
23
|
+
before do
|
24
|
+
stub_authentication!
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
user
|
27
|
+
it "the user id doesn't exist" do
|
28
|
+
api_get :index, user_id: 1000
|
29
|
+
expect(response.status).to eq(404)
|
35
30
|
end
|
36
31
|
|
37
|
-
|
38
|
-
|
32
|
+
context "calling user is in admin role" do
|
33
|
+
let(:current_api_user) do
|
34
|
+
user = admin_user
|
35
|
+
user
|
36
|
+
end
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
it "no credit cards exist for user" do
|
39
|
+
api_get :index, user_id: normal_user.id
|
40
|
+
|
41
|
+
expect(response.status).to eq(200)
|
42
|
+
expect(json_response["pages"]).to eq(0)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can view all credit cards for user" do
|
46
|
+
api_get :index, user_id: current_api_user.id
|
47
|
+
|
48
|
+
expect(response.status).to eq(200)
|
49
|
+
expect(json_response["pages"]).to eq(1)
|
50
|
+
expect(json_response["current_page"]).to eq(1)
|
51
|
+
expect(json_response["credit_cards"].length).to eq(1)
|
52
|
+
expect(json_response["credit_cards"].first["id"]).to eq(card.id)
|
53
|
+
end
|
42
54
|
end
|
43
55
|
|
44
|
-
|
45
|
-
|
56
|
+
context "calling user is not in admin role" do
|
57
|
+
let(:current_api_user) do
|
58
|
+
user = normal_user
|
59
|
+
user
|
60
|
+
end
|
61
|
+
|
62
|
+
let!(:card) { create(:credit_card, :user_id => normal_user.id, gateway_customer_profile_id: "random") }
|
63
|
+
|
64
|
+
it "can not view user" do
|
65
|
+
api_get :index, user_id: admin_user.id
|
66
|
+
|
67
|
+
expect(response.status).to eq(404)
|
68
|
+
end
|
46
69
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
70
|
+
it "can view own credit cards" do
|
71
|
+
api_get :index, user_id: normal_user.id
|
72
|
+
|
73
|
+
expect(response.status).to eq(200)
|
74
|
+
expect(json_response["pages"]).to eq(1)
|
75
|
+
expect(json_response["current_page"]).to eq(1)
|
76
|
+
expect(json_response["credit_cards"].length).to eq(1)
|
77
|
+
expect(json_response["credit_cards"].first["id"]).to eq(card.id)
|
78
|
+
end
|
52
79
|
end
|
53
80
|
end
|
54
81
|
|
55
|
-
|
56
|
-
let(:
|
57
|
-
|
58
|
-
user
|
59
|
-
end
|
82
|
+
describe '#update' do
|
83
|
+
let(:credit_card) { create(:credit_card, name: 'Joe Shmoe', user: credit_card_user) }
|
84
|
+
let(:credit_card_user) { create(:user) }
|
60
85
|
|
61
|
-
|
86
|
+
before do
|
87
|
+
stub_authentication!
|
88
|
+
end
|
62
89
|
|
63
|
-
|
64
|
-
|
90
|
+
context 'when the user is authorized' do
|
91
|
+
let(:current_api_user) { credit_card_user }
|
65
92
|
|
66
|
-
|
93
|
+
it 'updates the credit card' do
|
94
|
+
expect {
|
95
|
+
api_put :update, id: credit_card.to_param, credit_card: {name: 'Jordan Brough'}
|
96
|
+
}.to change {
|
97
|
+
credit_card.reload.name
|
98
|
+
}.from('Joe Shmoe').to('Jordan Brough')
|
99
|
+
end
|
67
100
|
end
|
68
101
|
|
69
|
-
|
70
|
-
|
102
|
+
context 'when the user is not authorized' do
|
103
|
+
let(:current_api_user) { create(:user) }
|
71
104
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
expect(json_response["credit_cards"].first["id"]).to eq(card.id)
|
105
|
+
it 'rejects the request' do
|
106
|
+
api_put :update, id: credit_card.to_param, credit_card: {name: 'Jordan Brough'}
|
107
|
+
expect(response.status).to eq(401)
|
108
|
+
end
|
77
109
|
end
|
78
110
|
end
|
79
111
|
end
|
@@ -27,25 +27,110 @@ module Spree
|
|
27
27
|
stub_authentication!
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
|
30
|
+
describe "POST create" do
|
31
|
+
let(:target_user) { create :user }
|
32
|
+
let(:date_override) { 3.days.ago }
|
32
33
|
|
33
34
|
before do
|
34
|
-
allow_any_instance_of(Spree::
|
35
|
+
allow_any_instance_of(Spree::Ability).to receive(:can?).
|
36
|
+
and_return(true)
|
37
|
+
|
38
|
+
allow_any_instance_of(Spree::Ability).to receive(:can?).
|
39
|
+
with(:admin, Spree::Order).
|
40
|
+
and_return(can_admin)
|
41
|
+
|
42
|
+
allow(Spree.user_class).to receive(:find).
|
43
|
+
with(target_user.id).
|
44
|
+
and_return(target_user)
|
35
45
|
end
|
36
46
|
|
37
|
-
|
38
|
-
|
47
|
+
subject { api_post :create, order: { user_id: target_user.id, created_at: date_override, email: target_user.email } }
|
48
|
+
|
49
|
+
context "when the current user cannot administrate the order" do
|
50
|
+
let(:can_admin) { false }
|
51
|
+
|
52
|
+
it "does not include unpermitted params, or allow overriding the user", focus: true do
|
53
|
+
expect(Spree::Core::Importer::Order).to receive(:import).
|
54
|
+
once.
|
55
|
+
with(current_api_user, { "email" => target_user.email })
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
|
59
|
+
it { should be_success }
|
39
60
|
end
|
40
61
|
|
41
|
-
|
42
|
-
|
43
|
-
|
62
|
+
context "when the current user can administrate the order" do
|
63
|
+
let(:can_admin) { true }
|
64
|
+
|
65
|
+
it "it permits all params and allows overriding the user" do
|
66
|
+
expect(Spree::Core::Importer::Order).to receive(:import).
|
67
|
+
once.
|
68
|
+
with(target_user, { "user_id" => target_user.id, "created_at" => date_override, "email" => target_user.email})
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
|
72
|
+
it { should be_success }
|
44
73
|
end
|
74
|
+
end
|
45
75
|
|
46
|
-
|
76
|
+
describe "PUT update" do
|
77
|
+
let(:user) { create :user }
|
78
|
+
let(:order_params) { { number: "anothernumber", user_id: user.id, email: "foo@foobar.com" } }
|
79
|
+
let(:can_admin) { false }
|
80
|
+
subject { api_put :update, id: order.to_param, order: order_params }
|
81
|
+
|
82
|
+
before do
|
83
|
+
allow_any_instance_of(Spree::Ability).to receive(:can?).
|
84
|
+
and_return(true)
|
85
|
+
|
86
|
+
allow(Spree::Order).to receive(:find_by!).
|
87
|
+
with(number: order.number).
|
88
|
+
and_return(order)
|
89
|
+
|
90
|
+
allow(Spree.user_class).to receive(:find).
|
91
|
+
with(user.id).
|
92
|
+
and_return(user)
|
93
|
+
|
94
|
+
allow_any_instance_of(Spree::Ability).to receive(:can?).
|
95
|
+
with(:admin, Spree::Order).
|
96
|
+
and_return(can_admin)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "updates the cart contents" do
|
100
|
+
expect(order.contents).to receive(:update_cart).
|
101
|
+
once.
|
102
|
+
with({"email" => "foo@foobar.com"})
|
47
103
|
subject
|
48
|
-
|
104
|
+
end
|
105
|
+
|
106
|
+
it { should be_success }
|
107
|
+
|
108
|
+
context "when the user can administer the order" do
|
109
|
+
let(:can_admin) { true }
|
110
|
+
|
111
|
+
it "will associate users" do
|
112
|
+
expect(order).to receive(:associate_user!).
|
113
|
+
once.
|
114
|
+
with(user)
|
115
|
+
|
116
|
+
subject
|
117
|
+
end
|
118
|
+
|
119
|
+
it "updates the otherwise forbidden attributes" do
|
120
|
+
expect{subject}.to change{order.reload.number}.
|
121
|
+
to("anothernumber")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "when the user cannot administer the order" do
|
126
|
+
it "does not associate users" do
|
127
|
+
expect(order).to_not receive(:associate_user!)
|
128
|
+
subject
|
129
|
+
end
|
130
|
+
|
131
|
+
it "does not change forbidden attributes" do
|
132
|
+
expect{subject}.to_not change{order.reload.number}
|
133
|
+
end
|
49
134
|
end
|
50
135
|
end
|
51
136
|
|
@@ -174,6 +259,20 @@ module Spree
|
|
174
259
|
expect(shipment['adjustments'][0]['label']).to eq(adjustment.label)
|
175
260
|
end
|
176
261
|
end
|
262
|
+
|
263
|
+
context 'when credit cards are present' do
|
264
|
+
let!(:payment) { create(:credit_card_payment, order: order, source: credit_card) }
|
265
|
+
let(:credit_card) { create(:credit_card, address: create(:address)) }
|
266
|
+
|
267
|
+
it 'contains the credit cards' do
|
268
|
+
subject
|
269
|
+
|
270
|
+
credit_cards = json_response['credit_cards']
|
271
|
+
expect(credit_cards.size).to eq 1
|
272
|
+
expect(credit_cards[0]['id']).to eq payment.source.id
|
273
|
+
expect(credit_cards[0]['address']['id']).to eq credit_card.address_id
|
274
|
+
end
|
275
|
+
end
|
177
276
|
end
|
178
277
|
|
179
278
|
it "orders contain the basic checkout steps" do
|
@@ -240,7 +339,7 @@ module Spree
|
|
240
339
|
|
241
340
|
expect(json_response['number']).to be_present
|
242
341
|
expect(json_response["token"]).not_to be_blank
|
243
|
-
expect(json_response["state"]).to eq("
|
342
|
+
expect(json_response["state"]).to eq("cart")
|
244
343
|
expect(order.user).to eq(current_api_user)
|
245
344
|
expect(order.email).to eq(current_api_user.email)
|
246
345
|
expect(json_response["user_id"]).to eq(current_api_user.id)
|
@@ -320,16 +419,6 @@ module Spree
|
|
320
419
|
|
321
420
|
before { allow_any_instance_of(Order).to receive_messages user: current_api_user }
|
322
421
|
|
323
|
-
context "line_items hash not present in request" do
|
324
|
-
it "responds successfully" do
|
325
|
-
api_put :update, :id => order.to_param, :order => {
|
326
|
-
:email => "hublock@spreecommerce.com"
|
327
|
-
}
|
328
|
-
|
329
|
-
expect(response).to be_success
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
422
|
it "updates quantities of existing line items" do
|
334
423
|
api_put :update, :id => order.to_param, :order => {
|
335
424
|
:line_items => {
|
@@ -500,6 +589,7 @@ module Spree
|
|
500
589
|
end
|
501
590
|
|
502
591
|
before do
|
592
|
+
order.next!
|
503
593
|
order.next!
|
504
594
|
order.save
|
505
595
|
end
|
@@ -5,6 +5,7 @@ module Spree
|
|
5
5
|
before { Spree::Api::Config[:requires_authentication] = false }
|
6
6
|
let!(:promotion) { FactoryGirl.create(:promotion, :with_order_adjustment, code: 'foo', weighted_order_adjustment_amount: 10) }
|
7
7
|
let(:promotion_code) { promotion.codes.first }
|
8
|
+
let!(:store) { FactoryGirl.create(:store) }
|
8
9
|
let(:bill_address) { FactoryGirl.create(:address) }
|
9
10
|
let(:ship_address) { FactoryGirl.create(:address) }
|
10
11
|
let(:variant_1) { FactoryGirl.create(:variant, price: 100.00) }
|
@@ -19,10 +19,6 @@ module ControllerHacks
|
|
19
19
|
api_process(action, params, session, flash, "PUT")
|
20
20
|
end
|
21
21
|
|
22
|
-
def api_patch(action, params={}, session=nil, flash=nil)
|
23
|
-
api_process(action, params, session, flash, "PATCH")
|
24
|
-
end
|
25
|
-
|
26
22
|
def api_delete(action, params={}, session=nil, flash=nil)
|
27
23
|
api_process(action, params, session, flash, "DELETE")
|
28
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.pre3
|
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: 1.0.0.
|
26
|
+
version: 1.0.0.pre3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|