spree_backend 3.2.1 → 3.2.2
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.
- checksums.yaml +4 -4
- data/app/views/spree/admin/products/_form.html.erb +8 -8
- data/spree_backend.gemspec +2 -2
- metadata +9 -100
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -296
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -64
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
- data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
- data/spec/features/admin/configuration/countries_spec.rb +0 -24
- data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
- data/spec/features/admin/configuration/roles_spec.rb +0 -47
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
- data/spec/features/admin/configuration/states_spec.rb +0 -68
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
- data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
- data/spec/features/admin/configuration/zones_spec.rb +0 -39
- data/spec/features/admin/homepage_spec.rb +0 -89
- data/spec/features/admin/locale_spec.rb +0 -31
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
- data/spec/features/admin/orders/adjustments_spec.rb +0 -130
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
- data/spec/features/admin/orders/customer_details_spec.rb +0 -154
- data/spec/features/admin/orders/line_items_spec.rb +0 -51
- data/spec/features/admin/orders/listing_spec.rb +0 -224
- data/spec/features/admin/orders/log_entries_spec.rb +0 -55
- data/spec/features/admin/orders/new_order_spec.rb +0 -186
- data/spec/features/admin/orders/order_details_spec.rb +0 -662
- data/spec/features/admin/orders/payments_spec.rb +0 -231
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
- data/spec/features/admin/orders/shipments_spec.rb +0 -64
- data/spec/features/admin/orders/state_changes_spec.rb +0 -21
- data/spec/features/admin/products/edit/images_spec.rb +0 -86
- data/spec/features/admin/products/edit/products_spec.rb +0 -64
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
- data/spec/features/admin/products/edit/variants_spec.rb +0 -56
- data/spec/features/admin/products/option_types_spec.rb +0 -114
- data/spec/features/admin/products/products_spec.rb +0 -445
- data/spec/features/admin/products/properties_spec.rb +0 -147
- data/spec/features/admin/products/prototypes_spec.rb +0 -112
- data/spec/features/admin/products/stock_management_spec.rb +0 -124
- data/spec/features/admin/products/taxonomies_spec.rb +0 -52
- data/spec/features/admin/products/variant_spec.rb +0 -50
- data/spec/features/admin/promotions/adjustments_spec.rb +0 -258
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
- data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
- data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +0 -36
- data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +0 -62
- data/spec/features/admin/reports_spec.rb +0 -61
- data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
- data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
- data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
- data/spec/features/admin/stock_transfer_spec.rb +0 -75
- data/spec/features/admin/store_credits_spec.rb +0 -93
- data/spec/features/admin/taxons_spec.rb +0 -47
- data/spec/features/admin/users_spec.rb +0 -286
- data/spec/helpers/admin/base_helper_spec.rb +0 -30
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -111
- data/spec/helpers/admin/promotion_rules_helper_spec.rb +0 -12
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
- data/spec/models/spree/resource_spec.rb +0 -48
- data/spec/routing/admin_path_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -144
- data/spec/support/appear_before_matcher.rb +0 -8
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'Store credits admin' do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
let!(:admin_user) { create(:admin_user) }
|
|
7
|
-
let!(:store_credit) { create(:store_credit) }
|
|
8
|
-
|
|
9
|
-
before do
|
|
10
|
-
allow(Spree.user_class).to receive(:find_by).and_return(store_credit.user)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe 'visiting the store credits page' do
|
|
14
|
-
before do
|
|
15
|
-
visit spree.admin_path
|
|
16
|
-
click_link 'Users'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'should be on the store credits page' do
|
|
20
|
-
click_link store_credit.user.email
|
|
21
|
-
click_link 'Store Credits'
|
|
22
|
-
expect(page.current_path).to eq spree.admin_user_store_credits_path(store_credit.user)
|
|
23
|
-
|
|
24
|
-
store_credit_table = page.find('table')
|
|
25
|
-
expect(store_credit_table.all('tr').count).to eq 1
|
|
26
|
-
expect(store_credit_table).to have_content(Spree::Money.new(store_credit.amount).to_s)
|
|
27
|
-
expect(store_credit_table).to have_content(Spree::Money.new(store_credit.amount_used).to_s)
|
|
28
|
-
expect(store_credit_table).to have_content(store_credit.category_name)
|
|
29
|
-
expect(store_credit_table).to have_content(store_credit.created_by_email)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe 'creating store credit' do
|
|
34
|
-
before do
|
|
35
|
-
visit spree.admin_path
|
|
36
|
-
click_link 'Users'
|
|
37
|
-
click_link store_credit.user.email
|
|
38
|
-
click_link 'Store Credits'
|
|
39
|
-
allow_any_instance_of(Spree::Admin::StoreCreditsController).to receive(:try_spree_current_user).and_return(admin_user)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should create store credit and associate it with the user' do
|
|
43
|
-
click_link 'Add Store Credit'
|
|
44
|
-
page.fill_in 'store_credit_amount', with: '102.00'
|
|
45
|
-
select 'Exchange', from: 'store_credit_category_id'
|
|
46
|
-
click_button 'Create'
|
|
47
|
-
|
|
48
|
-
expect(page.current_path).to eq spree.admin_user_store_credits_path(store_credit.user)
|
|
49
|
-
store_credit_table = page.find('table')
|
|
50
|
-
expect(store_credit_table.all('tr').count).to eq 2
|
|
51
|
-
expect(Spree::StoreCredit.count).to eq 2
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe 'updating store credit' do
|
|
56
|
-
let(:updated_amount) { '99.0' }
|
|
57
|
-
|
|
58
|
-
before do
|
|
59
|
-
visit spree.admin_path
|
|
60
|
-
click_link 'Users'
|
|
61
|
-
click_link store_credit.user.email
|
|
62
|
-
click_link 'Store Credits'
|
|
63
|
-
allow_any_instance_of(Spree::Admin::StoreCreditsController).to receive(:try_spree_current_user).and_return(admin_user)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'should create store credit and associate it with the user' do
|
|
67
|
-
click_link 'Edit'
|
|
68
|
-
page.fill_in 'store_credit_amount', with: updated_amount
|
|
69
|
-
click_button 'Update'
|
|
70
|
-
|
|
71
|
-
expect(page.current_path).to eq spree.admin_user_store_credits_path(store_credit.user)
|
|
72
|
-
store_credit_table = page.find('table')
|
|
73
|
-
expect(store_credit_table).to have_content(Spree::Money.new(updated_amount).to_s)
|
|
74
|
-
expect(store_credit.reload.amount.to_f).to eq updated_amount.to_f
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe 'non-existent user' do
|
|
79
|
-
before do
|
|
80
|
-
visit spree.admin_path
|
|
81
|
-
click_link 'Users'
|
|
82
|
-
click_link store_credit.user.email
|
|
83
|
-
store_credit.user.destroy
|
|
84
|
-
allow(Spree.user_class).to receive(:find_by).and_return(nil)
|
|
85
|
-
click_link 'Store Credits'
|
|
86
|
-
allow_any_instance_of(Spree::Admin::StoreCreditsController).to receive(:try_spree_current_user).and_return(admin_user)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'should display flash withe error' do
|
|
90
|
-
expect(page).to have_content(Spree.t(:user_not_found))
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'Users', type: :feature do
|
|
4
|
-
include Spree::BaseHelper
|
|
5
|
-
stub_authorization!
|
|
6
|
-
include Spree::Admin::BaseHelper
|
|
7
|
-
|
|
8
|
-
let!(:country) { create(:country) }
|
|
9
|
-
let!(:user_a) { create(:user_with_addresses, email: 'a@example.com') }
|
|
10
|
-
let!(:user_b) { create(:user_with_addresses, email: 'b@example.com') }
|
|
11
|
-
|
|
12
|
-
let(:order) { create(:completed_order_with_totals, user: user_a, number: "R123") }
|
|
13
|
-
|
|
14
|
-
let(:order_2) do
|
|
15
|
-
create(:completed_order_with_totals, user: user_a, number: "R456").tap do |o|
|
|
16
|
-
li = o.line_items.last
|
|
17
|
-
li.update_column(:price, li.price + 10)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
let(:orders) { [order, order_2] }
|
|
22
|
-
|
|
23
|
-
before do
|
|
24
|
-
stub_const('Spree::User', create(:user, email: 'example@example.com').class)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
shared_examples_for 'a user page' do
|
|
28
|
-
it 'has lifetime stats' do
|
|
29
|
-
orders
|
|
30
|
-
visit current_url # need to refresh after creating the orders for specs that did not require orders
|
|
31
|
-
within("#user-lifetime-stats") do
|
|
32
|
-
[:total_sales, :num_orders, :average_order_value, :member_since].each do |stat_name|
|
|
33
|
-
expect(page).to have_content Spree.t(stat_name)
|
|
34
|
-
end
|
|
35
|
-
expect(page).to have_content (order.total + order_2.total)
|
|
36
|
-
expect(page).to have_content orders.count
|
|
37
|
-
expect(page).to have_content (orders.sum(&:total) / orders.count)
|
|
38
|
-
expect(page).to have_content pretty_time(user_a.created_at)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'can go back to the users list' do
|
|
43
|
-
expect(page).to have_link Spree.t(:users), href: spree.admin_users_path
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'can navigate to the account page' do
|
|
47
|
-
expect(page).to have_link Spree.t(:"admin.user.account"), href: spree.edit_admin_user_path(user_a)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'can navigate to the order history' do
|
|
51
|
-
expect(page).to have_link Spree.t(:"admin.user.orders"), href: spree.orders_admin_user_path(user_a)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'can navigate to the items purchased' do
|
|
55
|
-
expect(page).to have_link Spree.t(:"admin.user.items"), href: spree.items_admin_user_path(user_a)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
shared_examples_for 'a sortable attribute' do
|
|
60
|
-
before { click_link sort_link }
|
|
61
|
-
|
|
62
|
-
it "can sort asc" do
|
|
63
|
-
within_table(table_id) do
|
|
64
|
-
expect(page).to have_text text_match_1
|
|
65
|
-
expect(page).to have_text text_match_2
|
|
66
|
-
expect(text_match_1).to appear_before text_match_2
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "can sort desc" do
|
|
71
|
-
within_table(table_id) do
|
|
72
|
-
click_link sort_link
|
|
73
|
-
|
|
74
|
-
expect(page).to have_text text_match_1
|
|
75
|
-
expect(page).to have_text text_match_2
|
|
76
|
-
expect(text_match_2).to appear_before text_match_1
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
before do
|
|
82
|
-
visit spree.admin_path
|
|
83
|
-
click_link 'Users'
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context 'users index' do
|
|
87
|
-
|
|
88
|
-
context "email" do
|
|
89
|
-
it_behaves_like "a sortable attribute" do
|
|
90
|
-
let(:text_match_1) { user_a.email }
|
|
91
|
-
let(:text_match_2) { user_b.email }
|
|
92
|
-
let(:table_id) { "listing_users" }
|
|
93
|
-
let(:sort_link) { "users_email_title" }
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'displays the correct results for a user search' do
|
|
98
|
-
fill_in 'q_email_cont', with: user_a.email, visible: false
|
|
99
|
-
click_button 'Search', visible: false
|
|
100
|
-
within_table('listing_users') do
|
|
101
|
-
expect(page).to have_text user_a.email
|
|
102
|
-
expect(page).not_to have_text user_b.email
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context 'editing users' do
|
|
108
|
-
before { click_link user_a.email }
|
|
109
|
-
|
|
110
|
-
it_behaves_like 'a user page'
|
|
111
|
-
|
|
112
|
-
it 'can edit the user email' do
|
|
113
|
-
fill_in 'user_email', with: 'a@example.com99'
|
|
114
|
-
click_button 'Update'
|
|
115
|
-
|
|
116
|
-
expect(user_a.reload.email).to eq 'a@example.com99'
|
|
117
|
-
expect(page).to have_text 'Account updated'
|
|
118
|
-
expect(find_field('user_email').value).to eq 'a@example.com99'
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it 'can edit the user password' do
|
|
122
|
-
fill_in 'user_password', with: 'welcome'
|
|
123
|
-
fill_in 'user_password_confirmation', with: 'welcome'
|
|
124
|
-
click_button 'Update'
|
|
125
|
-
|
|
126
|
-
expect(page).to have_text 'Account updated'
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it 'can edit user roles' do
|
|
130
|
-
Spree::Role.create name: "admin"
|
|
131
|
-
click_link 'Users'
|
|
132
|
-
click_link user_a.email
|
|
133
|
-
|
|
134
|
-
check 'user_spree_role_admin'
|
|
135
|
-
click_button 'Update'
|
|
136
|
-
expect(page).to have_text 'Account updated'
|
|
137
|
-
expect(find_field('user_spree_role_admin')['checked']).to be true
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
it 'can edit user shipping address' do
|
|
141
|
-
click_link "Addresses"
|
|
142
|
-
|
|
143
|
-
within("#admin_user_edit_addresses") do
|
|
144
|
-
fill_in "user_ship_address_attributes_address1", with: "1313 Mockingbird Ln"
|
|
145
|
-
click_button 'Update'
|
|
146
|
-
expect(find_field('user_ship_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
expect(user_a.reload.ship_address.address1).to eq "1313 Mockingbird Ln"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it 'can edit user billing address' do
|
|
153
|
-
click_link "Addresses"
|
|
154
|
-
|
|
155
|
-
within("#admin_user_edit_addresses") do
|
|
156
|
-
fill_in "user_bill_address_attributes_address1", with: "1313 Mockingbird Ln"
|
|
157
|
-
click_button 'Update'
|
|
158
|
-
expect(find_field('user_bill_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
expect(user_a.reload.bill_address.address1).to eq "1313 Mockingbird Ln"
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context 'no api key exists' do
|
|
165
|
-
it 'can generate a new api key' do
|
|
166
|
-
within("#admin_user_edit_api_key") do
|
|
167
|
-
expect(user_a.spree_api_key).to be_blank
|
|
168
|
-
click_button Spree.t('generate_key', scope: 'api')
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
expect(user_a.reload.spree_api_key).to be_present
|
|
172
|
-
|
|
173
|
-
within("#admin_user_edit_api_key") do
|
|
174
|
-
expect(find("#current-api-key").text).to match /Key: #{user_a.spree_api_key}/
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
context 'an api key exists' do
|
|
180
|
-
before do
|
|
181
|
-
user_a.generate_spree_api_key!
|
|
182
|
-
expect(user_a.reload.spree_api_key).to be_present
|
|
183
|
-
visit current_path
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it 'can clear an api key' do
|
|
187
|
-
within("#admin_user_edit_api_key") do
|
|
188
|
-
click_button Spree.t('clear_key', scope: 'api')
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
expect(user_a.reload.spree_api_key).to be_blank
|
|
192
|
-
expect { find("#current-api-key") }.to raise_error Capybara::ElementNotFound
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it 'can regenerate an api key' do
|
|
196
|
-
old_key = user_a.spree_api_key
|
|
197
|
-
|
|
198
|
-
within("#admin_user_edit_api_key") do
|
|
199
|
-
click_button Spree.t('regenerate_key', scope: 'api')
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
expect(user_a.reload.spree_api_key).to be_present
|
|
203
|
-
expect(user_a.reload.spree_api_key).not_to eq old_key
|
|
204
|
-
|
|
205
|
-
within("#admin_user_edit_api_key") do
|
|
206
|
-
expect(find("#current-api-key").text).to match /Key: #{user_a.spree_api_key}/
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
context 'order history with sorting' do
|
|
213
|
-
|
|
214
|
-
before do
|
|
215
|
-
orders
|
|
216
|
-
click_link user_a.email
|
|
217
|
-
within("#sidebar") { click_link Spree.t(:"admin.user.orders") }
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
it_behaves_like 'a user page'
|
|
221
|
-
|
|
222
|
-
context "completed_at" do
|
|
223
|
-
it_behaves_like "a sortable attribute" do
|
|
224
|
-
let(:text_match_1) { order_time(order.completed_at) }
|
|
225
|
-
let(:text_match_2) { order_time(order_2.completed_at) }
|
|
226
|
-
let(:table_id) { "listing_orders" }
|
|
227
|
-
let(:sort_link) { "orders_completed_at_title" }
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
[:number, :state, :total].each do |attr|
|
|
232
|
-
context attr do
|
|
233
|
-
it_behaves_like "a sortable attribute" do
|
|
234
|
-
let(:text_match_1) { order.send(attr).to_s }
|
|
235
|
-
let(:text_match_2) { order_2.send(attr).to_s }
|
|
236
|
-
let(:table_id) { "listing_orders" }
|
|
237
|
-
let(:sort_link) { "orders_#{attr}_title" }
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
context 'items purchased with sorting' do
|
|
244
|
-
|
|
245
|
-
before do
|
|
246
|
-
orders
|
|
247
|
-
click_link user_a.email
|
|
248
|
-
within("#sidebar") { click_link Spree.t(:"admin.user.items") }
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
it_behaves_like 'a user page'
|
|
252
|
-
|
|
253
|
-
context "completed_at" do
|
|
254
|
-
it_behaves_like "a sortable attribute" do
|
|
255
|
-
let(:text_match_1) { order_time(order.completed_at) }
|
|
256
|
-
let(:text_match_2) { order_time(order_2.completed_at) }
|
|
257
|
-
let(:table_id) { "listing_items" }
|
|
258
|
-
let(:sort_link) { "orders_completed_at_title" }
|
|
259
|
-
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
[:number, :state].each do |attr|
|
|
263
|
-
context attr do
|
|
264
|
-
it_behaves_like "a sortable attribute" do
|
|
265
|
-
let(:text_match_1) { order.send(attr).to_s }
|
|
266
|
-
let(:text_match_2) { order_2.send(attr).to_s }
|
|
267
|
-
let(:table_id) { "listing_items" }
|
|
268
|
-
let(:sort_link) { "orders_#{attr}_title" }
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
it "has item attributes" do
|
|
274
|
-
items = order.line_items | order_2.line_items
|
|
275
|
-
expect(page).to have_table 'listing_items'
|
|
276
|
-
within_table('listing_items') do
|
|
277
|
-
items.each do |item|
|
|
278
|
-
expect(page).to have_selector(".item-name", text: item.product.name)
|
|
279
|
-
expect(page).to have_selector(".item-price", text: item.single_money.to_html)
|
|
280
|
-
expect(page).to have_selector(".item-quantity", text: item.quantity)
|
|
281
|
-
expect(page).to have_selector(".item-total", text: item.money.to_html)
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
|
|
25
|
-
context "#order_time" do
|
|
26
|
-
it "prints in a format" do
|
|
27
|
-
expect(order_time(DateTime.new(2016, 5, 6, 13, 33))).to eq "2016-05-06 1:33 PM"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# coding: UTF-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe Spree::Admin::NavigationHelper, type: :helper do
|
|
5
|
-
before(:each) do
|
|
6
|
-
# `spree` route helper is not accessible in `type: :helper` hence extending it explicitly
|
|
7
|
-
# https://github.com/rspec/rspec-rails/issues/1626
|
|
8
|
-
helper.extend Spree::TestingSupport::UrlHelpers
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#tab" do
|
|
12
|
-
before do
|
|
13
|
-
allow(helper).to receive(:cannot?).and_return false
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context "creating an admin tab" do
|
|
17
|
-
it "should capitalize the first letter of each word in the tab's label" do
|
|
18
|
-
admin_tab = helper.tab(:orders)
|
|
19
|
-
expect(admin_tab).to include("Orders")
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should accept options with label and capitalize each word of it" do
|
|
24
|
-
admin_tab = helper.tab(:orders, label: "delivered orders")
|
|
25
|
-
expect(admin_tab).to include("Delivered Orders")
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should capitalize words with unicode characters" do
|
|
29
|
-
# overview
|
|
30
|
-
admin_tab = helper.tab(:orders, label: "přehled")
|
|
31
|
-
expect(admin_tab).to include("Přehled")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe "selection" do
|
|
35
|
-
context "when match_path option is not supplied" do
|
|
36
|
-
subject(:tab) { helper.tab(:orders) }
|
|
37
|
-
|
|
38
|
-
it "should be selected if the controller matches" do
|
|
39
|
-
allow(controller).to receive(:controller_name).and_return("orders")
|
|
40
|
-
expect(subject).to include('selected')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should not be selected if the controller does not match" do
|
|
44
|
-
allow(controller).to receive(:controller_name).and_return("bonobos")
|
|
45
|
-
expect(subject).not_to include('selected')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "when match_path option is supplied" do
|
|
51
|
-
before do
|
|
52
|
-
allow(helper).to receive(:request).and_return(double(ActionDispatch::Request, fullpath: "/admin/orders/edit/1"))
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should be selected if the fullpath matches" do
|
|
56
|
-
allow(controller).to receive(:controller_name).and_return("bonobos")
|
|
57
|
-
tab = helper.tab(:orders, label: "delivered orders", match_path: '/orders')
|
|
58
|
-
expect(tab).to include('selected')
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "should be selected if the fullpath matches a regular expression" do
|
|
62
|
-
allow(controller).to receive(:controller_name).and_return("bonobos")
|
|
63
|
-
tab = helper.tab(:orders, label: "delivered orders", match_path: /orders$|orders\//)
|
|
64
|
-
expect(tab).to include('selected')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should not be selected if the fullpath does not match" do
|
|
68
|
-
allow(controller).to receive(:controller_name).and_return("bonobos")
|
|
69
|
-
tab = helper.tab(:orders, label: "delivered orders", match_path: '/shady')
|
|
70
|
-
expect(tab).not_to include('selected')
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should not be selected if the fullpath does not match a regular expression" do
|
|
74
|
-
allow(controller).to receive(:controller_name).and_return("bonobos")
|
|
75
|
-
tab = helper.tab(:orders, label: "delivered orders", match_path: /shady$|shady\//)
|
|
76
|
-
expect(tab).not_to include('selected')
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe '#klass_for' do
|
|
83
|
-
|
|
84
|
-
it 'returns correct klass for Spree model' do
|
|
85
|
-
expect(klass_for(:products)).to eq(Spree::Product)
|
|
86
|
-
expect(klass_for(:product_properties)).to eq(Spree::ProductProperty)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'returns correct klass for non-spree model' do
|
|
90
|
-
class MyUser
|
|
91
|
-
end
|
|
92
|
-
expect(klass_for(:my_users)).to eq(MyUser)
|
|
93
|
-
|
|
94
|
-
Object.send(:remove_const, 'MyUser')
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'returns correct namespaced klass for non-spree model' do
|
|
98
|
-
module My
|
|
99
|
-
class User
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
expect(klass_for(:my_users)).to eq(My::User)
|
|
104
|
-
|
|
105
|
-
My.send(:remove_const, 'User')
|
|
106
|
-
Object.send(:remove_const, 'My')
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
module Spree
|
|
3
|
-
describe Spree::Admin::PromotionRulesHelper, type: :helper do
|
|
4
|
-
it "does not include existing rules in options" do
|
|
5
|
-
promotion = Spree::Promotion.new
|
|
6
|
-
promotion.promotion_rules << Spree::Promotion::Rules::ItemTotal.new
|
|
7
|
-
|
|
8
|
-
options = helper.options_for_promotion_rule_types(promotion)
|
|
9
|
-
expect(options).not_to match(/ItemTotal/)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# coding: UTF-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe Spree::Admin::StockMovementsHelper, type: :helper do
|
|
5
|
-
|
|
6
|
-
describe "#pretty_originator" do
|
|
7
|
-
|
|
8
|
-
context "transfering between two locations" do
|
|
9
|
-
let(:destination_location) { create(:stock_location_with_items) }
|
|
10
|
-
let(:source_location) { create(:stock_location_with_items) }
|
|
11
|
-
let(:stock_item) { source_location.stock_items.order(:id).first }
|
|
12
|
-
let(:variant) { stock_item.variant }
|
|
13
|
-
|
|
14
|
-
before do
|
|
15
|
-
@stock_transfer = Spree::StockTransfer.create(reference: 'PO123')
|
|
16
|
-
variants = { variant => 5 }
|
|
17
|
-
@stock_transfer.transfer(source_location,
|
|
18
|
-
destination_location,
|
|
19
|
-
variants)
|
|
20
|
-
helper.pretty_originator(@stock_transfer.stock_movements.last)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
it "returns link to stock transfer" do
|
|
25
|
-
expect(helper.pretty_originator(@stock_transfer.stock_movements.last)).to eq @stock_transfer.number
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
class Test
|
|
5
|
-
end
|
|
6
|
-
module Submodule
|
|
7
|
-
class Test
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module Spree
|
|
13
|
-
module Admin
|
|
14
|
-
describe Resource, type: :model do
|
|
15
|
-
let(:resource_base) { Resource.new('spree/admin/test', 'test', 'widget') }
|
|
16
|
-
let(:resource_submodule) { Resource.new('spree/admin/submodule/test', 'test', 'widget') }
|
|
17
|
-
let(:resource_object_name) { Resource.new('spree/admin/test', 'test', 'gadget', 'widget') }
|
|
18
|
-
|
|
19
|
-
it "can get base model class" do
|
|
20
|
-
expect(resource_base.model_class).to eq(Spree::Test)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "can get submodule class" do
|
|
24
|
-
expect(resource_submodule.model_class).to eq(Spree::Submodule::Test)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "can get base model name (only used for parent)" do
|
|
28
|
-
expect(resource_base.model_name).to eq('widget')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "can get submodule model name (only used for parent)" do
|
|
32
|
-
expect(resource_submodule.model_name).to eq('widget')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "can get base object name" do
|
|
36
|
-
expect(resource_base.object_name).to eq('test')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "can get submodule object name" do
|
|
40
|
-
expect(resource_submodule.object_name).to eq('submodule_test')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "can get overridden object name" do
|
|
44
|
-
expect(resource_object_name.object_name).to eq('widget')
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
module Admin
|
|
5
|
-
RSpec.describe "AdminPath", type: :routing do
|
|
6
|
-
it "shoud route to admin by default" do
|
|
7
|
-
expect(spree.admin_path).to eq("/admin")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "should route to the the configured path" do
|
|
11
|
-
Spree.admin_path = "/secret"
|
|
12
|
-
Rails.application.reload_routes!
|
|
13
|
-
expect(spree.admin_path).to eq("/secret")
|
|
14
|
-
|
|
15
|
-
# restore the path for other tests
|
|
16
|
-
Spree.admin_path = "/admin"
|
|
17
|
-
Rails.application.reload_routes!
|
|
18
|
-
expect(spree.admin_path).to eq("/admin")
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|