spree_backend 3.0.5 → 3.0.6
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/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,62 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Shipping Methods", type: :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
let!(:zone) { create(:global_zone) }
|
|
6
|
+
let!(:shipping_method) { create(:shipping_method, zones: [zone]) }
|
|
7
|
+
|
|
8
|
+
after do
|
|
9
|
+
Capybara.ignore_hidden_elements = true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
Capybara.ignore_hidden_elements = false
|
|
14
|
+
# HACK: To work around no email prompting on check out
|
|
15
|
+
allow_any_instance_of(Spree::Order).to receive_messages(require_email: false)
|
|
16
|
+
create(:check_payment_method)
|
|
17
|
+
|
|
18
|
+
visit spree.admin_shipping_methods_path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "show" do
|
|
22
|
+
it "should display existing shipping methods" do
|
|
23
|
+
within_row(1) do
|
|
24
|
+
expect(column_text(1)).to eq(shipping_method.name)
|
|
25
|
+
expect(column_text(2)).to eq(zone.name)
|
|
26
|
+
expect(column_text(3)).to eq("Flat rate")
|
|
27
|
+
expect(column_text(4)).to eq("Both")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "create" do
|
|
33
|
+
it "should be able to create a new shipping method" do
|
|
34
|
+
click_link "New Shipping Method"
|
|
35
|
+
|
|
36
|
+
fill_in "shipping_method_name", with: "bullock cart"
|
|
37
|
+
|
|
38
|
+
within("#shipping_method_categories_field") do
|
|
39
|
+
check first("input[type='checkbox']")["name"]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
click_on "Create"
|
|
43
|
+
expect(current_path).to eql(spree.edit_admin_shipping_method_path(Spree::ShippingMethod.last))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Regression test for #1331
|
|
48
|
+
context "update" do
|
|
49
|
+
it "can change the calculator", js: true do
|
|
50
|
+
within("#listing_shipping_methods") do
|
|
51
|
+
click_icon :edit
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
expect(find(:css, ".calculator-settings-warning")).not_to be_visible
|
|
55
|
+
select2_search('Flexible Rate', from: 'Calculator')
|
|
56
|
+
expect(find(:css, ".calculator-settings-warning")).to be_visible
|
|
57
|
+
|
|
58
|
+
click_button "Update"
|
|
59
|
+
expect(page).not_to have_content("Shipping method is not found")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "States", type: :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
let!(:country) { create(:country) }
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
@hungary = Spree::Country.create!(:name => "Hungary", :iso_name => "Hungary")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def go_to_states_page
|
|
13
|
+
visit spree.admin_country_states_path(country)
|
|
14
|
+
expect(page).to have_selector('#new_state_link')
|
|
15
|
+
page.execute_script('$.fx.off = true')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "admin visiting states listing" do
|
|
19
|
+
let!(:state) { create(:state, :country => country) }
|
|
20
|
+
|
|
21
|
+
it "should correctly display the states" do
|
|
22
|
+
visit spree.admin_country_states_path(country)
|
|
23
|
+
expect(page).to have_content(state.name)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "creating and editing states" do
|
|
28
|
+
it "should allow an admin to edit existing states", js: true do
|
|
29
|
+
go_to_states_page
|
|
30
|
+
set_select2_field("country", country.id)
|
|
31
|
+
|
|
32
|
+
click_link "new_state_link"
|
|
33
|
+
fill_in "state_name", with: "Calgary"
|
|
34
|
+
fill_in "Abbreviation", with: "CL"
|
|
35
|
+
click_button "Create"
|
|
36
|
+
expect(page).to have_content("successfully created!")
|
|
37
|
+
expect(page).to have_content("Calgary")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should allow an admin to create states for non default countries", js: true do
|
|
41
|
+
go_to_states_page
|
|
42
|
+
set_select2_field "#country", @hungary.id
|
|
43
|
+
# Just so the change event actually gets triggered in this spec
|
|
44
|
+
# It is definitely triggered in the "real world"
|
|
45
|
+
page.execute_script("$('#country').change();")
|
|
46
|
+
|
|
47
|
+
click_link "new_state_link"
|
|
48
|
+
fill_in "state_name", with: "Pest megye"
|
|
49
|
+
fill_in "Abbreviation", with: "PE"
|
|
50
|
+
click_button "Create"
|
|
51
|
+
expect(page).to have_content("successfully created!")
|
|
52
|
+
expect(page).to have_content("Pest megye")
|
|
53
|
+
expect(find("#s2id_country span").text).to eq("Hungary")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should show validation errors", js: true do
|
|
57
|
+
go_to_states_page
|
|
58
|
+
set_select2_field("country", country.id)
|
|
59
|
+
|
|
60
|
+
click_link "new_state_link"
|
|
61
|
+
|
|
62
|
+
fill_in "state_name", with: ""
|
|
63
|
+
fill_in "Abbreviation", with: ""
|
|
64
|
+
click_button "Create"
|
|
65
|
+
expect(page).to have_content("Name can't be blank")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Stock Locations", type: :feature, js: true do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
country = create(:country)
|
|
8
|
+
visit spree.admin_stock_locations_path
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "can create a new stock location" do
|
|
12
|
+
click_link "New Stock Location"
|
|
13
|
+
fill_in "Name", with: "London"
|
|
14
|
+
check "Active"
|
|
15
|
+
click_button "Create"
|
|
16
|
+
|
|
17
|
+
expect(page).to have_content("successfully created")
|
|
18
|
+
expect(page).to have_content("London")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "can delete an existing stock location" do
|
|
22
|
+
location = create(:stock_location)
|
|
23
|
+
visit current_path
|
|
24
|
+
|
|
25
|
+
expect(find('#listing_stock_locations')).to have_content("NY Warehouse")
|
|
26
|
+
accept_alert do
|
|
27
|
+
click_icon :delete
|
|
28
|
+
end
|
|
29
|
+
# Wait for API request to complete.
|
|
30
|
+
wait_for_ajax
|
|
31
|
+
visit current_path
|
|
32
|
+
expect(page).to have_content("No Stock Locations found")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "can update an existing stock location" do
|
|
36
|
+
create(:stock_location)
|
|
37
|
+
visit current_path
|
|
38
|
+
|
|
39
|
+
expect(page).to have_content("NY Warehouse")
|
|
40
|
+
|
|
41
|
+
click_icon :edit
|
|
42
|
+
fill_in "Name", with: "London"
|
|
43
|
+
click_button "Update"
|
|
44
|
+
|
|
45
|
+
expect(page).to have_content("successfully updated")
|
|
46
|
+
expect(page).to have_content("London")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Tax Categories", type: :feature, js: true do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
visit spree.admin_path
|
|
8
|
+
click_link "Configuration"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context "admin visiting tax categories list" do
|
|
12
|
+
it "should display the existing tax categories" do
|
|
13
|
+
create(:tax_category, name: "Clothing", tax_code: "CL001", description: "For Clothing")
|
|
14
|
+
click_link "Tax Categories"
|
|
15
|
+
within("h1") { expect(page).to have_content("Tax Categories") }
|
|
16
|
+
within_row(1) do
|
|
17
|
+
expect(column_text(1)).to eq("Clothing")
|
|
18
|
+
expect(column_text(2)).to eq("CL001")
|
|
19
|
+
expect(column_text(3)).to eq("For Clothing")
|
|
20
|
+
expect(column_text(4)).to eq("No")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "admin creating new tax category" do
|
|
26
|
+
before(:each) do
|
|
27
|
+
click_link "Tax Categories"
|
|
28
|
+
click_link "admin_new_tax_categories_link"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should be able to create new tax category" do
|
|
32
|
+
expect(page).to have_content("New Tax Category")
|
|
33
|
+
fill_in "tax_category_name", with: "sports goods"
|
|
34
|
+
fill_in "tax_category_description", with: "sports goods desc"
|
|
35
|
+
click_button "Create"
|
|
36
|
+
expect(page).to have_content("successfully created!")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should show validation errors if there are any" do
|
|
40
|
+
click_button "Create"
|
|
41
|
+
expect(page).to have_content("Name can't be blank")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "admin editing a tax category" do
|
|
46
|
+
it "should be able to update an existing tax category" do
|
|
47
|
+
create(:tax_category)
|
|
48
|
+
click_link "Tax Categories"
|
|
49
|
+
within_row(1) { click_icon :edit }
|
|
50
|
+
fill_in "tax_category_description", with: "desc 99"
|
|
51
|
+
click_button "Update"
|
|
52
|
+
expect(page).to have_content("successfully updated!")
|
|
53
|
+
expect(page).to have_content("desc 99")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Tax Rates", type: :feature, js: true do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
let!(:tax_rate) { create(:tax_rate, calculator: stub_model(Spree::Calculator)) }
|
|
7
|
+
|
|
8
|
+
# Regression test for #1422
|
|
9
|
+
it "can create a new tax rate" do
|
|
10
|
+
visit spree.admin_path
|
|
11
|
+
click_link "Configuration"
|
|
12
|
+
click_link "Tax Rates"
|
|
13
|
+
click_link "New Tax Rate"
|
|
14
|
+
fill_in "Rate", with: "0.05"
|
|
15
|
+
click_button "Create"
|
|
16
|
+
expect(page).to have_content("Tax Rate has been successfully created!")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Zones", type: :feature, js: true do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
Spree::Zone.delete_all
|
|
8
|
+
visit spree.admin_path
|
|
9
|
+
click_link "Configuration"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "show" do
|
|
13
|
+
it "should display existing zones" do
|
|
14
|
+
create(:zone, :name => "eastern", :description => "zone is eastern")
|
|
15
|
+
create(:zone, :name => "western", :description => "cool san fran")
|
|
16
|
+
click_link "Zones"
|
|
17
|
+
|
|
18
|
+
within_row(1) { expect(page).to have_content("eastern") }
|
|
19
|
+
within_row(2) { expect(page).to have_content("western") }
|
|
20
|
+
|
|
21
|
+
click_link "zones_order_by_description_title"
|
|
22
|
+
|
|
23
|
+
within_row(1) { expect(page).to have_content("western") }
|
|
24
|
+
within_row(2) { expect(page).to have_content("eastern") }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "create" do
|
|
29
|
+
it "should allow an admin to create a new zone" do
|
|
30
|
+
click_link "Zones"
|
|
31
|
+
click_link "admin_new_zone_link"
|
|
32
|
+
expect(page).to have_content("New Zone")
|
|
33
|
+
fill_in "zone_name", :with => "japan"
|
|
34
|
+
fill_in "zone_description", :with => "japanese time zone"
|
|
35
|
+
click_button "Create"
|
|
36
|
+
expect(page).to have_content("successfully created!")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Homepage", :type => :feature do
|
|
4
|
+
|
|
5
|
+
context 'as admin user' do
|
|
6
|
+
stub_authorization!
|
|
7
|
+
|
|
8
|
+
context "visiting the homepage" do
|
|
9
|
+
before(:each) do
|
|
10
|
+
visit spree.admin_path
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should have the header text 'Orders'" do
|
|
14
|
+
within('h1') { expect(page).to have_content("Orders") }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should have a link to overview" do
|
|
18
|
+
within("header") { page.find(:xpath, "//a[@href='/admin']") }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should have a link to orders" do
|
|
22
|
+
page.find_link("Orders")['/admin/orders']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should have a link to products" do
|
|
26
|
+
page.find_link("Products")['/admin/products']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should have a link to reports" do
|
|
30
|
+
page.find_link("Reports")['/admin/reports']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should have a link to configuration" do
|
|
34
|
+
page.find_link("Configuration")['/admin/configurations']
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "visiting the products tab" do
|
|
39
|
+
before(:each) do
|
|
40
|
+
visit spree.admin_products_path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should have a link to products" do
|
|
44
|
+
within('.sidebar') { page.find_link("Products")['/admin/products'] }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should have a link to option types" do
|
|
48
|
+
within('.sidebar') { page.find_link("Option Types")['/admin/option_types'] }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should have a link to properties" do
|
|
52
|
+
within('.sidebar') { page.find_link("Properties")['/admin/properties'] }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should have a link to prototypes" do
|
|
56
|
+
within('.sidebar') { page.find_link("Prototypes")['/admin/prototypes'] }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context 'as fakedispatch user' do
|
|
62
|
+
|
|
63
|
+
before do
|
|
64
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
custom_authorization! do |user|
|
|
68
|
+
can [:admin, :edit, :index, :read], Spree::Order
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should only display tabs fakedispatch has access to' do
|
|
72
|
+
visit spree.admin_path
|
|
73
|
+
expect(page).to have_link('Orders')
|
|
74
|
+
expect(page).not_to have_link('Products')
|
|
75
|
+
expect(page).not_to have_link('Promotions')
|
|
76
|
+
expect(page).not_to have_link('Reports')
|
|
77
|
+
expect(page).not_to have_link('Configurations')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "setting locale", :type => :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before do
|
|
7
|
+
I18n.locale = I18n.default_locale
|
|
8
|
+
I18n.backend.store_translations(:fr,
|
|
9
|
+
:date => {
|
|
10
|
+
:month_names => [],
|
|
11
|
+
},
|
|
12
|
+
:spree => {
|
|
13
|
+
:admin => {
|
|
14
|
+
:tab => { :orders => "Ordres" }
|
|
15
|
+
},
|
|
16
|
+
:listing_orders => "Ordres",
|
|
17
|
+
})
|
|
18
|
+
Spree::Backend::Config[:locale] = "fr"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after do
|
|
22
|
+
I18n.locale = I18n.default_locale
|
|
23
|
+
Spree::Backend::Config[:locale] = "en"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should be in french" do
|
|
27
|
+
visit spree.admin_path
|
|
28
|
+
click_link "Ordres"
|
|
29
|
+
expect(page).to have_content("Ordres")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Adjustments Promotions", type: :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
promotion = create(:promotion_with_item_adjustment,
|
|
8
|
+
:name => "$10 off",
|
|
9
|
+
:path => 'test',
|
|
10
|
+
:code => "10_off",
|
|
11
|
+
:starts_at => 1.day.ago,
|
|
12
|
+
:expires_at => 1.day.from_now,
|
|
13
|
+
:adjustment_rate => 10)
|
|
14
|
+
|
|
15
|
+
order = create(:order_with_totals)
|
|
16
|
+
line_item = order.line_items.first
|
|
17
|
+
# so we can be sure of a determinate price in our assertions
|
|
18
|
+
line_item.update_column(:price, 10)
|
|
19
|
+
|
|
20
|
+
visit spree.admin_order_adjustments_path(order)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "admin adding a promotion" do
|
|
24
|
+
context "successfully" do
|
|
25
|
+
it "should create a new adjustment", js: true do
|
|
26
|
+
fill_in "coupon_code", with: "10_off"
|
|
27
|
+
click_button "Add Coupon Code"
|
|
28
|
+
expect(page).to have_content("$10 off")
|
|
29
|
+
expect(page).to have_content("-$10.00")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "for non-existing promotion" do
|
|
34
|
+
it "should show an error message", js: true do
|
|
35
|
+
fill_in "coupon_code", with: "does_not_exist"
|
|
36
|
+
click_button "Add Coupon Code"
|
|
37
|
+
expect(page).to have_content("doesn't exist.")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "for already applied promotion" do
|
|
42
|
+
it "should show an error message", js: true do
|
|
43
|
+
fill_in "coupon_code", with: "10_off"
|
|
44
|
+
click_button "Add Coupon Code"
|
|
45
|
+
expect(page).to have_content('-$10.00')
|
|
46
|
+
|
|
47
|
+
fill_in "coupon_code", with: "10_off"
|
|
48
|
+
click_button "Add Coupon Code"
|
|
49
|
+
expect(page).to have_content("already been applied")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|