solidus_backend 1.1.0 → 1.1.1

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/Rakefile +15 -0
  4. data/script/rails +9 -0
  5. data/solidus_backend.gemspec +30 -0
  6. data/spec/controllers/spree/admin/base_controller_spec.rb +24 -0
  7. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +77 -0
  8. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +234 -0
  9. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
  10. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
  11. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +80 -0
  12. data/spec/controllers/spree/admin/orders_controller_spec.rb +460 -0
  13. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
  14. data/spec/controllers/spree/admin/payments_controller_spec.rb +175 -0
  15. data/spec/controllers/spree/admin/product_properties_controller_spec.rb +69 -0
  16. data/spec/controllers/spree/admin/products_controller_spec.rb +162 -0
  17. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
  18. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +18 -0
  19. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
  20. data/spec/controllers/spree/admin/promotions_controller_spec.rb +122 -0
  21. data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
  22. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +124 -0
  23. data/spec/controllers/spree/admin/reports_controller_spec.rb +134 -0
  24. data/spec/controllers/spree/admin/resource_controller_spec.rb +166 -0
  25. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +240 -0
  26. data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
  27. data/spec/controllers/spree/admin/root_controller_spec.rb +41 -0
  28. data/spec/controllers/spree/admin/search_controller_spec.rb +104 -0
  29. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
  30. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +50 -0
  31. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
  32. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +351 -0
  33. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +309 -0
  34. data/spec/controllers/spree/admin/users_controller_spec.rb +257 -0
  35. data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
  36. data/spec/features/admin/configuration/analytics_tracker_spec.rb +50 -0
  37. data/spec/features/admin/configuration/countries_spec.rb +22 -0
  38. data/spec/features/admin/configuration/general_settings_spec.rb +45 -0
  39. data/spec/features/admin/configuration/payment_methods_spec.rb +124 -0
  40. data/spec/features/admin/configuration/shipping_methods_spec.rb +64 -0
  41. data/spec/features/admin/configuration/states_spec.rb +64 -0
  42. data/spec/features/admin/configuration/stock_locations_spec.rb +50 -0
  43. data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
  44. data/spec/features/admin/configuration/tax_rates_spec.rb +30 -0
  45. data/spec/features/admin/configuration/taxonomies_spec.rb +52 -0
  46. data/spec/features/admin/configuration/zones_spec.rb +39 -0
  47. data/spec/features/admin/homepage_spec.rb +78 -0
  48. data/spec/features/admin/locale_spec.rb +30 -0
  49. data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
  50. data/spec/features/admin/orders/adjustments_spec.rb +126 -0
  51. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +48 -0
  52. data/spec/features/admin/orders/cancelling_inventory_spec.rb +48 -0
  53. data/spec/features/admin/orders/customer_details_spec.rb +163 -0
  54. data/spec/features/admin/orders/line_items_spec.rb +50 -0
  55. data/spec/features/admin/orders/listing_spec.rb +130 -0
  56. data/spec/features/admin/orders/log_entries_spec.rb +55 -0
  57. data/spec/features/admin/orders/new_order_spec.rb +185 -0
  58. data/spec/features/admin/orders/order_details_spec.rb +533 -0
  59. data/spec/features/admin/orders/payments_spec.rb +234 -0
  60. data/spec/features/admin/orders/risk_analysis_spec.rb +47 -0
  61. data/spec/features/admin/orders/shipments_spec.rb +65 -0
  62. data/spec/features/admin/payments/store_credits_spec.rb +21 -0
  63. data/spec/features/admin/products/edit/images_spec.rb +87 -0
  64. data/spec/features/admin/products/edit/products_spec.rb +66 -0
  65. data/spec/features/admin/products/edit/taxons_spec.rb +43 -0
  66. data/spec/features/admin/products/edit/variants_spec.rb +61 -0
  67. data/spec/features/admin/products/option_types_spec.rb +114 -0
  68. data/spec/features/admin/products/products_spec.rb +395 -0
  69. data/spec/features/admin/products/properties_spec.rb +139 -0
  70. data/spec/features/admin/products/prototypes_spec.rb +110 -0
  71. data/spec/features/admin/products/stock_management_spec.rb +82 -0
  72. data/spec/features/admin/products/variant_spec.rb +51 -0
  73. data/spec/features/admin/promotion_adjustments_spec.rb +220 -0
  74. data/spec/features/admin/promotions/option_value_rule_spec.rb +65 -0
  75. data/spec/features/admin/promotions/tiered_calculator_spec.rb +69 -0
  76. data/spec/features/admin/reports_spec.rb +61 -0
  77. data/spec/features/admin/stock_transfer_spec.rb +104 -0
  78. data/spec/features/admin/store_credits_spec.rb +82 -0
  79. data/spec/features/admin/taxons_spec.rb +31 -0
  80. data/spec/features/admin/users_spec.rb +275 -0
  81. data/spec/helpers/admin/base_helper_spec.rb +18 -0
  82. data/spec/helpers/admin/navigation_helper_spec.rb +73 -0
  83. data/spec/helpers/admin/reimbursements_helper_spec.rb +34 -0
  84. data/spec/helpers/admin/stock_movements_helper_spec.rb +29 -0
  85. data/spec/helpers/admin/store_credit_events_helper_spec.rb +95 -0
  86. data/spec/helpers/promotion_rules_helper_spec.rb +12 -0
  87. data/spec/spec_helper.rb +116 -0
  88. data/spec/support/appear_before_matcher.rb +8 -0
  89. data/spec/support/ror_ringer.jpeg +0 -0
  90. data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
  91. data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
  92. metadata +96 -6
