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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/admin/orders_controller.rb +1 -3
  3. data/app/controllers/spree/admin/products_controller.rb +1 -1
  4. data/app/views/spree/admin/products/_form.html.erb +8 -8
  5. data/app/views/spree/admin/products/index.html.erb +1 -1
  6. data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
  7. data/app/views/spree/admin/taxons/edit.html.erb +1 -1
  8. data/spree_backend.gemspec +1 -1
  9. metadata +7 -98
  10. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
  11. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
  12. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  13. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  14. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
  15. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -254
  16. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  17. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
  18. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
  19. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  20. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  21. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
  22. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  23. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
  24. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
  25. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
  26. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
  27. data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
  28. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  29. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -35
  30. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -56
  31. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  32. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
  33. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  34. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
  35. data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
  36. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
  37. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  38. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
  39. data/spec/features/admin/configuration/countries_spec.rb +0 -24
  40. data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
  41. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
  42. data/spec/features/admin/configuration/roles_spec.rb +0 -47
  43. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
  44. data/spec/features/admin/configuration/states_spec.rb +0 -68
  45. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
  46. data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
  47. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  48. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
  49. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  50. data/spec/features/admin/homepage_spec.rb +0 -89
  51. data/spec/features/admin/locale_spec.rb +0 -31
  52. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  53. data/spec/features/admin/orders/adjustments_spec.rb +0 -129
  54. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
  55. data/spec/features/admin/orders/customer_details_spec.rb +0 -154
  56. data/spec/features/admin/orders/line_items_spec.rb +0 -51
  57. data/spec/features/admin/orders/listing_spec.rb +0 -222
  58. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  59. data/spec/features/admin/orders/new_order_spec.rb +0 -160
  60. data/spec/features/admin/orders/order_details_spec.rb +0 -662
  61. data/spec/features/admin/orders/payments_spec.rb +0 -230
  62. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
  63. data/spec/features/admin/orders/shipments_spec.rb +0 -64
  64. data/spec/features/admin/orders/state_changes_spec.rb +0 -21
  65. data/spec/features/admin/products/edit/images_spec.rb +0 -86
  66. data/spec/features/admin/products/edit/products_spec.rb +0 -64
  67. data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
  68. data/spec/features/admin/products/edit/variants_spec.rb +0 -56
  69. data/spec/features/admin/products/option_types_spec.rb +0 -114
  70. data/spec/features/admin/products/products_spec.rb +0 -445
  71. data/spec/features/admin/products/properties_spec.rb +0 -147
  72. data/spec/features/admin/products/prototypes_spec.rb +0 -112
  73. data/spec/features/admin/products/stock_management_spec.rb +0 -124
  74. data/spec/features/admin/products/taxonomies_spec.rb +0 -52
  75. data/spec/features/admin/products/variant_spec.rb +0 -50
  76. data/spec/features/admin/promotions/adjustments_spec.rb +0 -259
  77. data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
  78. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
  79. data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
  80. data/spec/features/admin/reports_spec.rb +0 -61
  81. data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
  82. data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
  83. data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
  84. data/spec/features/admin/stock_transfer_spec.rb +0 -75
  85. data/spec/features/admin/store_credits_spec.rb +0 -93
  86. data/spec/features/admin/taxons_spec.rb +0 -47
  87. data/spec/features/admin/users_spec.rb +0 -286
  88. data/spec/helpers/admin/base_helper_spec.rb +0 -30
  89. data/spec/helpers/admin/navigation_helper_spec.rb +0 -106
  90. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
  91. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  92. data/spec/models/spree/resource_spec.rb +0 -48
  93. data/spec/routing/admin_path_spec.rb +0 -22
  94. data/spec/spec_helper.rb +0 -134
  95. data/spec/support/appear_before_matcher.rb +0 -8
  96. data/spec/support/ror_ringer.jpeg +0 -0
  97. data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
  98. data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
  99. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  100. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::GeneralSettingsController, type: :controller do
