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,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module Admin
|
|
5
|
+
describe TaxCategoriesController, :type => :controller do
|
|
6
|
+
stub_authorization!
|
|
7
|
+
|
|
8
|
+
describe 'GET #index' do
|
|
9
|
+
subject { spree_get :index }
|
|
10
|
+
|
|
11
|
+
it 'should be successful' do
|
|
12
|
+
expect(subject).to be_success
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe 'PUT #update' do
|
|
17
|
+
let(:tax_category) { create :tax_category }
|
|
18
|
+
|
|
19
|
+
subject { spree_put :update, {id: tax_category.id, tax_category: { name: 'Foo', tax_code: 'Bar' }}}
|
|
20
|
+
|
|
21
|
+
it 'should redirect' do
|
|
22
|
+
expect(subject).to be_redirect
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should update' do
|
|
26
|
+
subject
|
|
27
|
+
tax_category.reload
|
|
28
|
+
expect(tax_category.name).to eq('Foo')
|
|
29
|
+
expect(tax_category.tax_code).to eq('Bar')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'spree/testing_support/bar_ability'
|
|
3
|
+
|
|
4
|
+
describe Spree::Admin::UsersController, :type => :controller do
|
|
5
|
+
let(:user) { create(:user) }
|
|
6
|
+
let(:mock_user) { mock_model Spree.user_class }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(controller).to receive_messages :spree_current_user => user
|
|
10
|
+
user.spree_roles.clear
|
|
11
|
+
stub_const('Spree::User', user.class)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "#show" do
|
|
15
|
+
before do
|
|
16
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "redirects to edit" do
|
|
20
|
+
spree_get :show, id: user.id
|
|
21
|
+
expect(response).to redirect_to spree.edit_admin_user_path(user)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context '#authorize_admin' do
|
|
26
|
+
before { use_mock_user }
|
|
27
|
+
|
|
28
|
+
it 'grant access to users with an admin role' do
|
|
29
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
30
|
+
spree_post :index
|
|
31
|
+
expect(response).to render_template :index
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "allows admins to update a user's API key" do
|
|
35
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
36
|
+
expect(mock_user).to receive(:generate_spree_api_key!).and_return(true)
|
|
37
|
+
spree_put :generate_api_key, id: mock_user.id
|
|
38
|
+
expect(response).to redirect_to(spree.edit_admin_user_path(mock_user))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "allows admins to clear a user's API key" do
|
|
42
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
43
|
+
expect(mock_user).to receive(:clear_spree_api_key!).and_return(true)
|
|
44
|
+
spree_put :clear_api_key, id: mock_user.id
|
|
45
|
+
expect(response).to redirect_to(spree.edit_admin_user_path(mock_user))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'deny access to users with an bar role' do
|
|
49
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
|
|
50
|
+
Spree::Ability.register_ability(BarAbility)
|
|
51
|
+
spree_post :index
|
|
52
|
+
expect(response).to redirect_to '/unauthorized'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'deny access to users with an bar role' do
|
|
56
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'bar')
|
|
57
|
+
Spree::Ability.register_ability(BarAbility)
|
|
58
|
+
spree_post :update, { id: '9' }
|
|
59
|
+
expect(response).to redirect_to '/unauthorized'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'deny access to users without an admin role' do
|
|
63
|
+
allow(user).to receive_messages :has_spree_role? => false
|
|
64
|
+
spree_post :index
|
|
65
|
+
expect(response).to redirect_to '/unauthorized'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "#create" do
|
|
70
|
+
before do
|
|
71
|
+
use_mock_user
|
|
72
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "can create a shipping_address" do
|
|
76
|
+
expect(Spree.user_class).to receive(:new).with(hash_including(
|
|
77
|
+
"ship_address_attributes" => { "city" => "New York" }
|
|
78
|
+
))
|
|
79
|
+
spree_post :create, { :user => { :ship_address_attributes => { :city => "New York" } } }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "can create a billing_address" do
|
|
83
|
+
expect(Spree.user_class).to receive(:new).with(hash_including(
|
|
84
|
+
"bill_address_attributes" => { "city" => "New York" }
|
|
85
|
+
))
|
|
86
|
+
spree_post :create, { :user => { :bill_address_attributes => { :city => "New York" } } }
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#update" do
|
|
91
|
+
before do
|
|
92
|
+
use_mock_user
|
|
93
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "allows shipping address attributes through" do
|
|
97
|
+
expect(mock_user).to receive(:update_attributes).with(hash_including(
|
|
98
|
+
"ship_address_attributes" => { "city" => "New York" }
|
|
99
|
+
))
|
|
100
|
+
spree_put :update, { :id => mock_user.id, :user => { :ship_address_attributes => { :city => "New York" } } }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "allows billing address attributes through" do
|
|
104
|
+
expect(mock_user).to receive(:update_attributes).with(hash_including(
|
|
105
|
+
"bill_address_attributes" => { "city" => "New York" }
|
|
106
|
+
))
|
|
107
|
+
spree_put :update, { :id => mock_user.id, :user => { :bill_address_attributes => { :city => "New York" } } }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "allows updating without password resetting" do
|
|
111
|
+
expect(mock_user).to receive(:update_attributes).with(hash_not_including(password: '', password_confirmation: ''))
|
|
112
|
+
spree_put :update, id: mock_user.id, user: { password: '', password_confirmation: '', email: 'spree@example.com' }
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe "#orders" do
|
|
117
|
+
let(:order) { create(:order) }
|
|
118
|
+
before do
|
|
119
|
+
user.orders << order
|
|
120
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "assigns a list of the users orders" do
|
|
124
|
+
spree_get :orders, { :id => user.id }
|
|
125
|
+
expect(assigns[:orders].count).to eq 1
|
|
126
|
+
expect(assigns[:orders].first).to eq order
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "assigns a ransack search for Spree::Order" do
|
|
130
|
+
spree_get :orders, { :id => user.id }
|
|
131
|
+
expect(assigns[:search]).to be_a Ransack::Search
|
|
132
|
+
expect(assigns[:search].klass).to eq Spree::Order
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe "#items" do
|
|
137
|
+
let(:order) { create(:order) }
|
|
138
|
+
before do
|
|
139
|
+
user.orders << order
|
|
140
|
+
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "assigns a list of the users orders" do
|
|
144
|
+
spree_get :items, { :id => user.id }
|
|
145
|
+
expect(assigns[:orders].count).to eq 1
|
|
146
|
+
expect(assigns[:orders].first).to eq order
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "assigns a ransack search for Spree::Order" do
|
|
150
|
+
spree_get :items, { :id => user.id }
|
|
151
|
+
expect(assigns[:search]).to be_a Ransack::Search
|
|
152
|
+
expect(assigns[:search].klass).to eq Spree::Order
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def use_mock_user
|
|
158
|
+
allow(mock_user).to receive(:save).and_return(true)
|
|
159
|
+
allow(Spree.user_class).to receive(:find).with(mock_user.id.to_s).and_return(mock_user)
|
|
160
|
+
allow(Spree.user_class).to receive(:new).and_return(mock_user)
|
|
161
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module Admin
|
|
5
|
+
describe VariantsController, :type => :controller do
|
|
6
|
+
stub_authorization!
|
|
7
|
+
|
|
8
|
+
describe "#index" do
|
|
9
|
+
let(:product) { create(:product) }
|
|
10
|
+
let!(:variant_1) { create(:variant, product: product) }
|
|
11
|
+
let!(:variant_2) { create(:variant, product: product) }
|
|
12
|
+
|
|
13
|
+
context "deleted is not requested" do
|
|
14
|
+
it "assigns the variants for a requested product" do
|
|
15
|
+
spree_get :index, product_id: product.slug
|
|
16
|
+
expect(assigns(:collection)).to include variant_1
|
|
17
|
+
expect(assigns(:collection)).to include variant_2
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "deleted is requested" do
|
|
22
|
+
before { variant_2.destroy }
|
|
23
|
+
it "assigns only deleted variants for a requested product" do
|
|
24
|
+
spree_get :index, product_id: product.slug, deleted: "on"
|
|
25
|
+
expect(assigns(:collection)).not_to include variant_1
|
|
26
|
+
expect(assigns(:collection)).to include variant_2
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Analytics Tracker", type: :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
context "index" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
2.times { create(:tracker) }
|
|
9
|
+
visit spree.admin_trackers_path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should have the right content" do
|
|
13
|
+
expect(page).to have_content("Analytics Trackers")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should have the right tabular values displayed" do
|
|
17
|
+
within_row(1) do
|
|
18
|
+
expect(column_text(1)).to eq("A100")
|
|
19
|
+
expect(column_text(2)).to eq("Yes")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
within_row(2) do
|
|
23
|
+
expect(column_text(1)).to eq("A100")
|
|
24
|
+
expect(column_text(2)).to eq("Yes")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "create" do
|
|
30
|
+
before(:each) do
|
|
31
|
+
visit spree.admin_trackers_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should be able to create a new analytics tracker" do
|
|
35
|
+
click_link "admin_new_tracker_link"
|
|
36
|
+
fill_in "tracker_analytics_id", with: "A100"
|
|
37
|
+
click_button "Create"
|
|
38
|
+
|
|
39
|
+
expect(page).to have_content("successfully created!")
|
|
40
|
+
within_row(1) do
|
|
41
|
+
expect(column_text(1)).to eq("A100")
|
|
42
|
+
expect(column_text(2)).to eq("Yes")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
describe "Countries", type: :feature do
|
|
5
|
+
stub_authorization!
|
|
6
|
+
|
|
7
|
+
it "deletes a state", js: true do
|
|
8
|
+
visit spree.admin_countries_path
|
|
9
|
+
click_link "New Country"
|
|
10
|
+
|
|
11
|
+
fill_in "Name", with: "Brazil"
|
|
12
|
+
fill_in "Iso Name", with: "BRL"
|
|
13
|
+
click_button "Create"
|
|
14
|
+
|
|
15
|
+
accept_alert do
|
|
16
|
+
click_icon :delete
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
wait_for_ajax
|
|
20
|
+
|
|
21
|
+
expect { Country.find(country.id) }.to raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
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.edit_admin_general_settings_path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "visiting general settings (admin)" do
|
|
13
|
+
it "should have the right content" do
|
|
14
|
+
expect(page).to have_content("General Settings")
|
|
15
|
+
expect(find("#store_name").value).to eq("Test Store")
|
|
16
|
+
expect(find("#store_url").value).to eq("test.example.org")
|
|
17
|
+
expect(find("#store_mail_from_address").value).to eq("test@example.org")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "editing general settings (admin)" do
|
|
22
|
+
it "should be able to update the site name" do
|
|
23
|
+
fill_in "store_name", with: "Spree Demo Site99"
|
|
24
|
+
fill_in "store_mail_from_address", with: "spree@example.org"
|
|
25
|
+
click_button "Update"
|
|
26
|
+
|
|
27
|
+
assert_successful_update_message(:general_settings)
|
|
28
|
+
expect(find("#store_name").value).to eq("Spree Demo Site99")
|
|
29
|
+
expect(find("#store_mail_from_address").value).to eq("spree@example.org")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "clearing the cache" do
|
|
34
|
+
it "should clear the cache" do
|
|
35
|
+
expect(page).to_not have_content(Spree.t(:clear_cache_ok))
|
|
36
|
+
expect(page).to have_content(Spree.t(:clear_cache_warning))
|
|
37
|
+
|
|
38
|
+
click_button "Clear Cache"
|
|
39
|
+
|
|
40
|
+
expect(page).to have_content(Spree.t(:clear_cache_ok))
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Payment Methods", type: :feature do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
visit spree.admin_payment_methods_path
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context "admin visiting payment methods listing page" do
|
|
11
|
+
it "should display existing payment methods" do
|
|
12
|
+
create(:check_payment_method)
|
|
13
|
+
visit current_path
|
|
14
|
+
|
|
15
|
+
within("table#listing_payment_methods") do
|
|
16
|
+
expect(all("th")[0].text).to eq("Name")
|
|
17
|
+
expect(all("th")[1].text).to eq("Provider")
|
|
18
|
+
expect(all("th")[2].text).to eq("Display")
|
|
19
|
+
expect(all("th")[3].text).to eq("Active")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
within('table#listing_payment_methods') do
|
|
23
|
+
expect(page).to have_content("Spree::PaymentMethod::Check")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "admin creating a new payment method" do
|
|
29
|
+
it "should be able to create a new payment method" do
|
|
30
|
+
click_link "admin_new_payment_methods_link"
|
|
31
|
+
expect(page).to have_content("New Payment Method")
|
|
32
|
+
fill_in "payment_method_name", with: "check90"
|
|
33
|
+
fill_in "payment_method_description", with: "check90 desc"
|
|
34
|
+
select "PaymentMethod::Check", from: "gtwy-type"
|
|
35
|
+
click_button "Create"
|
|
36
|
+
expect(page).to have_content("successfully created!")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "admin editing a payment method", js: true do
|
|
41
|
+
before(:each) do
|
|
42
|
+
create(:check_payment_method)
|
|
43
|
+
visit current_path
|
|
44
|
+
|
|
45
|
+
within("table#listing_payment_methods") do
|
|
46
|
+
click_icon(:edit)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should be able to edit an existing payment method" do
|
|
51
|
+
fill_in "payment_method_name", with: "Payment 99"
|
|
52
|
+
click_button "Update"
|
|
53
|
+
expect(page).to have_content("successfully updated!")
|
|
54
|
+
expect(find_field("payment_method_name").value).to eq("Payment 99")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should display validation errors" do
|
|
58
|
+
fill_in "payment_method_name", with: ""
|
|
59
|
+
click_button "Update"
|
|
60
|
+
expect(page).to have_content("Name can't be blank")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Roles", type: :feature, js: true do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
create(:role, name: "admin")
|
|
8
|
+
create(:role, name: "user")
|
|
9
|
+
visit spree.admin_path
|
|
10
|
+
click_link "Configuration"
|
|
11
|
+
# Crap workaround for animation to finish expanding so click doesn't hit ReimbursementTypes.
|
|
12
|
+
sleep 1
|
|
13
|
+
click_link "Roles"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "show" do
|
|
17
|
+
it "should display existing roles" do
|
|
18
|
+
within_row(1) { expect(page).to have_content("admin") }
|
|
19
|
+
within_row(2) { expect(page).to have_content("user") }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "create" do
|
|
24
|
+
it "should be able to create a new role" do
|
|
25
|
+
click_link "admin_new_role_link"
|
|
26
|
+
expect(page).to have_content("New Role")
|
|
27
|
+
fill_in "role_name", with: "blogger"
|
|
28
|
+
click_button "Create"
|
|
29
|
+
expect(page).to have_content("successfully created!")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "edit" do
|
|
34
|
+
it "should not be able to edit the admin role" do
|
|
35
|
+
within_row(1) do
|
|
36
|
+
expect(find("td:nth-child(2)")).not_to have_selector(:css, "span.icon-edit")
|
|
37
|
+
expect(find("td:nth-child(2)")).not_to have_selector(:css, "span.icon-delete")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
it "should be able to edit the user role" do
|
|
41
|
+
within_row(2) do
|
|
42
|
+
expect(find("td:nth-child(2)")).to have_selector(:css, "span.icon-edit")
|
|
43
|
+
expect(find("td:nth-child(2)")).to have_selector(:css, "span.icon-delete")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|