spree_backend 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/Gemfile +6 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/spree/backend/admin.js +26 -0
- data/app/controllers/spree/admin/resource_controller.rb +4 -2
- data/app/helpers/spree/admin/navigation_helper.rb +10 -1
- data/app/views/spree/admin/images/new.html.erb +1 -1
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_index_table_options.html.erb +1 -11
- data/app/views/spree/admin/shared/sub_menu/_product.html.erb +1 -1
- data/script/rails +9 -0
- data/spec/controllers/spree/admin/base_controller_spec.rb +46 -0
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +185 -0
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +42 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +247 -0
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
- data/spec/controllers/spree/admin/payments_controller_spec.rb +97 -0
- data/spec/controllers/spree/admin/products_controller_spec.rb +53 -0
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +44 -0
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +74 -0
- data/spec/controllers/spree/admin/reports_controller_spec.rb +42 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +276 -0
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +225 -0
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
- data/spec/controllers/spree/admin/root_controller_spec.rb +35 -0
- data/spec/controllers/spree/admin/search_controller_spec.rb +56 -0
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +19 -0
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +34 -0
- data/spec/controllers/spree/admin/users_controller_spec.rb +161 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +46 -0
- data/spec/features/admin/configuration/countries_spec.rb +24 -0
- data/spec/features/admin/configuration/general_settings_spec.rb +43 -0
- data/spec/features/admin/configuration/payment_methods_spec.rb +63 -0
- data/spec/features/admin/configuration/roles_spec.rb +47 -0
- data/spec/features/admin/configuration/shipping_methods_spec.rb +62 -0
- data/spec/features/admin/configuration/states_spec.rb +68 -0
- data/spec/features/admin/configuration/stock_locations_spec.rb +48 -0
- data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
- data/spec/features/admin/configuration/tax_rates_spec.rb +18 -0
- data/spec/features/admin/configuration/zones_spec.rb +39 -0
- data/spec/features/admin/homepage_spec.rb +81 -0
- data/spec/features/admin/locale_spec.rb +31 -0
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
- data/spec/features/admin/orders/adjustments_spec.rb +129 -0
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +47 -0
- data/spec/features/admin/orders/customer_details_spec.rb +182 -0
- data/spec/features/admin/orders/line_items_spec.rb +51 -0
- data/spec/features/admin/orders/listing_spec.rb +225 -0
- data/spec/features/admin/orders/log_entries_spec.rb +55 -0
- data/spec/features/admin/orders/new_order_spec.rb +161 -0
- data/spec/features/admin/orders/order_details_spec.rb +620 -0
- data/spec/features/admin/orders/payments_spec.rb +229 -0
- data/spec/features/admin/orders/risk_analysis_spec.rb +48 -0
- data/spec/features/admin/orders/shipments_spec.rb +64 -0
- data/spec/features/admin/orders/state_changes_spec.rb +21 -0
- data/spec/features/admin/products/edit/images_spec.rb +86 -0
- data/spec/features/admin/products/edit/products_spec.rb +64 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +41 -0
- data/spec/features/admin/products/edit/variants_spec.rb +56 -0
- data/spec/features/admin/products/option_types_spec.rb +113 -0
- data/spec/features/admin/products/products_spec.rb +394 -0
- data/spec/features/admin/products/properties_spec.rb +140 -0
- data/spec/features/admin/products/prototypes_spec.rb +112 -0
- data/spec/features/admin/products/stock_management_spec.rb +123 -0
- data/spec/features/admin/products/taxonomies_spec.rb +52 -0
- data/spec/features/admin/products/variant_spec.rb +50 -0
- data/spec/features/admin/promotions/adjustments_spec.rb +255 -0
- data/spec/features/admin/promotions/option_value_rule_spec.rb +70 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +70 -0
- data/spec/features/admin/reports_spec.rb +61 -0
- data/spec/features/admin/stock_transfer_spec.rb +75 -0
- data/spec/features/admin/taxons_spec.rb +47 -0
- data/spec/features/admin/users_spec.rb +284 -0
- data/spec/helpers/admin/base_helper_spec.rb +24 -0
- data/spec/helpers/admin/navigation_helper_spec.rb +106 -0
- data/spec/helpers/admin/stock_movements_helper_spec.rb +30 -0
- data/spec/helpers/promotion_rules_helper_spec.rb +12 -0
- data/spec/models/spree/resource_spec.rb +48 -0
- data/spec/spec_helper.rb +133 -0
- data/spec/support/appear_before_matcher.rb +8 -0
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +1 -0
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +1 -0
- data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
- data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
- data/spree_backend.gemspec +29 -0
- metadata +101 -14
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Stock Transfers', type: :feature, js: true do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
it 'transfer between 2 locations' do
|
7
|
+
source_location = create(:stock_location_with_items, name: 'NY')
|
8
|
+
destination_location = create(:stock_location, name: 'SF')
|
9
|
+
variant = Spree::Variant.last
|
10
|
+
|
11
|
+
visit spree.admin_stock_transfers_path
|
12
|
+
click_on 'New Stock Transfer'
|
13
|
+
fill_in 'reference', with: 'PO 666'
|
14
|
+
|
15
|
+
select2_search variant.name, from: 'Variant'
|
16
|
+
|
17
|
+
click_button 'Add'
|
18
|
+
click_button 'Transfer Stock'
|
19
|
+
|
20
|
+
expect(page).to have_content('Reference PO 666')
|
21
|
+
expect(page).to have_content('NY')
|
22
|
+
expect(page).to have_content('SF')
|
23
|
+
expect(page).to have_content(variant.name)
|
24
|
+
|
25
|
+
transfer = Spree::StockTransfer.last
|
26
|
+
expect(transfer.stock_movements.size).to eq 2
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'received stock transfer' do
|
30
|
+
def it_is_received_stock_transfer(page)
|
31
|
+
expect(page).to have_content('Reference PO 666')
|
32
|
+
expect(page).not_to have_selector("#stock-location-source")
|
33
|
+
expect(page).to have_selector("#stock-location-destination")
|
34
|
+
|
35
|
+
transfer = Spree::StockTransfer.last
|
36
|
+
expect(transfer.stock_movements.size).to eq 1
|
37
|
+
expect(transfer.source_location).to be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'receive stock to a single location' do
|
41
|
+
source_location = create(:stock_location_with_items, name: 'NY')
|
42
|
+
destination_location = create(:stock_location, name: 'SF')
|
43
|
+
variant = Spree::Variant.last
|
44
|
+
|
45
|
+
visit spree.new_admin_stock_transfer_path
|
46
|
+
|
47
|
+
fill_in 'reference', with: 'PO 666'
|
48
|
+
check 'transfer_receive_stock'
|
49
|
+
select('NY', from: 'transfer_destination_location_id')
|
50
|
+
select2_search variant.name, from: 'Variant'
|
51
|
+
|
52
|
+
click_button 'Add'
|
53
|
+
click_button 'Transfer Stock'
|
54
|
+
|
55
|
+
it_is_received_stock_transfer page
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'forced to only receive there is only one location' do
|
59
|
+
source_location = create(:stock_location_with_items, name: 'NY')
|
60
|
+
variant = Spree::Variant.last
|
61
|
+
|
62
|
+
visit spree.new_admin_stock_transfer_path
|
63
|
+
|
64
|
+
fill_in 'reference', with: 'PO 666'
|
65
|
+
|
66
|
+
select('NY', from: 'transfer_destination_location_id')
|
67
|
+
select2_search variant.name, from: 'Variant'
|
68
|
+
|
69
|
+
click_button 'Add'
|
70
|
+
click_button 'Transfer Stock'
|
71
|
+
|
72
|
+
it_is_received_stock_transfer page
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Taxonomies and taxons" do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
scenario "admin should be able to edit taxon" do
|
7
|
+
visit spree.new_admin_taxonomy_path
|
8
|
+
|
9
|
+
fill_in "Name", with: "Hello"
|
10
|
+
click_button "Create"
|
11
|
+
|
12
|
+
@taxonomy = Spree::Taxonomy.last
|
13
|
+
|
14
|
+
visit spree.edit_admin_taxonomy_taxon_path(@taxonomy, @taxonomy.root.id)
|
15
|
+
|
16
|
+
fill_in "taxon_name", with: "Shirt"
|
17
|
+
fill_in "taxon_description", with: "Discover our new rails shirts"
|
18
|
+
|
19
|
+
fill_in "permalink_part", with: "shirt-rails"
|
20
|
+
click_button "Update"
|
21
|
+
expect(page).to have_content("Taxon \"Shirt\" has been successfully updated!")
|
22
|
+
end
|
23
|
+
|
24
|
+
scenario "admin should be able to remove a product from a taxon", js: true do
|
25
|
+
taxon_1 = create(:taxon, name: 'Clothing')
|
26
|
+
product = create(:product)
|
27
|
+
product.taxons << taxon_1
|
28
|
+
|
29
|
+
visit spree.admin_taxons_path
|
30
|
+
select_clothing_from_select2
|
31
|
+
|
32
|
+
find('.product').hover
|
33
|
+
find('.product .dropdown-toggle').click
|
34
|
+
click_link "Delete From Taxon"
|
35
|
+
wait_for_ajax
|
36
|
+
|
37
|
+
visit current_path
|
38
|
+
select_clothing_from_select2
|
39
|
+
|
40
|
+
expect(page).to have_content("No results")
|
41
|
+
end
|
42
|
+
|
43
|
+
def select_clothing_from_select2
|
44
|
+
targetted_select2_search "Clothing", from: "#s2id_taxon_id"
|
45
|
+
wait_for_ajax
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Users', type: :feature do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
let!(:country) { create(:country) }
|
7
|
+
let!(:user_a) { create(:user_with_addresses, email: 'a@example.com') }
|
8
|
+
let!(:user_b) { create(:user_with_addresses, email: 'b@example.com') }
|
9
|
+
|
10
|
+
let(:order) { create(:completed_order_with_totals, user: user_a, number: "R123") }
|
11
|
+
|
12
|
+
let(:order_2) do
|
13
|
+
create(:completed_order_with_totals, user: user_a, number: "R456").tap do |o|
|
14
|
+
li = o.line_items.last
|
15
|
+
li.update_column(:price, li.price + 10)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:orders) { [order, order_2] }
|
20
|
+
|
21
|
+
before do
|
22
|
+
stub_const('Spree::User', create(:user, email: 'example@example.com').class)
|
23
|
+
end
|
24
|
+
|
25
|
+
shared_examples_for 'a user page' do
|
26
|
+
it 'has lifetime stats' do
|
27
|
+
orders
|
28
|
+
visit current_url # need to refresh after creating the orders for specs that did not require orders
|
29
|
+
within("#user-lifetime-stats") do
|
30
|
+
[:total_sales, :num_orders, :average_order_value, :member_since].each do |stat_name|
|
31
|
+
expect(page).to have_content Spree.t(stat_name)
|
32
|
+
end
|
33
|
+
expect(page).to have_content (order.total + order_2.total)
|
34
|
+
expect(page).to have_content orders.count
|
35
|
+
expect(page).to have_content (orders.sum(&:total) / orders.count)
|
36
|
+
expect(page).to have_content I18n.l(user_a.created_at.to_date)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can go back to the users list' do
|
41
|
+
expect(page).to have_link Spree.t(:back_to_users_list), href: spree.admin_users_path
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can navigate to the account page' do
|
45
|
+
expect(page).to have_link Spree.t(:"admin.user.account"), href: spree.edit_admin_user_path(user_a)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'can navigate to the order history' do
|
49
|
+
expect(page).to have_link Spree.t(:"admin.user.orders"), href: spree.orders_admin_user_path(user_a)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can navigate to the items purchased' do
|
53
|
+
expect(page).to have_link Spree.t(:"admin.user.items"), href: spree.items_admin_user_path(user_a)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
shared_examples_for 'a sortable attribute' do
|
58
|
+
before { click_link sort_link }
|
59
|
+
|
60
|
+
it "can sort asc" do
|
61
|
+
within_table(table_id) do
|
62
|
+
expect(page).to have_text text_match_1
|
63
|
+
expect(page).to have_text text_match_2
|
64
|
+
expect(text_match_1).to appear_before text_match_2
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "can sort desc" do
|
69
|
+
within_table(table_id) do
|
70
|
+
click_link sort_link
|
71
|
+
|
72
|
+
expect(page).to have_text text_match_1
|
73
|
+
expect(page).to have_text text_match_2
|
74
|
+
expect(text_match_2).to appear_before text_match_1
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
before do
|
80
|
+
visit spree.admin_path
|
81
|
+
click_link 'Users'
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'users index' do
|
85
|
+
|
86
|
+
context "email" do
|
87
|
+
it_behaves_like "a sortable attribute" do
|
88
|
+
let(:text_match_1) { user_a.email }
|
89
|
+
let(:text_match_2) { user_b.email }
|
90
|
+
let(:table_id) { "listing_users" }
|
91
|
+
let(:sort_link) { "users_email_title" }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'displays the correct results for a user search' do
|
96
|
+
fill_in 'q_email_cont', with: user_a.email, visible: false
|
97
|
+
click_button 'Search', visible: false
|
98
|
+
within_table('listing_users') do
|
99
|
+
expect(page).to have_text user_a.email
|
100
|
+
expect(page).not_to have_text user_b.email
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'editing users' do
|
106
|
+
before { click_link user_a.email }
|
107
|
+
|
108
|
+
it_behaves_like 'a user page'
|
109
|
+
|
110
|
+
it 'can edit the user email' do
|
111
|
+
fill_in 'user_email', with: 'a@example.com99'
|
112
|
+
click_button 'Update'
|
113
|
+
|
114
|
+
expect(user_a.reload.email).to eq 'a@example.com99'
|
115
|
+
expect(page).to have_text 'Account updated'
|
116
|
+
expect(find_field('user_email').value).to eq 'a@example.com99'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'can edit the user password' do
|
120
|
+
fill_in 'user_password', with: 'welcome'
|
121
|
+
fill_in 'user_password_confirmation', with: 'welcome'
|
122
|
+
click_button 'Update'
|
123
|
+
|
124
|
+
expect(page).to have_text 'Account updated'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'can edit user roles' do
|
128
|
+
Spree::Role.create name: "admin"
|
129
|
+
click_link 'Users'
|
130
|
+
click_link user_a.email
|
131
|
+
|
132
|
+
check 'user_spree_role_admin'
|
133
|
+
click_button 'Update'
|
134
|
+
expect(page).to have_text 'Account updated'
|
135
|
+
expect(find_field('user_spree_role_admin')['checked']).to be true
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'can edit user shipping address' do
|
139
|
+
click_link "Addresses"
|
140
|
+
|
141
|
+
within("#admin_user_edit_addresses") do
|
142
|
+
fill_in "user_ship_address_attributes_address1", with: "1313 Mockingbird Ln"
|
143
|
+
click_button 'Update'
|
144
|
+
expect(find_field('user_ship_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
|
145
|
+
end
|
146
|
+
|
147
|
+
expect(user_a.reload.ship_address.address1).to eq "1313 Mockingbird Ln"
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'can edit user billing address' do
|
151
|
+
click_link "Addresses"
|
152
|
+
|
153
|
+
within("#admin_user_edit_addresses") do
|
154
|
+
fill_in "user_bill_address_attributes_address1", with: "1313 Mockingbird Ln"
|
155
|
+
click_button 'Update'
|
156
|
+
expect(find_field('user_bill_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
|
157
|
+
end
|
158
|
+
|
159
|
+
expect(user_a.reload.bill_address.address1).to eq "1313 Mockingbird Ln"
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'no api key exists' do
|
163
|
+
it 'can generate a new api key' do
|
164
|
+
within("#admin_user_edit_api_key") do
|
165
|
+
expect(user_a.spree_api_key).to be_blank
|
166
|
+
click_button Spree.t('generate_key', :scope => 'api')
|
167
|
+
end
|
168
|
+
|
169
|
+
expect(user_a.reload.spree_api_key).to be_present
|
170
|
+
|
171
|
+
within("#admin_user_edit_api_key") do
|
172
|
+
expect(find("#current-api-key").text).to match /Key: #{user_a.spree_api_key}/
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context 'an api key exists' do
|
178
|
+
before do
|
179
|
+
user_a.generate_spree_api_key!
|
180
|
+
expect(user_a.reload.spree_api_key).to be_present
|
181
|
+
visit current_path
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'can clear an api key' do
|
185
|
+
within("#admin_user_edit_api_key") do
|
186
|
+
click_button Spree.t('clear_key', :scope => 'api')
|
187
|
+
end
|
188
|
+
|
189
|
+
expect(user_a.reload.spree_api_key).to be_blank
|
190
|
+
expect { find("#current-api-key") }.to raise_error Capybara::ElementNotFound
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'can regenerate an api key' do
|
194
|
+
old_key = user_a.spree_api_key
|
195
|
+
|
196
|
+
within("#admin_user_edit_api_key") do
|
197
|
+
click_button Spree.t('regenerate_key', :scope => 'api')
|
198
|
+
end
|
199
|
+
|
200
|
+
expect(user_a.reload.spree_api_key).to be_present
|
201
|
+
expect(user_a.reload.spree_api_key).not_to eq old_key
|
202
|
+
|
203
|
+
within("#admin_user_edit_api_key") do
|
204
|
+
expect(find("#current-api-key").text).to match /Key: #{user_a.spree_api_key}/
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'order history with sorting' do
|
211
|
+
|
212
|
+
before do
|
213
|
+
orders
|
214
|
+
click_link user_a.email
|
215
|
+
within("#sidebar") { click_link Spree.t(:"admin.user.orders") }
|
216
|
+
end
|
217
|
+
|
218
|
+
it_behaves_like 'a user page'
|
219
|
+
|
220
|
+
context "completed_at" do
|
221
|
+
it_behaves_like "a sortable attribute" do
|
222
|
+
let(:text_match_1) { I18n.l(order.completed_at.to_date) }
|
223
|
+
let(:text_match_2) { I18n.l(order_2.completed_at.to_date) }
|
224
|
+
let(:table_id) { "listing_orders" }
|
225
|
+
let(:sort_link) { "orders_completed_at_title" }
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
[:number, :state, :total].each do |attr|
|
230
|
+
context attr do
|
231
|
+
it_behaves_like "a sortable attribute" do
|
232
|
+
let(:text_match_1) { order.send(attr).to_s }
|
233
|
+
let(:text_match_2) { order_2.send(attr).to_s }
|
234
|
+
let(:table_id) { "listing_orders" }
|
235
|
+
let(:sort_link) { "orders_#{attr}_title" }
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'items purchased with sorting' do
|
242
|
+
|
243
|
+
before do
|
244
|
+
orders
|
245
|
+
click_link user_a.email
|
246
|
+
within("#sidebar") { click_link Spree.t(:"admin.user.items") }
|
247
|
+
end
|
248
|
+
|
249
|
+
it_behaves_like 'a user page'
|
250
|
+
|
251
|
+
context "completed_at" do
|
252
|
+
it_behaves_like "a sortable attribute" do
|
253
|
+
let(:text_match_1) { I18n.l(order.completed_at.to_date) }
|
254
|
+
let(:text_match_2) { I18n.l(order_2.completed_at.to_date) }
|
255
|
+
let(:table_id) { "listing_items" }
|
256
|
+
let(:sort_link) { "orders_completed_at_title" }
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
[:number, :state].each do |attr|
|
261
|
+
context attr do
|
262
|
+
it_behaves_like "a sortable attribute" do
|
263
|
+
let(:text_match_1) { order.send(attr).to_s }
|
264
|
+
let(:text_match_2) { order_2.send(attr).to_s }
|
265
|
+
let(:table_id) { "listing_items" }
|
266
|
+
let(:sort_link) { "orders_#{attr}_title" }
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
it "has item attributes" do
|
272
|
+
items = order.line_items | order_2.line_items
|
273
|
+
expect(page).to have_table 'listing_items'
|
274
|
+
within_table('listing_items') do
|
275
|
+
items.each do |item|
|
276
|
+
expect(page).to have_selector(".item-name", text: item.product.name)
|
277
|
+
expect(page).to have_selector(".item-price", text: item.single_money.to_html)
|
278
|
+
expect(page).to have_selector(".item-quantity", text: item.quantity)
|
279
|
+
expect(page).to have_selector(".item-total", text: item.money.to_html)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Admin::BaseHelper, :type => :helper do
|
4
|
+
include Spree::Admin::BaseHelper
|
5
|
+
|
6
|
+
context "#datepicker_field_value" do
|
7
|
+
it "should return nil when date is empty" do
|
8
|
+
date = nil
|
9
|
+
expect(datepicker_field_value(date)).to be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return a formatted date when date is present" do
|
13
|
+
date = "2013-08-14".to_time
|
14
|
+
expect(datepicker_field_value(date)).to eq("2013/08/14")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "#plural_resource_name" do
|
19
|
+
it "should return correct form of class" do
|
20
|
+
resource_class = Spree::Product
|
21
|
+
expect(plural_resource_name(resource_class)).to eq("Products")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Spree::Admin::NavigationHelper, type: :helper do
|
5
|
+
|
6
|
+
describe "#tab" do
|
7
|
+
before do
|
8
|
+
allow(helper).to receive(:cannot?).and_return false
|
9
|
+
end
|
10
|
+
|
11
|
+
context "creating an admin tab" do
|
12
|
+
it "should capitalize the first letter of each word in the tab's label" do
|
13
|
+
admin_tab = helper.tab(:orders)
|
14
|
+
expect(admin_tab).to include("Orders")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should accept options with label and capitalize each word of it" do
|
19
|
+
admin_tab = helper.tab(:orders, label: "delivered orders")
|
20
|
+
expect(admin_tab).to include("Delivered Orders")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should capitalize words with unicode characters" do
|
24
|
+
# overview
|
25
|
+
admin_tab = helper.tab(:orders, label: "přehled")
|
26
|
+
expect(admin_tab).to include("Přehled")
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "selection" do
|
30
|
+
context "when match_path option is not supplied" do
|
31
|
+
subject(:tab) { helper.tab(:orders) }
|
32
|
+
|
33
|
+
it "should be selected if the controller matches" do
|
34
|
+
allow(controller).to receive(:controller_name).and_return("orders")
|
35
|
+
expect(subject).to include('selected')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not be selected if the controller does not match" do
|
39
|
+
allow(controller).to receive(:controller_name).and_return("bonobos")
|
40
|
+
expect(subject).not_to include('selected')
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when match_path option is supplied" do
|
46
|
+
before do
|
47
|
+
allow(helper).to receive(:request).and_return(double(ActionDispatch::Request, fullpath: "/admin/orders/edit/1"))
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be selected if the fullpath matches" do
|
51
|
+
allow(controller).to receive(:controller_name).and_return("bonobos")
|
52
|
+
tab = helper.tab(:orders, label: "delivered orders", match_path: '/orders')
|
53
|
+
expect(tab).to include('selected')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be selected if the fullpath matches a regular expression" do
|
57
|
+
allow(controller).to receive(:controller_name).and_return("bonobos")
|
58
|
+
tab = helper.tab(:orders, label: "delivered orders", match_path: /orders$|orders\//)
|
59
|
+
expect(tab).to include('selected')
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not be selected if the fullpath does not match" do
|
63
|
+
allow(controller).to receive(:controller_name).and_return("bonobos")
|
64
|
+
tab = helper.tab(:orders, label: "delivered orders", match_path: '/shady')
|
65
|
+
expect(tab).not_to include('selected')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not be selected if the fullpath does not match a regular expression" do
|
69
|
+
allow(controller).to receive(:controller_name).and_return("bonobos")
|
70
|
+
tab = helper.tab(:orders, label: "delivered orders", match_path: /shady$|shady\//)
|
71
|
+
expect(tab).not_to include('selected')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#klass_for' do
|
78
|
+
|
79
|
+
it 'returns correct klass for Spree model' do
|
80
|
+
expect(klass_for(:products)).to eq(Spree::Product)
|
81
|
+
expect(klass_for(:product_properties)).to eq(Spree::ProductProperty)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns correct klass for non-spree model' do
|
85
|
+
class MyUser
|
86
|
+
end
|
87
|
+
expect(klass_for(:my_users)).to eq(MyUser)
|
88
|
+
|
89
|
+
Object.send(:remove_const, 'MyUser')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns correct namespaced klass for non-spree model' do
|
93
|
+
module My
|
94
|
+
class User
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
expect(klass_for(:my_users)).to eq(My::User)
|
99
|
+
|
100
|
+
My.send(:remove_const, 'User')
|
101
|
+
Object.send(:remove_const, 'My')
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|