4
- let(:user) { create(:user) }
5
-
6
- before do
7
- allow(controller).to receive_messages :spree_current_user => user
8
- user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
9
- end
10
-
11
- describe '#clear_cache' do
12
- subject { spree_post :clear_cache }
13
-
14
- shared_examples 'a HTTP 204 response' do
15
- it 'grant access to users with an admin role' do
16
- subject
17
- expect(response.status).to eq(204)
18
- end
19
- end
20
-
21
- context 'when no callback' do
22
- it_behaves_like 'a HTTP 204 response'
23
- end
24
-
25
- context 'when callback implemented' do
26
- Spree::Admin::GeneralSettingsController.class_eval do
27
- custom_callback(:clear_cache).after :foo
28
-
29
- def foo
30
- # Make a call to Akamai, CloudFlare, etc invalidation....
31
- end
32
- end
33
-
34
- before do
35
- expect(controller).to receive(:foo).once
36
- end
37
-
38
- it_behaves_like 'a HTTP 204 response'
39
- end
40
- end
41
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
- # This test exists in this file because in the standard admin/products_controller spec
3
- # There is the stub_authorization call. This call is not triggered for this test because
4
- # the load_resource filter in Spree::Admin::ResourceController is prepended to the filter chain
5
- # this means this call is triggered before the authorize_admin call and in this case
6
- # the load_resource filter halts the request meaning authorize_admin is not called at all.
7
- describe Spree::Admin::ProductsController, :type => :controller do
8
- stub_authorization!
9
-
10
- # Regression test for GH #538
11
- it "cannot find a non-existent product" do
12
- spree_get :edit, :id => "non-existent-product"
13
- expect(response).to redirect_to(spree.admin_products_path)
14
- expect(flash[:error]).to eql("Product is not found")
15
- end
16
- end
17
-
18
-
@@ -1,197 +0,0 @@
1
- require "spec_helper"
2
- require "cancan"
3
- require "spree/testing_support/bar_ability"
4
-
5
- describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
6
-
7
- context "with authorization" do
8
- stub_authorization!
9
-
10
- let(:order) do
11
- mock_model(
12
- Spree::Order,
13
- total: 100,
14
- number: "R123456789",
15
- billing_address: mock_model(Spree::Address)
16
- )
17
- end
18
-
19
- before do
20
- allow(Spree::Order).to receive_message_chain(:friendly, :find).and_return(order)
21
- end
22
-
23
- describe '#update' do
24
- let(:attributes) do
25
- {
26
- order_id: order.number,
27
- order: {
28
- email: "",
29
- use_billing: "",
30
- bill_address_attributes: {},
31
- ship_address_attributes: {}
32
- },
33
- guest_checkout: 'true'
34
- }
35
- end
36
-
37
- def send_request(params = {})
38
- spree_put :update, params
39
- end
40
-
41
- context 'using guest checkout' do
42
- context 'having valid parameters' do
43
- before do
44
- allow(order).to receive_messages(update_attributes: true)
45
- allow(order).to receive_messages(next: false)
46
- allow(order).to receive_messages(complete?: true)
47
- allow(order).to receive_messages(refresh_shipment_rates: true)
48
- end
49
-
50
- context 'having successful response' do
51
- before { send_request(attributes) }
52
- it { expect(response).to have_http_status(302) }
53
- it { expect(response).to redirect_to(edit_admin_order_url(order)) }
54
- end
55
-
56
- context 'with correct method flow' do
57
- it { expect(order).to receive(:update_attributes).with(attributes[:order]) }
58
- it { expect(order).to_not receive(:next) }
59
- it { expect(order).to receive(:complete?) }
60
- it 'does refresh the shipment rates with all shipping methods' do
61
- expect(order).to receive(:refresh_shipment_rates).
62
- with(Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END)
63
- end
64
- it { expect(controller).to receive(:load_order).and_call_original }
65
- it { expect(controller).to receive(:guest_checkout?).twice.and_call_original }
66
- it { expect(controller).to_not receive(:load_user).and_call_original }
67
- after { send_request(attributes) }
68
- end
69
- end
70
-
71
- context 'having invalid parameters' do
72
- before do
73
- allow(order).to receive_messages(update_attributes: false)
74
- end
75
-
76
- context 'having failure response' do
77
- before { send_request(attributes) }
78
- it { expect(response).to render_template(:edit) }
79
- end
80
-
81
- context 'with correct method flow' do
82
- it { expect(order).to receive(:update_attributes).with(attributes[:order]) }
83
- it { expect(controller).to receive(:load_order).and_call_original }
84
- it { expect(controller).to receive(:guest_checkout?).and_call_original }
85
- it { expect(controller).to_not receive(:load_user).and_call_original }
86
- after { send_request(attributes) }
87
- end
88
- end
89
- end
90
-
91
- context 'without using guest checkout' do
92
- let(:user) { mock_model(Spree.user_class) }
93
- let(:changed_attributes) { attributes.merge(guest_checkout: 'false', user_id: user.id) }
94
-
95
- context 'having valid parameters' do
96
- before do
97
- allow(Spree.user_class).to receive(:find_by).and_return(user)
98
- allow(order).to receive_messages(update_attributes: true)
99
- allow(order).to receive_messages(next: false)
100
- allow(order).to receive_messages(complete?: true)
101
- allow(order).to receive_messages(refresh_shipment_rates: true)
102
- allow(order).to receive_messages(associate_user!: true)
103
- allow(controller).to receive(:guest_checkout?).and_return(false)
104
- allow(order).to receive(:associate_user!)
105
- end
106
-
107
- context 'having successful response' do
108
- before { send_request(changed_attributes) }
109
- it { expect(response).to have_http_status(302) }
110
- it { expect(response).to redirect_to(edit_admin_order_url(order)) }
111
- end
112
-
113
- context 'with correct method flow' do
114
- it { expect(order).to receive(:update_attributes).with(changed_attributes[:order]) }
115
- it { expect(order).to receive(:associate_user!).with(user, order.email.blank?) }
116
- it { expect(order).to_not receive(:next) }
117
- it { expect(order).to receive(:complete?) }
118
- it 'does refresh the shipment rates with all shipping methods' do
119
- expect(order).to receive(:refresh_shipment_rates).
120
- with(Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END)
121
- end
122
- it { expect(controller).to receive(:load_order).and_call_original }
123
- it { expect(controller).to receive(:guest_checkout?).twice.and_call_original }
124
- it { expect(controller).to receive(:load_user).and_call_original }
125
- after { send_request(changed_attributes) }
126
- end
127
- end
128
-
129
- context 'having invalid parameters' do
130
- before do
131
- allow(Spree.user_class).to receive(:find_by).and_return(false)
132
- allow(controller).to receive(:guest_checkout?).and_return(false)
133
- end
134
-
135
- context 'having failure response' do
136
- before { send_request(changed_attributes) }
137
- it { expect(response).to render_template(:edit) }
138
- end
139
-
140
- context 'with correct method flow' do
141
- it { expect(order).to_not receive(:update_attributes).with(changed_attributes[:order]) }
142
- it { expect(controller).to receive(:load_order).and_call_original }
143
- it { expect(controller).to receive(:guest_checkout?).and_call_original }
144
- it { expect(controller).to receive(:load_user).and_call_original }
145
- after { send_request(changed_attributes) }
146
- end
147
- end
148
-
149
- describe '#load_user' do
150
- context 'having valid parameters' do
151
- before do
152
- allow(Spree.user_class).to receive(:find_by).and_return(user)
153
- allow(order).to receive_messages(update_attributes: true)
154
- allow(order).to receive_messages(next: false)
155
- allow(order).to receive_messages(complete?: true)
156
- allow(order).to receive_messages(refresh_shipment_rates: true)
157
- allow(order).to receive_messages(associate_user!: true)
158
- allow(controller).to receive(:guest_checkout?).and_return(false)
159
- allow(order).to receive(:associate_user!)
160
- end
161
-
162
- it "expects to assign user" do
163
- send_request(changed_attributes)
164
- expect(assigns[:user]).to eq(user)
165
- end
166
-
167
- context 'with correct method flow' do
168
- it { expect(Spree.user_class).to receive(:find_by).with(id: user.id.to_s).and_return(user) }
169
- after { send_request(changed_attributes) }
170
- end
171
- end
172
-
173
- context 'with invalid parameters' do
174
- before do
175
- allow(Spree.user_class).to receive(:find_by).and_return(nil)
176
- allow(controller).to receive(:guest_checkout?).and_return(false)
177
- end
178
-
179
- it "expects to not assign user" do
180
- send_request(changed_attributes)
181
- expect(assigns[:user]).to_not eq(user)
182
- end
183
-
184
- context 'with correct method flow' do
185
- it { expect(Spree.user_class).to receive(:find_by).with(id: user.id.to_s).and_return(nil) }
186
- it "expects user class to receive find_by with email" do
187
- expect(Spree.user_class).to receive(:find_by).
188
- with(email: changed_attributes[:order][:email]).and_return(nil)
189
- end
190
- after { send_request(changed_attributes) }
191
- end
192
- end
193
- end
194
- end
195
- end
196
- end
197
- end
@@ -1,254 +0,0 @@
1
- require 'spec_helper'
2
- require 'cancan'
3
- require 'spree/testing_support/bar_ability'
4
-
5
- # Ability to test access to specific model instances
6
- class OrderSpecificAbility
7
- include CanCan::Ability
8
-
9
- def initialize(user)
10
- can [:admin, :manage], Spree::Order, number: 'R987654321'
11
- end
12
- end
13
-
14
- describe Spree::Admin::OrdersController, type: :controller do
15
-
16
- context "with authorization" do
17
- stub_authorization!
18
-
19
- before do
20
- request.env["HTTP_REFERER"] = "http://localhost:3000"
21
-
22
- # ensure no respond_overrides are in effect
23
- if Spree::BaseController.spree_responders[:OrdersController].present?
24
- Spree::BaseController.spree_responders[:OrdersController].clear
25
- end
26
- end
27
-
28
- let(:order) do
29
- mock_model(
30
- Spree::Order,
31
- completed?: true,
32
- total: 100,
33
- number: 'R123456789',
34
- all_adjustments: adjustments,
35
- billing_address: mock_model(Spree::Address)
36
- )
37
- end
38
-
39
- let(:adjustments) { double('adjustments') }
40
-
41
- before do
42
- allow(Spree::Order).to receive_message_chain(:friendly, :find).and_return(order)
43
- end
44
-
45
- context "#approve" do
46
- it "approves an order" do
47
- expect(order).to receive(:approved_by).with(controller.try_spree_current_user)
48
- spree_put :approve, id: order.number
49
- expect(flash[:success]).to eq Spree.t(:order_approved)
50
- end
51
- end
52
-
53
- context "#cancel" do
54
- it "cancels an order" do
55
- expect(order).to receive(:canceled_by).with(controller.try_spree_current_user)
56
- spree_put :cancel, id: order.number
57
- expect(flash[:success]).to eq Spree.t(:order_canceled)
58
- end
59
- end
60
-
61
- context "#resume" do
62
- it "resumes an order" do
63
- expect(order).to receive(:resume!)
64
- spree_put :resume, id: order.number
65
- expect(flash[:success]).to eq Spree.t(:order_resumed)
66
- end
67
- end
68
-
69
- context "pagination" do
70
- it "can page through the orders" do
71
- spree_get :index, page: 2, per_page: 10
72
- expect(assigns[:orders].offset_value).to eq(10)
73
- expect(assigns[:orders].limit_value).to eq(10)
74
- end
75
- end
76
-
77
- # Test for #3346
78
- context "#new" do
79
- it "a new order has the current user assigned as a creator" do
80
- spree_get :new
81
- expect(assigns[:order].created_by).to eq(controller.try_spree_current_user)
82
- end
83
- end
84
-
85
- # Regression test for #3684
86
- context "#edit" do
87
- it "does not refresh rates if the order is completed" do
88
- allow(order).to receive_messages completed?: true
89
- expect(order).not_to receive :refresh_shipment_rates
90
- spree_get :edit, id: order.number
91
- end
92
-
93
- it "does refresh the rates if the order is incomplete" do
94
- allow(order).to receive_messages completed?: false
95
- expect(order).to receive :refresh_shipment_rates
96
- spree_get :edit, id: order.number
97
- end
98
- end
99
-
100
- # Test for #3919
101
- context "search" do
102
- let(:user) { create(:user) }
103
-
104
- before do
105
- allow(controller).to receive_messages spree_current_user: user
106
- user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
107
-
108
- create(:completed_order_with_totals)
109
- expect(Spree::Order.count).to eq 1
110
- end
111
-
112
- def send_request
113
- spree_get :index, q: {
114
- line_items_variant_id_in: Spree::Order.first.variants.map(&:id)
115
- }
116
- end
117
-
118
- it 'does not display duplicate results' do
119
- send_request
120
- expect(assigns[:orders].map { |o| o.number }.count).to eq 1
121
- end
122
-
123
- it 'preloads users' do
124
- expect(Spree::Order).to receive(:preload).with(:user).and_return(Spree::Order.all)
125
- send_request
126
- end
127
- end
128
-
129
- context "#open_adjustments" do
130
- let(:closed) { double('closed_adjustments') }
131
-
132
- before do
133
- allow(adjustments).to receive(:closed).and_return(closed)
134
- allow(closed).to receive(:update_all)
135
- end
136
-
137
- it "changes all the closed adjustments to open" do
138
- expect(adjustments).to receive(:closed).and_return(closed)
139
- expect(closed).to receive(:update_all).with(state: 'open')
140
- spree_post :open_adjustments, id: order.number
141
- end
142
-
143
- it "sets the flash success message" do
144
- spree_post :open_adjustments, id: order.number
145
- expect(flash[:success]).to eql('All adjustments successfully opened!')
146
- end
147
-
148
- it "redirects back" do
149
- spree_post :open_adjustments, id: order.number
150
- expect(response).to redirect_to(:back)
151
- end
152
- end
153
-
154
- context "#close_adjustments" do
155
- let(:open) { double('open_adjustments') }
156
-
157
- before do
158
- allow(adjustments).to receive(:open).and_return(open)
159
- allow(open).to receive(:update_all)
160
- end
161
-
162
- it "changes all the open adjustments to closed" do
163
- expect(adjustments).to receive(:open).and_return(open)
164
- expect(open).to receive(:update_all).with(state: 'closed')
165
- spree_post :close_adjustments, id: order.number
166
- end
167
-
168
- it "sets the flash success message" do
169
- spree_post :close_adjustments, id: order.number
170
- expect(flash[:success]).to eql('All adjustments successfully closed!')
171
- end
172
-
173
- it "redirects back" do
174
- spree_post :close_adjustments, id: order.number
175
- expect(response).to redirect_to(:back)
176
- end
177
- end
178
- end
179
-
180
- context '#authorize_admin' do
181
- let(:user) { create(:user) }
182
- let(:order) { create(:completed_order_with_totals, number: 'R987654321') }
183
-
184
- def with_ability(ability)
185
- Spree::Ability.register_ability(ability)
186
- yield
187
- ensure
188
- Spree::Ability.remove_ability(ability)
189
- end
190
-
191
- before do
192
- allow(Spree::Order).to receive_messages find: order
193
- allow(controller).to receive_messages spree_current_user: user
194
- end
195
-
196
- it 'should grant access to users with an admin role' do
197
- user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
198
- spree_post :index
199
- expect(response).to render_template :index
200
- end
201
-
202
- it 'should grant access to users with an bar role' do
203
- with_ability(BarAbility) do
204
- user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
205
- spree_post :index
206
- expect(response).to render_template :index
207
- end
208
- end
209
-
210
- it 'should deny access to users with an bar role' do
211
- with_ability(BarAbility) do
212
- allow(order).to receive(:update_attributes).and_return true
213
- allow(order).to receive(:user).and_return Spree.user_class.new
214
- allow(order).to receive(:token).and_return nil
215
- user.spree_roles.clear
216
- user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
217
- spree_put :update, id: order.number
218
- expect(response).to redirect_to(spree.forbidden_path)
219
- end
220
- end
221
-
222
- it 'should deny access to users without an admin role' do
223
- allow(user).to receive_messages has_spree_role?: false
224
- spree_post :index
225
- expect(response).to redirect_to(spree.forbidden_path)
226
- end
227
-
228
- it 'should restrict returned order(s) on index when using OrderSpecificAbility' do
229
- number = order.number
230
-
231
- 3.times { create(:completed_order_with_totals) }
232
- expect(Spree::Order.complete.count).to eq 4
233
-
234
- with_ability(OrderSpecificAbility) do
235
- allow(user).to receive_messages has_spree_role?: false
236
- spree_get :index
237
- expect(response).to render_template :index
238
- expect(assigns['orders'].size).to eq 1
239
- expect(assigns['orders'].first.number).to eq number
240
- expect(Spree::Order.accessible_by(Spree::Ability.new(user), :index).pluck(:number)).to eq [number]
241
- end
242
- end
243
- end
244
-
245
- context "order number not given" do
246
- stub_authorization!
247
-
248
- it "raise active record not found" do
249
- expect {
250
- spree_get :edit, id: 99999999
251
- }.to raise_error ActiveRecord::RecordNotFound
252
- end
253
- end
254
- end