spree_backend 3.1.5 → 3.1.6
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/admin/orders_controller.rb +1 -3
- data/app/controllers/spree/admin/products_controller.rb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +8 -8
- data/app/views/spree/admin/products/index.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
- data/app/views/spree/admin/taxons/edit.html.erb +1 -1
- data/spree_backend.gemspec +1 -1
- metadata +7 -98
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -254
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
- data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -35
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -56
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
- data/spec/features/admin/configuration/countries_spec.rb +0 -24
- data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
- data/spec/features/admin/configuration/roles_spec.rb +0 -47
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
- data/spec/features/admin/configuration/states_spec.rb +0 -68
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
- data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
- data/spec/features/admin/configuration/zones_spec.rb +0 -39
- data/spec/features/admin/homepage_spec.rb +0 -89
- data/spec/features/admin/locale_spec.rb +0 -31
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
- data/spec/features/admin/orders/adjustments_spec.rb +0 -129
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
- data/spec/features/admin/orders/customer_details_spec.rb +0 -154
- data/spec/features/admin/orders/line_items_spec.rb +0 -51
- data/spec/features/admin/orders/listing_spec.rb +0 -222
- data/spec/features/admin/orders/log_entries_spec.rb +0 -55
- data/spec/features/admin/orders/new_order_spec.rb +0 -160
- data/spec/features/admin/orders/order_details_spec.rb +0 -662
- data/spec/features/admin/orders/payments_spec.rb +0 -230
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
- data/spec/features/admin/orders/shipments_spec.rb +0 -64
- data/spec/features/admin/orders/state_changes_spec.rb +0 -21
- data/spec/features/admin/products/edit/images_spec.rb +0 -86
- data/spec/features/admin/products/edit/products_spec.rb +0 -64
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
- data/spec/features/admin/products/edit/variants_spec.rb +0 -56
- data/spec/features/admin/products/option_types_spec.rb +0 -114
- data/spec/features/admin/products/products_spec.rb +0 -445
- data/spec/features/admin/products/properties_spec.rb +0 -147
- data/spec/features/admin/products/prototypes_spec.rb +0 -112
- data/spec/features/admin/products/stock_management_spec.rb +0 -124
- data/spec/features/admin/products/taxonomies_spec.rb +0 -52
- data/spec/features/admin/products/variant_spec.rb +0 -50
- data/spec/features/admin/promotions/adjustments_spec.rb +0 -259
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
- data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
- data/spec/features/admin/reports_spec.rb +0 -61
- data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
- data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
- data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
- data/spec/features/admin/stock_transfer_spec.rb +0 -75
- data/spec/features/admin/store_credits_spec.rb +0 -93
- data/spec/features/admin/taxons_spec.rb +0 -47
- data/spec/features/admin/users_spec.rb +0 -286
- data/spec/helpers/admin/base_helper_spec.rb +0 -30
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -106
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
- data/spec/models/spree/resource_spec.rb +0 -48
- data/spec/routing/admin_path_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -134
- data/spec/support/appear_before_matcher.rb +0 -8
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
module Admin
|
5
|
-
describe ReturnIndexController, type: :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
describe "#return_authorizations" do
|
9
|
-
let(:return_authorization) { create(:return_authorization) }
|
10
|
-
|
11
|
-
subject do
|
12
|
-
spree_get :return_authorizations
|
13
|
-
end
|
14
|
-
|
15
|
-
before { subject }
|
16
|
-
|
17
|
-
it "loads return authorizations" do
|
18
|
-
expect(assigns(:collection)).to include(return_authorization)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#customer_returns" do
|
23
|
-
let(:customer_return) { create(:customer_return) }
|
24
|
-
|
25
|
-
subject do
|
26
|
-
spree_get :customer_returns
|
27
|
-
end
|
28
|
-
|
29
|
-
before { subject }
|
30
|
-
|
31
|
-
it "loads customer returns" do
|
32
|
-
expect(assigns(:collection)).to include(customer_return)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Admin::ReturnItemsController, :type => :controller do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
describe '#update' do
|
7
|
-
let(:customer_return) { create(:customer_return) }
|
8
|
-
let(:return_item) { customer_return.return_items.first }
|
9
|
-
let(:old_acceptance_status) { 'accepted' }
|
10
|
-
let(:new_acceptance_status) { 'rejected' }
|
11
|
-
|
12
|
-
subject do
|
13
|
-
spree_put :update, id: return_item.to_param, return_item: {acceptance_status: new_acceptance_status}
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'updates the return item' do
|
17
|
-
expect {
|
18
|
-
subject
|
19
|
-
}.to change { return_item.reload.acceptance_status }.from(old_acceptance_status).to(new_acceptance_status)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'redirects to the custome return' do
|
23
|
-
subject
|
24
|
-
expect(response).to redirect_to spree.edit_admin_order_customer_return_path(customer_return.order, customer_return)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Admin::RootController do
|
4
|
-
|
5
|
-
context "unauthorized request" do
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
allow(controller).to receive(:spree_current_user).and_return(nil)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "redirects to orders path by default" do
|
12
|
-
get :index
|
13
|
-
|
14
|
-
expect(response).to redirect_to '/admin/orders'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "authorized request" do
|
19
|
-
stub_authorization!
|
20
|
-
|
21
|
-
it "redirects to orders path by default" do
|
22
|
-
get :index
|
23
|
-
|
24
|
-
expect(response).to redirect_to '/admin/orders'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "redirects to wherever admin_root_redirects_path tells it to" do
|
28
|
-
expect(controller).to receive(:admin_root_redirect_path).and_return('/grooot')
|
29
|
-
|
30
|
-
get :index
|
31
|
-
|
32
|
-
expect(response).to redirect_to '/grooot'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Admin::SearchController, :type => :controller do
|
4
|
-
stub_authorization!
|
5
|
-
# Regression test for ernie/ransack#176
|
6
|
-
|
7
|
-
describe "users" do
|
8
|
-
let(:user) { create(:user, :email => "spree_commerce@example.com") }
|
9
|
-
|
10
|
-
before do
|
11
|
-
user.ship_address = create(:address)
|
12
|
-
user.bill_address = create(:address)
|
13
|
-
user.save
|
14
|
-
end
|
15
|
-
|
16
|
-
it "can find a user by their email "do
|
17
|
-
spree_xhr_get :users, :q => user.email
|
18
|
-
expect(assigns[:users]).to include(user)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "can find a user by their ship address's first name" do
|
22
|
-
spree_xhr_get :users, :q => user.ship_address.firstname
|
23
|
-
expect(assigns[:users]).to include(user)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "can find a user by their ship address's last name" do
|
27
|
-
spree_xhr_get :users, :q => user.ship_address.lastname
|
28
|
-
expect(assigns[:users]).to include(user)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "can find a user by their bill address's first name" do
|
32
|
-
spree_xhr_get :users, :q => user.bill_address.firstname
|
33
|
-
expect(assigns[:users]).to include(user)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "can find a user by their bill address's last name" do
|
37
|
-
spree_xhr_get :users, :q => user.bill_address.lastname
|
38
|
-
expect(assigns[:users]).to include(user)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "products" do
|
43
|
-
let(:product) { create(:product, :name => "Example Product") }
|
44
|
-
|
45
|
-
it "can find a product by its name "do
|
46
|
-
spree_xhr_get :products, :q => product.name
|
47
|
-
expect(assigns[:products]).to include(product)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "can find a product by its slug "do
|
51
|
-
spree_xhr_get :products, :q => product.slug
|
52
|
-
expect(assigns[:products]).to include(product)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Admin::ShippingMethodsController, :type => :controller do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
# Regression test for #1240
|
7
|
-
it "should not hard-delete shipping methods" do
|
8
|
-
shipping_method = stub_model(Spree::ShippingMethod)
|
9
|
-
allow(Spree::ShippingMethod).to receive_messages :find => shipping_method
|
10
|
-
expect(shipping_method.deleted_at).to be_nil
|
11
|
-
spree_delete :destroy, :id => 1
|
12
|
-
expect(shipping_method.reload.deleted_at).not_to be_nil
|
13
|
-
end
|
14
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
module Admin
|
5
|
-
describe StockItemsController, :type => :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
context "formats" do
|
9
|
-
let!(:stock_item) { create(:variant).stock_items.first }
|
10
|
-
|
11
|
-
it "destroy stock item via js" do
|
12
|
-
expect {
|
13
|
-
spree_delete :destroy, format: :js, id: stock_item
|
14
|
-
}.to change{ StockItem.count }.by(-1)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
module Admin
|
5
|
-
describe StockLocationsController, :type => :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
# Regression for #4272
|
9
|
-
context "with no countries present" do
|
10
|
-
it "cannot create a new stock location" do
|
11
|
-
spree_get :new
|
12
|
-
expect(flash[:error]).to eq(Spree.t(:stock_locations_need_a_default_country))
|
13
|
-
expect(response).to redirect_to(spree.admin_stock_locations_path)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with a default country present" do
|
18
|
-
before do
|
19
|
-
country = FactoryGirl.create(:country)
|
20
|
-
Spree::Config[:default_country_id] = country.id
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can create a new stock location" do
|
24
|
-
spree_get :new
|
25
|
-
expect(response).to be_success
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with a country with the ISO code of 'US' existing" do
|
30
|
-
before do
|
31
|
-
FactoryGirl.create(:country, iso: 'US')
|
32
|
-
end
|
33
|
-
|
34
|
-
it "can create a new stock location" do
|
35
|
-
spree_get :new
|
36
|
-
expect(response).to be_success
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
describe Admin::StockTransfersController, :type => :controller do
|
5
|
-
stub_authorization!
|
6
|
-
|
7
|
-
let!(:stock_transfer1) {
|
8
|
-
StockTransfer.create do |transfer|
|
9
|
-
transfer.source_location_id = 1
|
10
|
-
transfer.destination_location_id = 2
|
11
|
-
transfer.reference = 'PO 666'
|
12
|
-
end }
|
13
|
-
|
14
|
-
let!(:stock_transfer2) {
|
15
|
-
StockTransfer.create do |transfer|
|
16
|
-
transfer.source_location_id = 3
|
17
|
-
transfer.destination_location_id = 4
|
18
|
-
transfer.reference = 'PO 666'
|
19
|
-
end }
|
20
|
-
|
21
|
-
|
22
|
-
context "#index" do
|
23
|
-
it "gets all transfers without search criteria" do
|
24
|
-
spree_get :index
|
25
|
-
expect(assigns[:stock_transfers].count).to eq 2
|
26
|
-
end
|
27
|
-
|
28
|
-
it "searches by source location" do
|
29
|
-
spree_get :index, :q => { :source_location_id_eq => 1 }
|
30
|
-
expect(assigns[:stock_transfers].count).to eq 1
|
31
|
-
expect(assigns[:stock_transfers]).to include(stock_transfer1)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "searches by destination location" do
|
35
|
-
spree_get :index, :q => { :destination_location_id_eq => 4 }
|
36
|
-
expect(assigns[:stock_transfers].count).to eq 1
|
37
|
-
expect(assigns[:stock_transfers]).to include(stock_transfer2)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
module Admin
|
5
|
-
describe TaxCategoriesController, :type => :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
describe 'GET #index' do
|
9
|
-
subject { spree_get :index }
|
10
|
-
|
11
|
-
it 'should be successful' do
|
12
|
-
expect(subject).to be_success
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'PUT #update' do
|
17
|
-
let(:tax_category) { create :tax_category }
|
18
|
-
|
19
|
-
subject { spree_put :update, {id: tax_category.id, tax_category: { name: 'Foo', tax_code: 'Bar' }}}
|
20
|
-
|
21
|
-
it 'should redirect' do
|
22
|
-
expect(subject).to be_redirect
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should update' do
|
26
|
-
subject
|
27
|
-
tax_category.reload
|
28
|
-
expect(tax_category.name).to eq('Foo')
|
29
|
-
expect(tax_category.tax_code).to eq('Bar')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'spree/testing_support/bar_ability'
|
3
|
-
|
4
|
-
describe Spree::Admin::UsersController, :type => :controller do
|
5
|
-
let(:user) { create(:user) }
|
6
|
-
let(:mock_user) { mock_model Spree.user_class }
|
7
|
-
|
8
|
-
before do
|
9
|
-
allow(controller).to receive_messages :spree_current_user => user
|
10
|
-
user.spree_roles.clear
|
11
|
-
stub_const('Spree::User', user.class)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "#show" do
|
15
|
-
before do
|
16
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
17
|
-
end
|
18
|
-
|
19
|
-
it "redirects to edit" do
|
20
|
-
spree_get :show, id: user.id
|
21
|
-
expect(response).to redirect_to spree.edit_admin_user_path(user)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context '#authorize_admin' do
|
26
|
-
before { use_mock_user }
|
27
|
-
|
28
|
-
it 'grant access to users with an admin role' do
|
29
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
30
|
-
spree_post :index
|
31
|
-
expect(response).to render_template :index
|
32
|
-
end
|
33
|
-
|
34
|
-
it "allows admins to update a user's API key" do
|
35
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
36
|
-
expect(mock_user).to receive(:generate_spree_api_key!).and_return(true)
|
37
|
-
spree_put :generate_api_key, id: mock_user.id
|
38
|
-
expect(response).to redirect_to(spree.edit_admin_user_path(mock_user))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "allows admins to clear a user's API key" do
|
42
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
43
|
-
expect(mock_user).to receive(:clear_spree_api_key!).and_return(true)
|
44
|
-
spree_put :clear_api_key, id: mock_user.id
|
45
|
-
expect(response).to redirect_to(spree.edit_admin_user_path(mock_user))
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'deny access to users with an bar role' do
|
49
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
|
50
|
-
Spree::Ability.register_ability(BarAbility)
|
51
|
-
spree_post :index
|
52
|
-
expect(response).to redirect_to(spree.forbidden_path)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'deny access to users with an bar role' do
|
56
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
|
57
|
-
Spree::Ability.register_ability(BarAbility)
|
58
|
-
spree_post :update, { id: '9' }
|
59
|
-
expect(response).to redirect_to(spree.forbidden_path)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'deny access to users without an admin role' do
|
63
|
-
allow(user).to receive_messages :has_spree_role? => false
|
64
|
-
spree_post :index
|
65
|
-
expect(response).to redirect_to(spree.forbidden_path)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#create" do
|
70
|
-
before do
|
71
|
-
use_mock_user
|
72
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
73
|
-
end
|
74
|
-
|
75
|
-
it "can create a shipping_address" do
|
76
|
-
expect(Spree.user_class).to receive(:new).with(hash_including(
|
77
|
-
"ship_address_attributes" => { "city" => "New York" }
|
78
|
-
))
|
79
|
-
spree_post :create, { :user => { :ship_address_attributes => { :city => "New York" } } }
|
80
|
-
end
|
81
|
-
|
82
|
-
it "can create a billing_address" do
|
83
|
-
expect(Spree.user_class).to receive(:new).with(hash_including(
|
84
|
-
"bill_address_attributes" => { "city" => "New York" }
|
85
|
-
))
|
86
|
-
spree_post :create, { :user => { :bill_address_attributes => { :city => "New York" } } }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "#update" do
|
91
|
-
before do
|
92
|
-
use_mock_user
|
93
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
94
|
-
end
|
95
|
-
|
96
|
-
it "allows shipping address attributes through" do
|
97
|
-
expect(mock_user).to receive(:update_attributes).with(hash_including(
|
98
|
-
"ship_address_attributes" => { "city" => "New York" }
|
99
|
-
))
|
100
|
-
spree_put :update, { :id => mock_user.id, :user => { :ship_address_attributes => { :city => "New York" } } }
|
101
|
-
end
|
102
|
-
|
103
|
-
it "allows billing address attributes through" do
|
104
|
-
expect(mock_user).to receive(:update_attributes).with(hash_including(
|
105
|
-
"bill_address_attributes" => { "city" => "New York" }
|
106
|
-
))
|
107
|
-
spree_put :update, { :id => mock_user.id, :user => { :bill_address_attributes => { :city => "New York" } } }
|
108
|
-
end
|
109
|
-
|
110
|
-
it "allows updating without password resetting" do
|
111
|
-
expect(mock_user).to receive(:update_attributes).with(hash_not_including(password: '', password_confirmation: ''))
|
112
|
-
spree_put :update, id: mock_user.id, user: { password: '', password_confirmation: '', email: 'spree@example.com' }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "#orders" do
|
117
|
-
let(:order) { create(:order) }
|
118
|
-
before do
|
119
|
-
user.orders << order
|
120
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
121
|
-
end
|
122
|
-
|
123
|
-
it "assigns a list of the users orders" do
|
124
|
-
spree_get :orders, { :id => user.id }
|
125
|
-
expect(assigns[:orders].count).to eq 1
|
126
|
-
expect(assigns[:orders].first).to eq order
|
127
|
-
end
|
128
|
-
|
129
|
-
it "assigns a ransack search for Spree::Order" do
|
130
|
-
spree_get :orders, { :id => user.id }
|
131
|
-
expect(assigns[:search]).to be_a Ransack::Search
|
132
|
-
expect(assigns[:search].klass).to eq Spree::Order
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "#items" do
|
137
|
-
let(:order) { create(:order) }
|
138
|
-
before do
|
139
|
-
user.orders << order
|
140
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
141
|
-
end
|
142
|
-
|
143
|
-
it "assigns a list of the users orders" do
|
144
|
-
spree_get :items, { :id => user.id }
|
145
|
-
expect(assigns[:orders].count).to eq 1
|
146
|
-
expect(assigns[:orders].first).to eq order
|
147
|
-
end
|
148
|
-
|
149
|
-
it "assigns a ransack search for Spree::Order" do
|
150
|
-
spree_get :items, { :id => user.id }
|
151
|
-
expect(assigns[:search]).to be_a Ransack::Search
|
152
|
-
expect(assigns[:search].klass).to eq Spree::Order
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def use_mock_user
|
158
|
-
allow(mock_user).to receive(:save).and_return(true)
|
159
|
-
allow(Spree.user_class).to receive(:find).with(mock_user.id.to_s).and_return(mock_user)
|
160
|
-
allow(Spree.user_class).to receive(:new).and_return(mock_user)
|
161
|
-
end
|