solidus_backend 1.0.7 → 1.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +3 -0
  3. data/app/assets/javascripts/spree/backend/admin.js.erb +17 -24
  4. data/app/assets/javascripts/spree/backend/checkouts/edit.js +3 -5
  5. data/app/assets/javascripts/spree/backend/flash.coffee +17 -0
  6. data/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +9 -0
  7. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +6 -6
  8. data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
  9. data/app/assets/javascripts/spree/backend/product_picker.js +10 -8
  10. data/app/assets/javascripts/spree/backend/promotions.js.coffee +101 -0
  11. data/app/assets/javascripts/spree/backend/routes.js +2 -1
  12. data/app/assets/javascripts/spree/backend/shipments.js.erb +1 -1
  13. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +1 -1
  14. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +2 -2
  15. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +1 -1
  16. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +6 -6
  17. data/app/assets/javascripts/spree/backend/taxons.js.coffee +6 -7
  18. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
  19. data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
  20. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +17 -0
  21. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +17 -0
  22. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +10 -0
  23. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +1 -0
  24. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +19 -0
  25. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs.erb +52 -0
  26. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +23 -0
  27. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +51 -0
  28. data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +67 -0
  29. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
  30. data/app/assets/javascripts/spree/backend/user_picker.js +8 -8
  31. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +6 -8
  32. data/app/assets/stylesheets/spree/backend/components/_messages.scss +6 -3
  33. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +16 -0
  34. data/app/controllers/spree/admin/base_controller.rb +1 -1
  35. data/app/controllers/spree/admin/option_types_controller.rb +1 -3
  36. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  37. data/app/controllers/spree/admin/orders_controller.rb +6 -11
  38. data/app/controllers/spree/admin/product_properties_controller.rb +9 -0
  39. data/app/controllers/spree/admin/products_controller.rb +20 -5
  40. data/app/controllers/spree/admin/promotions_controller.rb +2 -1
  41. data/app/controllers/spree/admin/reimbursements_controller.rb +20 -0
  42. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  43. data/app/controllers/spree/admin/return_authorizations_controller.rb +5 -0
  44. data/app/controllers/spree/admin/root_controller.rb +1 -1
  45. data/app/controllers/spree/admin/search_controller.rb +2 -4
  46. data/app/controllers/spree/admin/states_controller.rb +1 -1
  47. data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
  48. data/app/controllers/spree/admin/stock_transfers_controller.rb +3 -14
  49. data/app/controllers/spree/admin/users_controller.rb +2 -3
  50. data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +7 -0
  51. data/app/controllers/spree/admin/variants_controller.rb +1 -1
  52. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  53. data/app/helpers/spree/admin/adjustments_helper.rb +4 -9
  54. data/app/helpers/spree/admin/base_helper.rb +7 -6
  55. data/app/helpers/spree/admin/navigation_helper.rb +8 -2
  56. data/app/helpers/spree/admin/orders_helper.rb +1 -1
  57. data/app/helpers/spree/admin/products_helper.rb +2 -4
  58. data/app/helpers/spree/admin/stock_movements_helper.rb +3 -3
  59. data/app/views/spree/admin/adjustments/_adjustment.html.erb +1 -1
  60. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -5
  61. data/app/views/spree/admin/orders/_add_product.html.erb +0 -3
  62. data/app/views/spree/admin/orders/_carton.html.erb +0 -1
  63. data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
  64. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +0 -1
  65. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  66. data/app/views/spree/admin/orders/customer_details/edit.html.erb +0 -1
  67. data/app/views/spree/admin/orders/index.html.erb +1 -2
  68. data/app/views/spree/admin/payment_methods/_form.html.erb +0 -4
  69. data/app/views/spree/admin/payment_methods/index.html.erb +0 -2
  70. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +3 -0
  71. data/app/views/spree/admin/product_properties/index.html.erb +52 -2
  72. data/app/views/spree/admin/promotions/_actions.html.erb +14 -10
  73. data/app/views/spree/admin/promotions/_promotion_action.html.erb +5 -3
  74. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +5 -3
  75. data/app/views/spree/admin/promotions/_rules.html.erb +18 -14
  76. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -28
  77. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -27
  78. data/app/views/spree/admin/promotions/edit.html.erb +6 -4
  79. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  80. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
  81. data/app/views/spree/admin/refund_reasons/index.html.erb +2 -2
  82. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  83. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  84. data/app/views/spree/admin/search/users.rabl +1 -1
  85. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  86. data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
  87. data/app/views/spree/admin/shared/_translations.html.erb +16 -46
  88. data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
  89. data/app/views/spree/admin/stock_items/_stock_management.html.erb +0 -2
  90. data/app/views/spree/admin/stock_movements/_form.html.erb +0 -2
  91. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -3
  92. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -2
  93. data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
  94. data/app/views/spree/admin/taxons/index.html.erb +0 -1
  95. data/app/views/spree/admin/users/_addresses_form.html.erb +4 -4
  96. data/app/views/spree/layouts/admin.html.erb +11 -9
  97. data/config/routes.rb +5 -0
  98. data/lib/spree/backend.rb +1 -2
  99. metadata +41 -139
  100. data/CHANGELOG.md +0 -1
  101. data/Gemfile +0 -6
  102. data/Rakefile +0 -15
  103. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +0 -9
  104. data/app/assets/javascripts/spree/backend/promotions.js +0 -73
  105. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -196
  106. data/app/views/spree/admin/products/_autocomplete.js.erb +0 -14
  107. data/app/views/spree/admin/products/_sortable.html +0 -7
  108. data/app/views/spree/admin/stock_items/_stock_location_stock_item_template.html.erb +0 -21
  109. data/app/views/spree/admin/stock_transfers/_transfer_item_template.html.erb +0 -54
  110. data/app/views/spree/admin/variants/_autocomplete.js.erb +0 -25
  111. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +0 -69
  112. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -53
  113. data/app/views/spree/admin/variants/_split.js.erb +0 -29
  114. data/script/rails +0 -9
  115. data/solidus_backend.gemspec +0 -30
  116. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -24
  117. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -77
  118. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -234
  119. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  120. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  121. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -80
  122. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -472
  123. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  124. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -175
  125. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -45
  126. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  127. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -18
  128. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  129. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  130. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  131. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -75
  132. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -134
  133. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -166
  134. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -226
  135. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  136. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -41
  137. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -104
  138. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  139. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -50
  140. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  141. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -331
  142. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -309
  143. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -236
  144. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  145. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -54
  146. data/spec/features/admin/configuration/countries_spec.rb +0 -22
  147. data/spec/features/admin/configuration/general_settings_spec.rb +0 -45
  148. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -125
  149. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -64
  150. data/spec/features/admin/configuration/states_spec.rb +0 -64
  151. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -50
  152. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -30
  154. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -52
  155. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  156. data/spec/features/admin/homepage_spec.rb +0 -78
  157. data/spec/features/admin/locale_spec.rb +0 -30
  158. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  159. data/spec/features/admin/orders/adjustments_spec.rb +0 -126
  160. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -48
  161. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -48
  162. data/spec/features/admin/orders/customer_details_spec.rb +0 -163
  163. data/spec/features/admin/orders/line_items_spec.rb +0 -50
  164. data/spec/features/admin/orders/listing_spec.rb +0 -130
  165. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  166. data/spec/features/admin/orders/new_order_spec.rb +0 -197
  167. data/spec/features/admin/orders/order_details_spec.rb +0 -533
  168. data/spec/features/admin/orders/payments_spec.rb +0 -228
  169. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -47
  170. data/spec/features/admin/orders/shipments_spec.rb +0 -65
  171. data/spec/features/admin/payments/store_credits_spec.rb +0 -21
  172. data/spec/features/admin/products/edit/images_spec.rb +0 -87
  173. data/spec/features/admin/products/edit/products_spec.rb +0 -66
  174. data/spec/features/admin/products/edit/taxons_spec.rb +0 -56
  175. data/spec/features/admin/products/edit/variants_spec.rb +0 -61
  176. data/spec/features/admin/products/option_types_spec.rb +0 -114
  177. data/spec/features/admin/products/products_spec.rb +0 -392
  178. data/spec/features/admin/products/properties_spec.rb +0 -139
  179. data/spec/features/admin/products/prototypes_spec.rb +0 -110
  180. data/spec/features/admin/products/stock_management_spec.rb +0 -82
  181. data/spec/features/admin/products/variant_spec.rb +0 -51
  182. data/spec/features/admin/promotion_adjustments_spec.rb +0 -220
  183. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -69
  184. data/spec/features/admin/promotions/user_rule_spec.rb +0 -25
  185. data/spec/features/admin/reports_spec.rb +0 -61
  186. data/spec/features/admin/stock_transfer_spec.rb +0 -86
  187. data/spec/features/admin/store_credits_spec.rb +0 -82
  188. data/spec/features/admin/taxons_spec.rb +0 -31
  189. data/spec/features/admin/users_spec.rb +0 -270
  190. data/spec/helpers/admin/base_helper_spec.rb +0 -24
  191. data/spec/helpers/admin/navigation_helper_spec.rb +0 -73
  192. data/spec/helpers/admin/reimbursements_helper_spec.rb +0 -34
  193. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  194. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -95
  195. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  196. data/spec/spec_helper.rb +0 -108
  197. data/spec/support/appear_before_matcher.rb +0 -8
  198. data/spec/support/ror_ringer.jpeg +0 -0
  199. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  200. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  201. data/vendor/assets/javascripts/handlebars.js +0 -2746
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Spree
4
- class GatewayWithPassword < PaymentMethod
5
- preference :password, :string, :default => "password"
6
- end
7
-
8
- describe Admin::PaymentMethodsController, :type => :controller do
9
- stub_authorization!
10
-
11
- let(:payment_method) { GatewayWithPassword.create!(:name => "Bogus", :preferred_password => "haxme") }
12
-
13
- # regression test for #2094
14
- it "does not clear password on update" do
15
- expect(payment_method.preferred_password).to eq("haxme")
16
- spree_put :update, :id => payment_method.id, :payment_method => { :type => payment_method.class.to_s, :preferred_password => "" }
17
- expect(response).to redirect_to(spree.edit_admin_payment_method_path(payment_method))
18
-
19
- payment_method.reload
20
- expect(payment_method.preferred_password).to eq("haxme")
21
- end
22
-
23
- context "tries to save invalid payment" do
24
- it "doesn't break, responds nicely" do
25
- expect {
26
- spree_post :create, :payment_method => { :name => "", :type => "Spree::Gateway::Bogus" }
27
- }.not_to raise_error
28
- end
29
- end
30
-
31
- it "can create a payment method of a valid type" do
32
- expect {
33
- spree_post :create, :payment_method => { :name => "Test Method", :type => "Spree::Gateway::Bogus" }
34
- }.to change(Spree::PaymentMethod, :count).by(1)
35
-
36
- expect(response).to be_redirect
37
- expect(response).to redirect_to spree.edit_admin_payment_method_path(assigns(:payment_method))
38
- end
39
-
40
- it "can not create a payment method of an invalid type" do
41
- expect {
42
- spree_post :create, :payment_method => { :name => "Invalid Payment Method", :type => "Spree::InvalidType" }
43
- }.to change(Spree::PaymentMethod, :count).by(0)
44
-
45
- expect(response).to be_redirect
46
- expect(response).to redirect_to spree.new_admin_payment_method_path
47
- end
48
- end
49
- end
@@ -1,175 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Spree
4
- module Admin
5
- describe PaymentsController, :type => :controller do
6
- before do
7
- allow(controller).to receive_messages :spree_current_user => user
8
- end
9
-
10
- let(:user) { create(:admin_user) }
11
- let(:order) { create(:order) }
12
-
13
- context "with a valid credit card" do
14
- let(:order) { create(:order_with_line_items, :state => "payment") }
15
- let(:payment_method) { create(:credit_card_payment_method, :display_on => "back_end") }
16
- let(:attributes) do
17
- {
18
- :order_id => order.number,
19
- :card => "new",
20
- :payment => {
21
- :amount => order.total,
22
- :payment_method_id => payment_method.id.to_s,
23
- :source_attributes => {
24
- :name => "Test User",
25
- :number => "4111 1111 1111 1111",
26
- :expiry => "09 / #{Time.now.year + 1}",
27
- :verification_value => "123"
28
- }
29
- }
30
- }
31
- end
32
-
33
- before do
34
- spree_post :create, attributes
35
- end
36
-
37
- it "should process payment correctly" do
38
- expect(order.payments.count).to eq(1)
39
- expect(order.payments.last.state).to eq 'checkout'
40
- expect(response).to redirect_to(spree.admin_order_payments_path(order))
41
- expect(order.reload.state).to eq('confirm')
42
- end
43
-
44
- context 'with credit card address fields' do
45
- let(:address) { build(:address) }
46
-
47
- let(:attributes) do
48
- attrs = super()
49
- attrs[:payment][:source_attributes][:address_attributes] = address_attributes
50
- attrs
51
- end
52
-
53
- let(:address_attributes) do
54
- {
55
- 'firstname' => address.firstname,
56
- 'lastname' => address.lastname,
57
- 'address1' => address.address1,
58
- 'city' => address.city,
59
- 'country_id' => address.country_id,
60
- 'state_id' => address.state_id,
61
- 'zipcode' => address.zipcode,
62
- 'phone' => address.phone,
63
- }
64
- end
65
-
66
- it 'associates the address' do
67
- expect(order.payments.count).to eq(1)
68
- credit_card = order.payments.last.source
69
- expect(credit_card.address.attributes).to include(address_attributes)
70
- end
71
- end
72
- end
73
-
74
- # Regression test for #3233
75
- context "with a backend payment method" do
76
- before do
77
- @payment_method = create(:check_payment_method, :display_on => "back_end")
78
- end
79
-
80
- it "loads backend payment methods" do
81
- spree_get :new, :order_id => order.number
82
- expect(response.status).to eq(200)
83
- expect(assigns[:payment_methods]).to include(@payment_method)
84
- end
85
- end
86
-
87
- context "order has billing address" do
88
- before do
89
- order.bill_address = create(:address)
90
- order.save!
91
- end
92
-
93
- context "order does not have payments" do
94
- it "redirect to new payments page" do
95
- spree_get :index, { amount: 100, order_id: order.number }
96
- expect(response).to redirect_to(spree.new_admin_order_payment_path(order))
97
- end
98
- end
99
-
100
- context "order has payments" do
101
- before do
102
- order.payments << create(:payment, amount: order.total, order: order, state: 'completed')
103
- end
104
-
105
- it "shows the payments page" do
106
- spree_get :index, { amount: 100, order_id: order.number }
107
- expect(response.code).to eq "200"
108
- end
109
- end
110
-
111
- end
112
-
113
- context "order does not have a billing address" do
114
- before do
115
- order.bill_address = nil
116
- order.save
117
- end
118
-
119
- it "should redirect to the customer details page" do
120
- spree_get :index, { amount: 100, order_id: order.number }
121
- expect(response).to redirect_to(spree.edit_admin_order_customer_path(order))
122
- end
123
- end
124
-
125
- describe 'fire' do
126
- describe 'authorization' do
127
- let(:payment) { create(:payment, state: 'checkout') }
128
- let(:order) { payment.order }
129
-
130
- context 'the user is authorized' do
131
- class CaptureAllowedAbility
132
- include CanCan::Ability
133
-
134
- def initialize(user)
135
- can :capture, Spree::Payment
136
- end
137
- end
138
-
139
- before do
140
- Spree::Ability.register_ability(CaptureAllowedAbility)
141
- end
142
-
143
- it 'allows the action' do
144
- expect {
145
- spree_post(:fire, id: payment.to_param, e: 'capture', order_id: order.to_param)
146
- }.to change { payment.reload.state }.from('checkout').to('completed')
147
- end
148
- end
149
-
150
- context 'the user is not authorized' do
151
- class CaptureNotAllowedAbility
152
- include CanCan::Ability
153
-
154
- def initialize(user)
155
- cannot :capture, Spree::Payment
156
- end
157
- end
158
-
159
- before do
160
- Spree::Ability.register_ability(CaptureNotAllowedAbility)
161
- end
162
-
163
- it 'does not allow the action' do
164
- expect {
165
- spree_post(:fire, id: payment.to_param, e: 'capture', order_id: order.to_param)
166
- }.to_not change { payment.reload.state }
167
- expect(flash[:error]).to eq('Authorization Failure')
168
- end
169
- end
170
- end
171
- end
172
-
173
- end
174
- end
175
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::ProductsController, :type => :controller do
4
- stub_authorization!
5
-
6
- context "#index" do
7
- let(:ability_user) { stub_model(Spree::LegacyUser, :has_spree_role? => true) }
8
-
9
- # Regression test for #1259
10
- it "can find a product by SKU" do
11
- product = create(:product, :sku => "ABC123")
12
- spree_get :index, :q => { :sku_start => "ABC123" }
13
- expect(assigns[:collection]).not_to be_empty
14
- expect(assigns[:collection]).to include(product)
15
- end
16
- end
17
-
18
- # regression test for #1370
19
- context "adding properties to a product" do
20
- let!(:product) { create(:product) }
21
- specify do
22
- spree_put :update, :id => product.to_param, :product => { :product_properties_attributes => { "1" => { :property_name => "Foo", :value => "bar" } } }
23
- expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
24
- end
25
-
26
- end
27
-
28
-
29
- # regression test for #801
30
- context "destroying a product" do
31
- let(:product) do
32
- product = create(:product)
33
- create(:variant, :product => product)
34
- product
35
- end
36
-
37
- it "deletes all the variants (including master) for the product" do
38
- spree_delete :destroy, :id => product
39
- expect(product.reload.deleted_at).not_to be_nil
40
- product.variants_including_master.each do |variant|
41
- expect(variant.reload.deleted_at).not_to be_nil
42
- end
43
- end
44
- end
45
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::PromotionActionsController, :type => :controller do
4
- stub_authorization!
5
-
6
- let!(:promotion) { create(:promotion) }
7
-
8
- it "can create a promotion action of a valid type" do
9
- spree_post :create, :promotion_id => promotion.id, :action_type => "Spree::Promotion::Actions::CreateAdjustment"
10
- expect(response).to be_redirect
11
- expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
12
- expect(promotion.actions.count).to eq(1)
13
- end
14
-
15
- it "can not create a promotion action of an invalid type" do
16
- spree_post :create, :promotion_id => promotion.id, :action_type => "Spree::InvalidType"
17
- expect(response).to be_redirect
18
- expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
19
- expect(promotion.rules.count).to eq(0)
20
- end
21
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::PromotionCodesController do
4
- stub_authorization!
5
- render_views
6
-
7
- let!(:promotion) { create(:promotion) }
8
- let!(:code1) { create(:promotion_code, promotion: promotion) }
9
- let!(:code2) { create(:promotion_code, promotion: promotion) }
10
- let!(:code3) { create(:promotion_code, promotion: promotion) }
11
-
12
- it "can create a promotion rule of a valid type" do
13
- spree_get :index, promotion_id: promotion.id, format: 'csv'
14
- expect(response).to be_success
15
- parsed = CSV.parse(response.body, headers: true)
16
- expect(parsed.entries.map(&:to_h)).to eq([{"Code" => code1.value}, {"Code" => code2.value}, {"Code" => code3.value}])
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::PromotionRulesController, :type => :controller do
4
- stub_authorization!
5
-
6
- let!(:promotion) { create(:promotion) }
7
-
8
- it "can create a promotion rule of a valid type" do
9
- spree_post :create, :promotion_id => promotion.id, :promotion_rule => { :type => "Spree::Promotion::Rules::Product" }
10
- expect(response).to be_redirect
11
- expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
12
- expect(promotion.rules.count).to eq(1)
13
- end
14
-
15
- it "can not create a promotion rule of an invalid type" do
16
- spree_post :create, :promotion_id => promotion.id, :promotion_rule => { :type => "Spree::InvalidType" }
17
- expect(response).to be_redirect
18
- expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
19
- expect(promotion.rules.count).to eq(0)
20
- end
21
- end
@@ -1,122 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::Admin::PromotionsController, :type => :controller do
4
- stub_authorization!
5
-
6
- let!(:promotion1) { create(:promotion, name: "name1", code: "code1", path: "path1") }
7
- let!(:promotion2) { create(:promotion, name: "name2", code: "code2", path: "path2") }
8
- let!(:category) { create :promotion_category }
9
-
10
- describe "#index" do
11
-
12
- it "succeeds" do
13
- spree_get :index
14
- expect(assigns[:promotions]).to match_array [promotion2, promotion1]
15
- end
16
-
17
- it "assigns promotion categories" do
18
- spree_get :index
19
- expect(assigns[:promotion_categories]).to match_array [category]
20
- end
21
-
22
- context "search" do
23
- it "pages results" do
24
- spree_get :index, per_page: '1'
25
- expect(assigns[:promotions]).to eq [promotion2]
26
- end
27
-
28
- it "filters by name" do
29
- spree_get :index, q: {name_cont: promotion1.name}
30
- expect(assigns[:promotions]).to eq [promotion1]
31
- end
32
-
33
- it "filters by code" do
34
- spree_get :index, q: {codes_value_cont: promotion1.codes.first.value }
35
- expect(assigns[:promotions]).to eq [promotion1]
36
- end
37
-
38
- it "filters by path" do
39
- spree_get :index, q: {path_cont: promotion1.path}
40
- expect(assigns[:promotions]).to eq [promotion1]
41
- end
42
- end
43
- end
44
-
45
- describe "#create" do
46
- subject { spree_post :create, params }
47
- let(:params) { {promotion: {name: 'some promo'}} }
48
-
49
- context "it succeeds" do
50
- it "creates a promotion" do
51
- expect { subject }.to change { Spree::Promotion.count }.by(1)
52
- end
53
-
54
- it "sets the flash message" do
55
- subject
56
- expect(flash[:success]).to eq "Promotion has been successfully created!"
57
- end
58
-
59
- it "redirects to promotion edit" do
60
- subject
61
- expect(response).to redirect_to "http://test.host/admin/promotions/#{assigns(:promotion).id}/edit"
62
- end
63
-
64
- context "with one promo codes" do
65
- let(:params) do
66
- super().merge(promotion_builder: { base_code: 'abc', number_of_codes: 1 })
67
- end
68
-
69
- it "succeeds and creates one code" do
70
- expect {
71
- expect {
72
- subject
73
- }.to change { Spree::Promotion.count }.by(1)
74
- }.to change { Spree::PromotionCode.count }.by(1)
75
-
76
- expect(assigns(:promotion).codes.first.value).to eq ('abc')
77
- end
78
- end
79
-
80
- context "with multiple promo codes" do
81
- let(:params) do
82
- super().merge(promotion_builder: { base_code: 'abc', number_of_codes: 2 })
83
- end
84
-
85
- it "succeeds and creates multiple codes" do
86
- expect {
87
- expect {
88
- subject
89
- }.to change { Spree::Promotion.count }.by(1)
90
- }.to change { Spree::PromotionCode.count }.by(2)
91
-
92
- codes = assigns(:promotion).codes.map(&:value).sort
93
- expect(codes.length).to be 2
94
- expect(codes[0]).to match(/abc_[a-z]{6}/)
95
- expect(codes[1]).to match(/abc_[a-z]{6}/)
96
- end
97
- end
98
- end
99
-
100
- context "it fails" do
101
- let(:params) { {} }
102
-
103
- it "does not create a promotion" do
104
- expect {
105
- subject
106
- }.not_to change { Spree::Promotion.count }
107
- end
108
-
109
- it "sets the flash error" do
110
- subject
111
- expect(flash[:error]).to eq "Name can't be blank"
112
- end
113
-
114
- it "renders new" do
115
- subject
116
- expect(response).to render_template :new
117
- end
118
- end
119
-
120
- end
121
-
122
- end