@@ -0,0 +1,234 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Payments', :type => :feature do
4
+ stub_authorization!
5
+
6
+ context "with a pre-existing payment" do
7
+
8
+ let!(:payment) do
9
+ create(:payment,
10
+ order: order,
11
+ amount: order.outstanding_balance,
12
+ payment_method: create(:credit_card_payment_method),
13
+ state: state
14
+ )
15
+ end
16
+
17
+ let(:order) { create(:completed_order_with_totals, number: 'R100', line_items_count: 5) }
18
+ let(:state) { 'checkout' }
19
+
20
+ before do
21
+ visit spree.admin_path
22
+ click_link 'Orders'
23
+ within_row(1) do
24
+ click_link order.number
25
+ end
26
+ click_link 'Payments'
27
+ end
28
+
29
+ def refresh_page
30
+ visit current_path
31
+ end
32
+
33
+ # Regression tests for #1453
34
+ context 'with a check payment' do
35
+ let(:order) { create(:completed_order_with_totals, number: 'R100') }
36
+ let!(:payment) do
37
+ create(:payment,
38
+ order: order,
39
+ amount: order.outstanding_balance,
40
+ payment_method: create(:check_payment_method) # Check
41
+ )
42
+ end
43
+
44
+ it 'capturing a check payment from a new order' do
45
+ click_icon(:capture)
46
+ expect(page).not_to have_content('Cannot perform requested operation')
47
+ expect(page).to have_content('Payment Updated')
48
+ end
49
+
50
+ it 'voids a check payment from a new order' do
51
+ click_icon(:void)
52
+ expect(page).to have_content('Payment Updated')
53
+ end
54
+ end
55
+
56
+ it 'should list all captures for a payment' do
57
+ capture_amount = order.outstanding_balance/2 * 100
58
+ payment.capture!(capture_amount)
59
+
60
+ visit spree.admin_order_payment_path(order, payment)
61
+ expect(page).to have_content 'Capture events'
62
+ # within '#capture_events' do
63
+ within_row(1) do
64
+ expect(page).to have_content(capture_amount / 100)
65
+ end
66
+ # end
67
+ end
68
+
69
+ it 'displays the address for a credit card when present' do
70
+ payment.source.update!(address: create(:address, address1: 'my cc address'))
71
+ visit spree.admin_order_payment_path(order, payment)
72
+ expect(page).to have_content 'my cc address'
73
+ end
74
+
75
+ it 'lists and create payments for an order', js: true do
76
+ within_row(1) do
77
+ expect(column_text(3)).to eq('$150.00')
78
+ expect(column_text(4)).to eq('Credit Card')
79
+ expect(column_text(6)).to eq('CHECKOUT')
80
+ end
81
+
82
+ click_icon :void
83
+ expect(find('#payment_status').text).to eq('BALANCE DUE')
84
+ expect(page).to have_content('Payment Updated')
85
+
86
+ within_row(1) do
87
+ expect(column_text(3)).to eq('$150.00')
88
+ expect(column_text(4)).to eq('Credit Card')
89
+ expect(column_text(6)).to eq('VOID')
90
+ end
91
+
92
+ click_on 'New Payment'
93
+ expect(page).to have_content('New Payment')
94
+ click_button 'Update'
95
+ expect(page).to have_content('successfully created!')
96
+
97
+ click_icon(:capture)
98
+ expect(find('#payment_status').text).to eq('PAID')
99
+
100
+ expect(page).not_to have_selector('#new_payment_section')
101
+ end
102
+
103
+ # Regression test for #1269
104
+ it 'cannot create a payment for an order with no payment methods' do
105
+ Spree::PaymentMethod.delete_all
106
+ order.payments.delete_all
107
+
108
+ click_on 'New Payment'
109
+ expect(page).to have_content('You cannot create a payment for an order without any payment methods defined.')
110
+ expect(page).to have_content('Please define some payment methods first.')
111
+ end
112
+
113
+ context 'payment is pending', js: true do
114
+ let(:state) { 'pending' }
115
+
116
+ it 'allows the amount to be edited by clicking on the edit button then saving' do
117
+ within_row(1) do
118
+ click_icon(:edit)
119
+ fill_in('amount', with: '$1')
120
+ expect(page).to have_selector('td.amount span', text: '$1.00')
121
+ expect(payment.reload.amount).to eq(1.00)
122
+ end
123
+ end
124
+
125
+ it 'allows the amount to be edited by clicking on the amount then saving' do
126
+ within_row(1) do
127
+ find('td.amount span').click
128
+ fill_in('amount', with: '$1.01')
129
+ expect(page).to have_selector('td.amount span', text: '$1.01')
130
+ expect(payment.reload.amount).to eq(1.01)
131
+ end
132
+ end
133
+
134
+ it 'allows the amount change to be cancelled by clicking on the cancel button' do
135
+ within_row(1) do
136
+ click_icon(:edit)
137
+
138
+ # Can't use fill_in here, as under poltergeist that will unfocus (and
139
+ # thus submit) the field under poltergeist
140
+ find('td.amount input').click
141
+ page.execute_script("$('td.amount input').val('$1')")
142
+
143
+ click_icon(:cancel)
144
+ expect(page).to have_selector('td.amount span', text: '$150.00')
145
+ expect(payment.reload.amount).to eq(150.00)
146
+ end
147
+ end
148
+
149
+ it 'displays an error when the amount is invalid' do
150
+ within_row(1) do
151
+ click_icon(:edit)
152
+ fill_in('amount', with: 'invalid')
153
+ expect(find('td.amount input').value).to eq('invalid')
154
+ expect(payment.reload.amount).to eq(150.00)
155
+ end
156
+ expect(page).to have_selector('.flash.error', text: 'Invalid resource. Please fix errors and try again.')
157
+ end
158
+ end
159
+
160
+ context 'payment is completed', js: true do
161
+ let(:state) { 'completed' }
162
+
163
+ it 'does not allow the amount to be edited' do
164
+ within_row(1) do
165
+ expect(page).not_to have_selector('.fa-edit')
166
+ expect(page).not_to have_selector('td.amount span')
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ context "with no prior payments" do
173
+ let(:order) { create(:order_with_line_items, :line_items_count => 1) }
174
+ let!(:payment_method) { create(:credit_card_payment_method)}
175
+
176
+ # Regression tests for #4129
177
+ context "with a credit card payment method" do
178
+ before do
179
+ visit spree.admin_order_payments_path(order)
180
+ end
181
+
182
+ it "is able to create a new credit card payment with valid information", :js => true do
183
+ fill_in "Card Number", :with => "4111 1111 1111 1111"
184
+ fill_in "Name", :with => "Test User"
185
+ fill_in "Expiration", :with => "09 / #{Time.now.year + 1}"
186
+ fill_in "Card Code", :with => "007"
187
+ # Regression test for #4277
188
+ expect(page).to have_css('.ccType[value="visa"]', visible: false)
189
+ click_button "Continue"
190
+ expect(page).to have_content("Payment has been successfully created!")
191
+ end
192
+
193
+ it "is unable to create a new payment with invalid information" do
194
+ click_button "Continue"
195
+ expect(page).to have_content("Payment could not be created.")
196
+ expect(page).to have_content("Number can't be blank")
197
+ expect(page).to have_content("Name can't be blank")
198
+ expect(page).to have_content("Verification Value can't be blank")
199
+ expect(page).to have_content("Month is not a number")
200
+ expect(page).to have_content("Year is not a number")
201
+ end
202
+ end
203
+
204
+ context "user existing card" do
205
+ let!(:cc) do
206
+ create(:credit_card, user_id: order.user_id, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE")
207
+ end
208
+
209
+ before { visit spree.admin_order_payments_path(order) }
210
+
211
+ it "is able to reuse customer payment source" do
212
+ expect(find("#card_#{cc.id}")).to be_checked
213
+ click_button "Continue"
214
+ expect(page).to have_content("Payment has been successfully created!")
215
+ end
216
+ end
217
+
218
+ context "with a check" do
219
+ let(:order) { create(:completed_order_with_totals, :line_items_count => 1) }
220
+ let!(:payment_method) { create(:check_payment_method) }
221
+
222
+ before do
223
+ visit spree.admin_order_payments_path(order.reload)
224
+ end
225
+
226
+ it "can successfully be created and captured" do
227
+ click_on 'Update'
228
+ expect(page).to have_content("Payment has been successfully created!")
229
+ click_icon(:capture)
230
+ expect(page).to have_content("Payment Updated")
231
+ end
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Order Risk Analysis', :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:order) do
7
+ create(:completed_order_with_pending_payment)
8
+ end
9
+
10
+ def visit_order
11
+ visit spree.admin_path
12
+ click_link 'Orders'
13
+ within_row(1) do
14
+ click_link order.number
15
+ end
16
+ end
17
+
18
+ context "the order is considered risky" do
19
+ before do
20
+ allow_any_instance_of(Spree::Admin::BaseController).to receive_messages :try_spree_current_user => create(:user)
21
+
22
+ order.payments.first.update_column(:avs_response, 'N')
23
+ visit_order
24
+ end
25
+
26
+ it "displays 'Risk Analysis' box" do
27
+ expect(page).to have_content 'Risk Analysis'
28
+ end
29
+
30
+ it "can be approved" do
31
+ click_button('approve')
32
+ expect(page).to have_content 'Approver'
33
+ expect(page).to have_content 'Approved at'
34
+ expect(page).to have_content 'Status: complete'
35
+ end
36
+ end
37
+
38
+ context "the order is not considered risky" do
39
+ before do
40
+ visit_order
41
+ end
42
+
43
+ it "does not display 'Risk Analysis' box" do
44
+ expect(page).to_not have_content 'Risk Analysis'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Shipments", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:order) { create(:order_ready_to_ship, :number => "R100", :state => "complete", :line_items_count => 5) }
7
+
8
+ # Regression test for #4025
9
+ context "a shipment without a shipping method" do
10
+ before do
11
+ order.shipments.each do |s|
12
+ # Deleting the shipping rates causes there to be no shipping methods
13
+ s.shipping_rates.delete_all
14
+ end
15
+ end
16
+
17
+ it "can still be displayed" do
18
+ expect { visit spree.edit_admin_order_path(order) }.not_to raise_error
19
+ end
20
+ end
21
+
22
+ context "shipping an order", js: true do
23
+ before(:each) do
24
+ visit spree.admin_path
25
+ click_link "Orders"
26
+ within_row(1) do
27
+ click_link "R100"
28
+ end
29
+ end
30
+
31
+ it "can ship a completed order" do
32
+ find(".ship-shipment-button").click
33
+ wait_for_ajax
34
+
35
+ expect(page).to have_content("SHIPPED PACKAGE")
36
+ expect(order.reload.shipment_state).to eq("shipped")
37
+ end
38
+ end
39
+
40
+ context "moving variants between shipments", js: true do
41
+ let!(:order) { create(:completed_order_with_pending_payment, :number => "R100", :state => "complete", :line_items_count => 5) }
42
+ let!(:la) { create(:stock_location, name: "LA") }
43
+ before(:each) do
44
+ visit spree.admin_path
45
+ click_link "Orders"
46
+ within_row(1) do
47
+ click_link "R100"
48
+ end
49
+ end
50
+
51
+ it "can move a variant to a new and to an existing shipment" do
52
+ expect(order.shipments.count).to eq(1)
53
+
54
+ within_row(1) { click_icon 'arrows-h' }
55
+ targetted_select2 'LA', from: '#s2id_item_stock_location'
56
+ click_icon :ok
57
+ expect(page).to have_css("#shipment_#{order.shipments.first.id}")
58
+
59
+ within_row(2) { click_icon 'arrows-h' }
60
+ targetted_select2 "LA(#{order.reload.shipments.last.number})", from: '#s2id_item_stock_location'
61
+ click_icon :ok
62
+ expect(page).to have_css("#shipment_#{order.reload.shipments.last.id}")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Store credits', type: :feature do
4
+ stub_authorization!
5
+
6
+ let(:order) { FactoryGirl.create(:completed_order_with_totals) }
7
+ let(:payment) do
8
+ FactoryGirl.create(
9
+ :store_credit_payment,
10
+ order: order,
11
+ amount: 20
12
+ )
13
+ end
14
+
15
+ it "viewing a store credit payment" do
16
+ visit spree.admin_order_payment_path(order, payment)
17
+
18
+ expect(page).to have_content "Store Credit"
19
+ expect(page).to have_content "Amount: $20.00"
20
+ end
21
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Product Images", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let(:file_path) { Rails.root + "../../spec/support/ror_ringer.jpeg" }
7
+
8
+ before do
9
+ # Ensure attachment style keys are symbolized before running all tests
10
+ # Otherwise this would result in this error:
11
+ # undefined method `processors' for \"48x48>\
12
+ Spree::Image.attachment_definitions[:attachment][:styles].symbolize_keys!
13
+ end
14
+
15
+ context "uploading, editing, and deleting an image", :js => true do
16
+ it "should allow an admin to upload and edit an image for a product" do
17
+ Spree::Image.attachment_definitions[:attachment].delete :storage
18
+
19
+ create(:product)
20
+
21
+ visit spree.admin_path
22
+ click_link "Products"
23
+ click_icon(:edit)
24
+ click_link "Images"
25
+ click_link "new_image_link"
26
+ attach_file('image_attachment', file_path)
27
+ click_button "Update"
28
+ expect(page).to have_content("successfully created!")
29
+
30
+ click_icon(:edit)
31
+ fill_in "image_alt", :with => "ruby on rails t-shirt"
32
+ click_button "Update"
33
+ expect(page).to have_content("successfully updated!")
34
+ expect(page).to have_content("ruby on rails t-shirt")
35
+
36
+ accept_alert do
37
+ click_icon :trash
38
+ end
39
+ expect(page).not_to have_content("ruby on rails t-shirt")
40
+ end
41
+ end
42
+
43
+ # Regression test for #2228
44
+ it "should see variant images" do
45
+ variant = create(:variant)
46
+ variant.images.create!(:attachment => File.open(file_path))
47
+ visit spree.admin_product_images_path(variant.product)
48
+
49
+ expect(page).not_to have_content("No Images Found.")
50
+ within("table.index") do
51
+ expect(page).to have_content(variant.options_text)
52
+
53
+ #ensure no duplicate images are displayed
54
+ expect(page).to have_css("tbody tr", :count => 1)
55
+
56
+ #ensure variant header is displayed
57
+ within("thead") do
58
+ expect(page).to have_content("Variant")
59
+ end
60
+
61
+ #ensure variant header is displayed
62
+ within("tbody") do
63
+ expect(page).to have_content("Size: S")
64
+ end
65
+ end
66
+ end
67
+
68
+ it "should not see variant column when product has no variants" do
69
+ product = create(:product)
70
+ product.images.create!(:attachment => File.open(file_path))
71
+ visit spree.admin_product_images_path(product)
72
+
73
+ expect(page).not_to have_content("No Images Found.")
74
+ within("table.index") do
75
+ #ensure no duplicate images are displayed
76
+ expect(page).to have_css("tbody tr", :count => 1)
77
+
78
+ #ensure variant header is not displayed
79
+ within("thead") do
80
+ expect(page).not_to have_content("Variant")
81
+ end
82
+
83
+ #ensure correct cell count
84
+ expect(page).to have_css("thead th", :count => 3)
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Product Details', :type => :feature do
5
+ stub_authorization!
6
+
7
+ context 'editing a product' do
8
+ it 'should list the product details' do
9
+ create(:product, :name => 'Bún thịt nướng', :sku => 'A100',
10
+ :description => 'lorem ipsum', :available_on => '2013-08-14 01:02:03')
11
+
12
+ visit spree.admin_path
13
+ click_link 'Products'
14
+ within_row(1) { click_icon :edit }
15
+
16
+ click_link 'Product Details'
17
+
18
+ expect(find('.page-title').text.strip).to eq('Editing Product “Bún thịt nướng”')
19
+ expect(find('input#product_name').value).to eq('Bún thịt nướng')
20
+ expect(find('input#product_slug').value).to eq('bun-th-t-n-ng')
21
+ expect(find('textarea#product_description').text.strip).to eq('lorem ipsum')
22
+ expect(find('input#product_price').value).to eq('19.99')
23
+ expect(find('input#product_cost_price').value).to eq('17.00')
24
+ expect(find('input#product_available_on').value).to eq("2013/08/14")
25
+ expect(find('input#product_sku').value).to eq('A100')
26
+ end
27
+
28
+ it "should handle slug changes" do
29
+ create(:product, :name => 'Bún thịt nướng', :sku => 'A100',
30
+ :description => 'lorem ipsum', :available_on => '2011-01-01 01:01:01')
31
+
32
+ visit spree.admin_path
33
+ click_link 'Products'
34
+ within('table.index tbody tr:nth-child(1)') do
35
+ click_icon(:edit)
36
+ end
37
+
38
+ fill_in "product_slug", :with => 'random-slug-value'
39
+ click_button "Update"
40
+ expect(page).to have_content("successfully updated!")
41
+
42
+ fill_in "product_slug", :with => ''
43
+ click_button "Update"
44
+ within('#product_slug_field') { expect(page).to have_content("is too short") }
45
+
46
+ fill_in "product_slug", :with => 'another-random-slug-value'
47
+ click_button "Update"
48
+ expect(page).to have_content("successfully updated!")
49
+ end
50
+ end
51
+
52
+ # Regression test for #3385
53
+ context "deleting a product", :js => true do
54
+ it "is still able to find the master variant" do
55
+ create(:product)
56
+
57
+ visit spree.admin_products_path
58
+ within_row(1) do
59
+ accept_alert do
60
+ click_icon :trash
61
+ end
62
+ end
63
+ wait_for_ajax
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Product Taxons", :type => :feature do
4
+ stub_authorization!
5
+
6
+ after do
7
+ Capybara.ignore_hidden_elements = true
8
+ end
9
+
10
+ before do
11
+ Capybara.ignore_hidden_elements = false
12
+ end
13
+
14
+ context "managing taxons" do
15
+ def selected_taxons
16
+ find("#product_taxon_ids").value.split(',').map(&:to_i).uniq
17
+ end
18
+
19
+ it "should allow an admin to manage taxons", :js => true do
20
+ taxon_1 = create(:taxon)
21
+ taxon_2 = create(:taxon, :name => 'Clothing')
22
+ product = create(:product)
23
+ product.taxons << taxon_1
24
+
25
+ visit spree.admin_path
26
+ click_link "Products"
27
+ within("table.index") do
28
+ click_icon :edit
29
+ end
30
+
31
+ expect(find(".select2-search-choice").text).to eq(taxon_1.name)
32
+ expect(selected_taxons).to match_array([taxon_1.id])
33
+
34
+ select2_search "Clothing", :from => "Taxons"
35
+ click_button "Update"
36
+ expect(selected_taxons).to match_array([taxon_1.id, taxon_2.id])
37
+
38
+ # Regression test for #2139
39
+ expect(page).to have_css(".select2-search-choice", text: taxon_1.name)
40
+ expect(page).to have_css(".select2-search-choice", text: taxon_2.name)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Product Variants", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ end
9
+
10
+ context "editing variant option types", :js => true do
11
+ let!(:product) { create(:product) }
12
+
13
+ it "should allow an admin to create option types for a variant" do
14
+ click_link "Products"
15
+
16
+ within_row(1) { click_icon :edit }
17
+
18
+ within('#sidebar') { click_link "Variants" }
19
+ expect(page).to have_content("TO ADD VARIANTS, YOU MUST FIRST DEFINE")
20
+ end
21
+
22
+ it "allows admin to create a variant if there are option types" do
23
+ click_link "Products"
24
+ click_link "Option Types"
25
+ click_link "new_option_type_link"
26
+ fill_in "option_type_name", :with => "shirt colors"
27
+ fill_in "option_type_presentation", :with => "colors"
28
+ click_button "Create"
29
+ expect(page).to have_content("successfully created!")
30
+
31
+ page.find('#option_type_option_values_attributes_0_name').set('color')
32
+ page.find('#option_type_option_values_attributes_0_presentation').set('black')
33
+ click_button "Update"
34
+ expect(page).to have_content("successfully updated!")
35
+
36
+ visit spree.admin_path
37
+ click_link "Products"
38
+ within('table.index tbody tr:nth-child(1)') do
39
+ click_icon :edit
40
+ end
41
+
42
+ select2_search "shirt", :from => "Option Types"
43
+ click_button "Update"
44
+ expect(page).to have_content("successfully updated!")
45
+
46
+ within('#sidebar') { click_link "Variants" }
47
+ click_link "New Variant"
48
+
49
+ targetted_select2 "black", :from => "#s2id_variant_option_value_ids"
50
+ fill_in "variant_sku", :with => "A100"
51
+ click_button "Create"
52
+ expect(page).to have_content("successfully created!")
53
+
54
+ within(".index") do
55
+ expect(page).to have_content("19.99")
56
+ expect(page).to have_content("black")
57
+ expect(page).to have_content("A100")
58
+ end
59
+ end
60
+ end
61
+ end