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.

Potentially problematic release.


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

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,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe "General Settings", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ store = create(:store, name: 'Test Store', url: 'test.example.org',
8
+ mail_from_address: 'test@example.org')
9
+ visit spree.admin_path
10
+ click_link "Settings"
11
+ click_link "General Settings"
12
+ end
13
+
14
+ context "visiting general settings (admin)" do
15
+ it "should have the right content" do
16
+ expect(page).to have_content("General Settings")
17
+ expect(find("#store_name").value).to eq("Test Store")
18
+ expect(find("#store_url").value).to eq("test.example.org")
19
+ expect(find("#store_mail_from_address").value).to eq("test@example.org")
20
+ end
21
+ end
22
+
23
+ context "editing general settings (admin)" do
24
+ it "should be able to update the site name" do
25
+ fill_in "store_name", with: "Spree Demo Site99"
26
+ fill_in "store_mail_from_address", with: "spree@example.org"
27
+ click_button "Update"
28
+
29
+ assert_successful_update_message(:general_settings)
30
+ expect(find("#store_name").value).to eq("Spree Demo Site99")
31
+ expect(find("#store_mail_from_address").value).to eq("spree@example.org")
32
+ end
33
+ end
34
+
35
+ context "clearing the cache" do
36
+ it "should clear the cache" do
37
+ expect(page).to_not have_content(Spree.t(:clear_cache_ok))
38
+ expect(page).to have_content(Spree.t(:clear_cache_warning))
39
+
40
+ click_button "Clear Cache"
41
+
42
+ expect(page).to have_content(Spree.t(:clear_cache_ok))
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Payment Methods", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Settings"
9
+ end
10
+
11
+ context "admin visiting payment methods listing page" do
12
+ it "should display existing payment methods" do
13
+ create(:check_payment_method)
14
+ click_link "Payment Methods"
15
+
16
+ within("table#listing_payment_methods") do
17
+ expect(all("th")[0].text).to eq("Name")
18
+ expect(all("th")[1].text).to eq("Provider")
19
+ expect(all("th")[2].text).to eq("Display")
20
+ expect(all("th")[3].text).to eq("Active")
21
+ end
22
+
23
+ within('table#listing_payment_methods') do
24
+ expect(page).to have_content("Spree::PaymentMethod::Check")
25
+ end
26
+ end
27
+ end
28
+
29
+ context "admin creating a new payment method" do
30
+ it "should be able to create a new payment method" do
31
+ click_link "Payment Methods"
32
+ click_link "admin_new_payment_methods_link"
33
+ expect(page).to have_content("New Payment Method")
34
+ fill_in "payment_method_name", :with => "check90"
35
+ fill_in "payment_method_description", :with => "check90 desc"
36
+ select "PaymentMethod::Check", :from => "gtwy-type"
37
+ click_button "Create"
38
+ expect(page).to have_content("successfully created!")
39
+ end
40
+ end
41
+
42
+ context "admin editing a payment method" do
43
+ before(:each) do
44
+ create(:check_payment_method)
45
+ click_link "Payment Methods"
46
+ within("table#listing_payment_methods") do
47
+ click_icon(:edit)
48
+ end
49
+ end
50
+
51
+ it "should be able to edit an existing payment method" do
52
+ fill_in "payment_method_name", :with => "Payment 99"
53
+ click_button "Update"
54
+ expect(page).to have_content("successfully updated!")
55
+ expect(find_field("payment_method_name").value).to eq("Payment 99")
56
+ end
57
+
58
+ it "should display validation errors" do
59
+ fill_in "payment_method_name", :with => ""
60
+ click_button "Update"
61
+ expect(page).to have_content("Name can't be blank")
62
+ end
63
+ end
64
+
65
+ context "changing type and payment_source", js: true do
66
+ after do
67
+ # cleanup
68
+ Spree::Config.static_model_preferences.for_class(Spree::Gateway::Bogus).clear
69
+ end
70
+
71
+ it "displays message when changing type" do
72
+ create(:credit_card_payment_method)
73
+ click_link "Payment Methods"
74
+ click_icon :edit
75
+ expect(page).to have_content('TEST MODE')
76
+
77
+ select2_search 'Spree::PaymentMethod::Check', from: 'Provider'
78
+ expect(page).to have_content('you must save first')
79
+ expect(page).to have_no_content('TEST MODE')
80
+
81
+ # change back
82
+ select2_search 'Spree::Gateway::Bogus', from: 'Provider'
83
+ expect(page).to have_no_content('you must save first')
84
+ expect(page).to have_content('TEST MODE')
85
+ end
86
+
87
+ it "displays message when changing preference source" do
88
+ Spree::Config.static_model_preferences.add(Spree::Gateway::Bogus, 'my_prefs', {})
89
+
90
+ create(:credit_card_payment_method)
91
+ click_link "Payment Methods"
92
+ click_icon :edit
93
+ expect(page).to have_content('TEST MODE')
94
+
95
+ select2_search 'my_prefs', from: 'Preference Source'
96
+ expect(page).to have_content('you must save first')
97
+ expect(page).to have_no_content('TEST MODE')
98
+
99
+ # change back
100
+ select2_search 'Custom', from: 'Preference Source'
101
+ expect(page).to have_no_content('you must save first')
102
+ expect(page).to have_content('TEST MODE')
103
+ end
104
+
105
+ it "updates successfully and keeps secrets" do
106
+ Spree::Config.static_model_preferences.add(Spree::Gateway::Bogus, 'my_prefs', {server: 'secret'})
107
+
108
+ create(:credit_card_payment_method)
109
+ click_link "Payment Methods"
110
+ click_icon :edit
111
+
112
+ select2_search 'my_prefs', from: 'Preference Source'
113
+ click_on 'Update'
114
+ expect(page).to have_content('Using static preferences')
115
+ expect(page).to have_no_content('secret')
116
+
117
+ # change back
118
+ select2_search 'Custom', from: 'Preference Source'
119
+ click_on 'Update'
120
+ expect(page).to have_content('TEST MODE')
121
+ expect(page).to have_no_content('secret')
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,64 @@
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_path
19
+ click_link "Settings"
20
+ click_link "Shipping Methods"
21
+ end
22
+
23
+ context "show" do
24
+ it "should display existing shipping methods" do
25
+ within_row(1) do
26
+ expect(column_text(1)).to eq(shipping_method.name)
27
+ expect(column_text(2)).to eq(zone.name)
28
+ expect(column_text(3)).to eq("Flat rate")
29
+ expect(column_text(4)).to eq("Both")
30
+ end
31
+ end
32
+ end
33
+
34
+ context "create" do
35
+ it "should be able to create a new shipping method" do
36
+ click_link "New Shipping Method"
37
+
38
+ fill_in "shipping_method_name", :with => "bullock cart"
39
+
40
+ within("#shipping_method_categories_field") do
41
+ check first("input[type='checkbox']")["name"]
42
+ end
43
+
44
+ click_on "Create"
45
+ expect(current_path).to eql(spree.edit_admin_shipping_method_path(Spree::ShippingMethod.last))
46
+ end
47
+ end
48
+
49
+ # Regression test for #1331
50
+ context "update" do
51
+ it "can change the calculator", :js => true do
52
+ within("#listing_shipping_methods") do
53
+ click_icon :edit
54
+ end
55
+
56
+ expect(find(:css, ".calculator-settings-warning")).not_to be_visible
57
+ select2_search('Flexible Rate', :from => 'Calculator')
58
+ expect(find(:css, ".calculator-settings-warning")).to be_visible
59
+
60
+ click_button "Update"
61
+ expect(page).not_to have_content("Shipping method is not found")
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe "States", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:country) { create(:country) }
7
+
8
+ let!(:hungary) do
9
+ 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_css("#new_state_link")
15
+ end
16
+
17
+ context "admin visiting states listing" do
18
+ let!(:state) { create(:state, :country => country) }
19
+
20
+ it "should correctly display the states" do
21
+ visit spree.admin_country_states_path(country)
22
+ expect(page).to have_content(state.name)
23
+ end
24
+ end
25
+
26
+ context "creating and editing states" do
27
+ it "should allow an admin to edit existing states", :js => true do
28
+ go_to_states_page
29
+ select2 country.name, from: 'Country'
30
+
31
+ click_link "new_state_link"
32
+ fill_in "state_name", :with => "Calgary"
33
+ fill_in "Abbreviation", :with => "CL"
34
+ click_button "Create"
35
+ expect(page).to have_content("successfully created!")
36
+ expect(page).to have_content("Calgary")
37
+ end
38
+
39
+ it "should allow an admin to create states for non default countries", :js => true do
40
+ go_to_states_page
41
+ select2 hungary.name, from: 'Country'
42
+
43
+ click_link "new_state_link"
44
+ fill_in "state_name", :with => "Pest megye"
45
+ fill_in "Abbreviation", :with => "PE"
46
+ click_button "Create"
47
+ expect(page).to have_content("successfully created!")
48
+ expect(page).to have_content("Pest megye")
49
+ expect(find("#s2id_country span").text).to eq("Hungary")
50
+ end
51
+
52
+ it "should show validation errors", :js => true do
53
+ go_to_states_page
54
+ select2 country.name, from: 'Country'
55
+
56
+ click_link "new_state_link"
57
+
58
+ fill_in "state_name", :with => ""
59
+ fill_in "Abbreviation", :with => ""
60
+ click_button "Create"
61
+ expect(page).to have_content("Name can't be blank")
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Stock Locations", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ country = create(:country)
8
+ visit spree.admin_path
9
+ click_link "Settings"
10
+ click_link "Stock Locations"
11
+ end
12
+
13
+ it "can create a new stock location" do
14
+ click_link "New Stock Location"
15
+ fill_in "Name", with: "London"
16
+ check "Active"
17
+ click_button "Create"
18
+
19
+ expect(page).to have_content("successfully created")
20
+ expect(page).to have_content("London")
21
+ end
22
+
23
+ it "can delete an existing stock location", js: true do
24
+ location = create(:stock_location)
25
+ visit current_path
26
+
27
+ expect(find('#listing_stock_locations')).to have_content("NY Warehouse")
28
+ accept_alert do
29
+ click_icon :trash
30
+ end
31
+ # Wait for API request to complete.
32
+ wait_for_ajax
33
+ visit current_path
34
+ expect(page).to have_content("NO STOCK LOCATIONS FOUND")
35
+ end
36
+
37
+ it "can update an existing stock location" do
38
+ create(:stock_location)
39
+ visit current_path
40
+
41
+ expect(page).to have_content("NY Warehouse")
42
+
43
+ click_icon :edit
44
+ fill_in "Name", with: "London"
45
+ click_button "Update"
46
+
47
+ expect(page).to have_content("successfully updated")
48
+ expect(page).to have_content("London")
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Tax Categories", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Settings"
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
+ expect(page).to have_content("Listing 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,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Tax Rates", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:tax_rate) { create(:tax_rate, :calculator => stub_model(Spree::Calculator)) }
7
+
8
+ before do
9
+ visit spree.admin_path
10
+ click_link "Settings"
11
+ end
12
+
13
+ # Regression test for #535
14
+ it "can see a tax rate in the list if the tax category has been deleted" do
15
+ tax_rate.tax_category.update_column(:deleted_at, Time.now)
16
+ expect { click_link "Tax Rates" }.not_to raise_error
17
+ within(:xpath, all("table tbody td")[2].path) do
18
+ expect(page).to have_content("N/A")
19
+ end
20
+ end
21
+
22
+ # Regression test for #1422
23
+ it "can create a new tax rate" do
24
+ click_link "Tax Rates"
25
+ click_link "New Tax Rate"
26
+ fill_in "Rate", :with => "0.05"
27
+ click_button "Create"
28
+ expect(page).to have_content("Tax Rate has been successfully created!")
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Taxonomies", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Settings"
9
+ end
10
+
11
+ context "show" do
12
+ it "should display existing taxonomies" do
13
+ create(:taxonomy, :name => 'Brand')
14
+ create(:taxonomy, :name => 'Categories')
15
+ click_link "Taxonomies"
16
+ within_row(1) { expect(page).to have_content("Brand") }
17
+ within_row(2) { expect(page).to have_content("Categories") }
18
+ end
19
+ end
20
+
21
+ context "create" do
22
+ before(:each) do
23
+ click_link "Taxonomies"
24
+ click_link "admin_new_taxonomy_link"
25
+ end
26
+
27
+ it "should allow an admin to create a new taxonomy" do
28
+ expect(page).to have_content("New Taxonomy")
29
+ fill_in "taxonomy_name", :with => "sports"
30
+ click_button "Create"
31
+ expect(page).to have_content("successfully created!")
32
+ end
33
+
34
+ it "should display validation errors" do
35
+ fill_in "taxonomy_name", :with => ""
36
+ click_button "Create"
37
+ expect(page).to have_content("can't be blank")
38
+ end
39
+ end
40
+
41
+ context "edit" do
42
+ it "should allow an admin to update an existing taxonomy" do
43
+ create(:taxonomy)
44
+ click_link "Taxonomies"
45
+ within_row(1) { click_icon :edit }
46
+ fill_in "taxonomy_name", :with => "sports 99"
47
+ click_button "Update"
48
+ expect(page).to have_content("successfully updated!")
49
+ expect(page).to have_content("sports 99")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Zones", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ Spree::Zone.delete_all
8
+ visit spree.admin_path
9
+ click_link "Settings"
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,78 @@
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 a link to overview" do
14
+ within(:xpath, ".//figure[@data-hook='logo-wrapper']") { page.find(:xpath, "a[@href='/admin']") }
15
+ end
16
+
17
+ it "should have a link to orders" do
18
+ page.find_link("Orders")['/admin/orders']
19
+ end
20
+
21
+ it "should have a link to products" do
22
+ page.find_link("Products")['/admin/products']
23
+ end
24
+
25
+ it "should have a link to reports" do
26
+ page.find_link("Reports")['/admin/reports']
27
+ end
28
+
29
+ it "should have a link to configuration" do
30
+ page.find_link("Settings")['/admin/configurations']
31
+ end
32
+ end
33
+
34
+ context "visiting the products tab" do
35
+ before(:each) do
36
+ visit spree.admin_products_path
37
+ end
38
+
39
+ it "should have a link to products" do
40
+ within('#sub-menu') { page.find_link("Products")['/admin/products'] }
41
+ end
42
+
43
+ it "should have a link to option types" do
44
+ within('#sub-menu') { page.find_link("Option Types")['/admin/option_types'] }
45
+ end
46
+
47
+ it "should have a link to properties" do
48
+ within('#sub-menu') { page.find_link("Properties")['/admin/properties'] }
49
+ end
50
+
51
+ it "should have a link to prototypes" do
52
+ within('#sub-menu') { page.find_link("Prototypes")['/admin/prototypes'] }
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'as fakedispatch user' do
58
+
59
+ before do
60
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
61
+ end
62
+
63
+ custom_authorization! do |user|
64
+ can [:admin, :home], :dashboards
65
+ can [:admin, :edit, :index, :read], Spree::Order
66
+ end
67
+
68
+ it 'should only display tabs fakedispatch has access to' do
69
+ visit spree.admin_path
70
+ expect(page).to have_link('Orders')
71
+ expect(page).not_to have_link('Products')
72
+ expect(page).not_to have_link('Promotions')
73
+ expect(page).not_to have_link('Reports')
74
+ expect(page).not_to have_link('Settings')
75
+ end
76
+ end
77
+
78
+ end
@@ -0,0 +1,30 @@
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
+ expect(page).to have_content("Ordres")
29
+ end
30
+ end