office_clerk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +73 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +9 -0
- data/Gemfile +63 -0
- data/Gemfile.lock +367 -0
- data/Guardfile +28 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/app/assets/images/admin/baskets-2.jpg +0 -0
- data/app/assets/images/admin/baskets.jpg +0 -0
- data/app/assets/images/admin/categories-2.jpg +0 -0
- data/app/assets/images/admin/categories.jpg +0 -0
- data/app/assets/images/admin/clerks-2.jpg +0 -0
- data/app/assets/images/admin/clerks.jpg +0 -0
- data/app/assets/images/admin/orders-2.jpg +0 -0
- data/app/assets/images/admin/orders.jpg +0 -0
- data/app/assets/images/admin/products-2.jpg +0 -0
- data/app/assets/images/admin/products.jpg +0 -0
- data/app/assets/images/admin/purchases-2.jpg +0 -0
- data/app/assets/images/admin/purchases.jpg +0 -0
- data/app/assets/images/admin/suppliers-2.jpg +0 -0
- data/app/assets/images/admin/suppliers.jpg +0 -0
- data/app/assets/images/alpha.png +0 -0
- data/app/assets/images/down-icon.png +0 -0
- data/app/assets/images/header.gif +0 -0
- data/app/assets/images/hihih.jpg +0 -0
- data/app/assets/images/hue.png +0 -0
- data/app/assets/images/koe.jpg +0 -0
- data/app/assets/images/missing.png +0 -0
- data/app/assets/images/saturation.png +0 -0
- data/app/assets/images/shop/basket.jpg +0 -0
- data/app/assets/images/shop/farfalla-logo.jpg +0 -0
- data/app/assets/images/shop/header.gif +0 -0
- data/app/assets/images/shop/header.jpg +0 -0
- data/app/assets/images/shop/header.png +0 -0
- data/app/assets/images/shop/kansi.jpg +0 -0
- data/app/assets/images/shop/kansi.png +0 -0
- data/app/assets/images/shop/logo.png +0 -0
- data/app/assets/images/shop/menu-gourmet.jpg +0 -0
- data/app/assets/images/shop/menu-hius.jpg +0 -0
- data/app/assets/images/shop/menu-huonetuoksu.jpg +0 -0
- data/app/assets/images/shop/menu-info.jpg +0 -0
- data/app/assets/images/shop/menu-kasvo.jpg +0 -0
- data/app/assets/images/shop/menu-laukut.jpg +0 -0
- data/app/assets/images/shop/menu-luomu.jpg +0 -0
- data/app/assets/images/shop/menu-men.jpg +0 -0
- data/app/assets/images/shop/menu-oljy.jpg +0 -0
- data/app/assets/images/shop/menu-tuoksu1.jpg +0 -0
- data/app/assets/images/shop/menu-vaatteet.jpg +0 -0
- data/app/assets/images/shop/menu-valaisin.jpg +0 -0
- data/app/assets/images/shop/menu-vartalo.jpg +0 -0
- data/app/assets/images/shop/spacer.gif +0 -0
- data/app/assets/images/shop/tausta.jpg +0 -0
- data/app/assets/images/shop/tervetuloa.gif +0 -0
- data/app/assets/images/shop/valk.png +0 -0
- data/app/assets/images/shop/valk3.png +0 -0
- data/app/assets/images/shop/violetti-lev.jpg +0 -0
- data/app/assets/images/shop/violetti.jpg +0 -0
- data/app/assets/images/ui-anim_basic_16x16.gif +0 -0
- data/app/assets/images/up-icon.png +0 -0
- data/app/assets/javascripts/admin.js +29 -0
- data/app/assets/javascripts/shop.js +30 -0
- data/app/assets/stylesheets/admin.css.scss +129 -0
- data/app/assets/stylesheets/shop-receipt.css.scss +80 -0
- data/app/assets/stylesheets/shop.css.scss +403 -0
- data/app/controllers/admin_controller.rb +23 -0
- data/app/controllers/application_controller.rb +41 -0
- data/app/controllers/baskets_controller.rb +176 -0
- data/app/controllers/categories_controller.rb +69 -0
- data/app/controllers/clerks_controller.rb +64 -0
- data/app/controllers/orders_controller.rb +57 -0
- data/app/controllers/products_controller.rb +126 -0
- data/app/controllers/purchases_controller.rb +72 -0
- data/app/controllers/sessions_controller.rb +46 -0
- data/app/controllers/shop_controller.rb +90 -0
- data/app/controllers/suppliers_controller.rb +63 -0
- data/app/helpers/admin_helper.rb +28 -0
- data/app/helpers/application_helper.rb +25 -0
- data/app/helpers/baskets_helper.rb +4 -0
- data/app/helpers/categories_helper.rb +4 -0
- data/app/helpers/orders_helper.rb +4 -0
- data/app/helpers/products_helper.rb +4 -0
- data/app/helpers/purchases_helper.rb +4 -0
- data/app/helpers/shop_helper.rb +17 -0
- data/app/helpers/suppliers_helper.rb +4 -0
- data/app/mailers/.keep +0 -0
- data/app/models/basket.rb +114 -0
- data/app/models/category.rb +27 -0
- data/app/models/clerk.rb +46 -0
- data/app/models/item.rb +26 -0
- data/app/models/order.rb +72 -0
- data/app/models/product.rb +100 -0
- data/app/models/purchase.rb +26 -0
- data/app/models/supplier.rb +15 -0
- data/app/views/addresses/_form_fields.html.haml +4 -0
- data/app/views/addresses/show.html.haml +23 -0
- data/app/views/baskets/_small.html.haml +25 -0
- data/app/views/baskets/edit.html.haml +74 -0
- data/app/views/baskets/index.html.haml +55 -0
- data/app/views/baskets/show.html.haml +18 -0
- data/app/views/categories/_treeview.html.haml +8 -0
- data/app/views/categories/_triple.html.haml +12 -0
- data/app/views/categories/edit.html.haml +36 -0
- data/app/views/categories/index.html.haml +49 -0
- data/app/views/categories/show.html.haml +30 -0
- data/app/views/clerks/edit.html.haml +20 -0
- data/app/views/clerks/index.html.haml +37 -0
- data/app/views/clerks/show.html.haml +19 -0
- data/app/views/layouts/_admin_menu.html.haml +14 -0
- data/app/views/layouts/_google.haml +8 -0
- data/app/views/layouts/_messages.html.haml +5 -0
- data/app/views/layouts/admin.html.haml +42 -0
- data/app/views/layouts/shop.html.haml +96 -0
- data/app/views/orders/edit.html.haml +25 -0
- data/app/views/orders/index.html.haml +93 -0
- data/app/views/orders/show.html.haml +37 -0
- data/app/views/products/_line.html.haml +25 -0
- data/app/views/products/_name.html.haml +4 -0
- data/app/views/products/_online.html.haml +2 -0
- data/app/views/products/_triple.html.haml +12 -0
- data/app/views/products/edit.html.haml +42 -0
- data/app/views/products/index.html.haml +86 -0
- data/app/views/products/show.html.haml +94 -0
- data/app/views/purchases/edit.html.haml +9 -0
- data/app/views/purchases/index.html.haml +52 -0
- data/app/views/purchases/show.html.haml +32 -0
- data/app/views/sessions/new.html.haml +10 -0
- data/app/views/sessions/new_clerk.html.haml +22 -0
- data/app/views/shop/_groups.html.haml +8 -0
- data/app/views/shop/_menu.html.haml +5 -0
- data/app/views/shop/_sub.html.haml +0 -0
- data/app/views/shop/checkout.haml +142 -0
- data/app/views/shop/group.html.haml +9 -0
- data/app/views/shop/main_group.html.haml +9 -0
- data/app/views/shop/order.haml +104 -0
- data/app/views/shop/product.html.haml +67 -0
- data/app/views/shop/product_list.html.haml +50 -0
- data/app/views/shop/saved_search.html +6 -0
- data/app/views/shop/sub_group.html.haml +19 -0
- data/app/views/shop/tuotteista.html.haml +40 -0
- data/app/views/shop/welcome.html.haml +103 -0
- data/app/views/suppliers/edit.html.haml +10 -0
- data/app/views/suppliers/index.html.haml +40 -0
- data/app/views/suppliers/show.html.haml +27 -0
- data/bin/bundle +3 -0
- data/bin/rails +8 -0
- data/bin/rake +8 -0
- data/bin/rspec +7 -0
- data/bin/spring +18 -0
- data/config.ru +7 -0
- data/config/application.example.yml +13 -0
- data/config/application.rb +59 -0
- data/config/application.yml +13 -0
- data/config/boot.rb +7 -0
- data/config/database.yml +25 -0
- data/config/environment.rb +6 -0
- data/config/environments/development.rb +31 -0
- data/config/environments/production.rb +80 -0
- data/config/environments/test.rb +36 -0
- data/config/i18n-tasks.yml +11 -0
- data/config/initializers/attack.rb +32 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/migrate.rb +6 -0
- data/config/initializers/mime_types.rb +6 -0
- data/config/initializers/secret_token.rb +12 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/simple_form.rb +149 -0
- data/config/initializers/simple_form_bootstrap.rb +48 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/config.yml +23 -0
- data/config/locales/en.yml +183 -0
- data/config/locales/fi.yml +211 -0
- data/config/routes.rb +108 -0
- data/db/migrate/20131224171442_clerks.rb +15 -0
- data/db/migrate/20131226110406_suppliers.rb +9 -0
- data/db/migrate/20131226143612_categories.rb +18 -0
- data/db/migrate/20131226143747_items.rb +14 -0
- data/db/migrate/20131226144134_orders.rb +21 -0
- data/db/migrate/20131226144316_baskets.rb +12 -0
- data/db/migrate/20131226151151_purchases.rb +11 -0
- data/db/migrate/20131226151332_products.rb +27 -0
- data/db/schema.rb +138 -0
- data/db/seeds.rb +4 -0
- data/lib/assets/.keep +0 -0
- data/lib/office_clerk.rb +20 -0
- data/lib/office_clerk/shipping_method.rb +35 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/import.rake +33 -0
- data/lib/templates/haml/scaffold/_form.html.haml +8 -0
- data/office_clerk.gemspec +46 -0
- data/public/404.html +58 -0
- data/public/422.html +58 -0
- data/public/500.html +57 -0
- data/public/favicon.ico +0 -0
- data/public/humans.txt +20 -0
- data/public/robots.txt +5 -0
- data/spec/controllers/baskets_controller_spec.rb +112 -0
- data/spec/controllers/categories_controller_spec.rb +133 -0
- data/spec/controllers/clerks_controller_spec.rb +70 -0
- data/spec/controllers/orders_controller_spec.rb +105 -0
- data/spec/controllers/products_controller_spec.rb +138 -0
- data/spec/controllers/purchases_controller_spec.rb +123 -0
- data/spec/controllers/sessions_controller_spec.rb +18 -0
- data/spec/controllers/suppliers_controller_spec.rb +137 -0
- data/spec/factories/addresses.rb +11 -0
- data/spec/factories/baskets.rb +15 -0
- data/spec/factories/categories.rb +8 -0
- data/spec/factories/clerks.rb +15 -0
- data/spec/factories/items.rb +19 -0
- data/spec/factories/orders.rb +9 -0
- data/spec/factories/products.rb +10 -0
- data/spec/factories/purchases.rb +10 -0
- data/spec/factories/suppliers.rb +7 -0
- data/spec/features/baskets/buttons_spec.rb +35 -0
- data/spec/features/baskets/edit_spec.rb +50 -0
- data/spec/features/baskets/index_spec.rb +12 -0
- data/spec/features/baskets/search_spec.rb +33 -0
- data/spec/features/baskets/show_spec.rb +21 -0
- data/spec/features/categories_spec.rb +21 -0
- data/spec/features/clerks_spec.rb +21 -0
- data/spec/features/orders_spec.rb +14 -0
- data/spec/features/products/index_spec.rb +30 -0
- data/spec/features/products/new_spec.rb +20 -0
- data/spec/features/purchases_spec.rb +14 -0
- data/spec/features/shops_spec.rb +18 -0
- data/spec/features/suppliers_spec.rb +18 -0
- data/spec/models/baskets/inventory_spec.rb +34 -0
- data/spec/models/baskets/items_spec.rb +37 -0
- data/spec/models/baskets/products_spec.rb +31 -0
- data/spec/models/category_spec.rb +18 -0
- data/spec/models/clerk/email_spec.rb +69 -0
- data/spec/models/clerk/password_spec.rb +83 -0
- data/spec/models/item_spec.rb +33 -0
- data/spec/models/locale_spec.rb +17 -0
- data/spec/models/order_spec.rb +19 -0
- data/spec/models/product_spec.rb +29 -0
- data/spec/models/purchase_spec.rb +8 -0
- data/spec/models/supplier_spec.rb +8 -0
- data/spec/routing/baskets_routing_spec.rb +35 -0
- data/spec/routing/categories_routing_spec.rb +35 -0
- data/spec/routing/orders_routing_spec.rb +35 -0
- data/spec/routing/products_routing_spec.rb +35 -0
- data/spec/routing/purchases_routing_spec.rb +35 -0
- data/spec/routing/suppliers_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +74 -0
- data/spec/support/request_helper.rb +31 -0
- data/test/fixtures/baskets.yml +41993 -0
- data/test/fixtures/categories.yml +638 -0
- data/test/fixtures/clerks.yml +694 -0
- data/test/fixtures/items.yml +83651 -0
- data/test/fixtures/orders.yml +58918 -0
- data/test/fixtures/products.yml +110904 -0
- data/test/fixtures/purchases.yml +1755 -0
- data/test/fixtures/suppliers.yml +341 -0
- data/todo +8 -0
- metadata +607 -0
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SuppliersController do
|
4
|
+
|
5
|
+
# This should return the minimal set of attributes required to create a valid
|
6
|
+
# Supplier. As you add validations to Supplier, be sure to
|
7
|
+
# adjust the attributes here as well.
|
8
|
+
let(:supplier_attributes) do
|
9
|
+
{:supplier => attributes_for(:supplier)}
|
10
|
+
end
|
11
|
+
before :all do
|
12
|
+
create :admin unless Clerk.where(:admin => true).first
|
13
|
+
end
|
14
|
+
|
15
|
+
# This should return the minimal set of values that should be in the session
|
16
|
+
# in order to pass any filters (e.g. authentication) defined in
|
17
|
+
# SuppliersController. Be sure to keep this updated too.
|
18
|
+
let(:valid_session) { { :clerk_email => Clerk.where(:admin => true).first.email } }
|
19
|
+
|
20
|
+
describe "GET index" do
|
21
|
+
it "assigns all suppliers as @suppliers" do
|
22
|
+
before = Supplier.count
|
23
|
+
create :supplier
|
24
|
+
get :index, {}, valid_session
|
25
|
+
expect(Supplier.count).to be before + 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "GET show" do
|
30
|
+
it "assigns the requested supplier as @supplier" do
|
31
|
+
supplier = create :supplier
|
32
|
+
get :show, {:id => supplier.to_param}, valid_session
|
33
|
+
expect(assigns(:supplier)).to eq(supplier)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "GET new" do
|
38
|
+
it "assigns a new supplier as @supplier" do
|
39
|
+
get :new, {}, valid_session
|
40
|
+
expect(assigns(:supplier)).to be_kind_of(Supplier)
|
41
|
+
expect(assigns(:supplier)).to be_new_record
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "GET edit" do
|
46
|
+
it "assigns the requested supplier as @supplier" do
|
47
|
+
supplier = create :supplier
|
48
|
+
get :edit, {:id => supplier.to_param}, valid_session
|
49
|
+
expect(assigns(:supplier)).to eq(supplier)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "POST create" do
|
54
|
+
describe "with valid params" do
|
55
|
+
it "creates a new Supplier" do
|
56
|
+
expect {
|
57
|
+
post :create, supplier_attributes, valid_session
|
58
|
+
}.to change(Supplier, :count).by(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "assigns a newly created supplier as @supplier" do
|
62
|
+
post :create, supplier_attributes, valid_session
|
63
|
+
expect(assigns(:supplier)).to be_kind_of(Supplier)
|
64
|
+
expect(assigns(:supplier)).to be_persisted
|
65
|
+
end
|
66
|
+
|
67
|
+
it "redirects to the created supplier" do
|
68
|
+
post :create, supplier_attributes , valid_session
|
69
|
+
expect(response).to redirect_to(Supplier.unscoped.last)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "with invalid params" do
|
74
|
+
it "assigns a newly created but unsaved supplier as @supplier" do
|
75
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
76
|
+
allow_any_instance_of(Supplier).to receive(:save).and_return(false)
|
77
|
+
post :create, {:supplier => { :name => "" }}, valid_session
|
78
|
+
expect(assigns(:supplier)).to be_kind_of(Supplier)
|
79
|
+
expect(assigns(:supplier)).to be_new_record
|
80
|
+
end
|
81
|
+
|
82
|
+
it "re-renders the 'new' template" do
|
83
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
84
|
+
allow_any_instance_of(Supplier).to receive(:save).and_return(false)
|
85
|
+
post :create, {:supplier => { :name => "" }}, valid_session
|
86
|
+
expect(response).to render_template(:edit)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "PUT update" do
|
92
|
+
describe "with valid params" do
|
93
|
+
it "assigns the requested supplier as @supplier" do
|
94
|
+
supplier = create :supplier
|
95
|
+
attributes = supplier_attributes
|
96
|
+
attributes[:id] = supplier.id
|
97
|
+
put :update, attributes , valid_session
|
98
|
+
expect(response).to redirect_to(supplier)
|
99
|
+
expect(assigns(:supplier)).to eq(supplier)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "with invalid params" do
|
104
|
+
it "assigns the supplier as @supplier" do
|
105
|
+
supplier = create :supplier
|
106
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
107
|
+
allow_any_instance_of(Supplier).to receive(:save).and_return(false)
|
108
|
+
put :update, {:id => supplier.to_param, :supplier => { :name => "" }}, valid_session
|
109
|
+
expect(assigns(:supplier)).to eq(supplier)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "re-renders the 'edit' template" do
|
113
|
+
supplier = create :supplier
|
114
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
115
|
+
allow_any_instance_of(Supplier).to receive(:save).and_return(false)
|
116
|
+
put :update, {:id => supplier.to_param, :supplier => { :name => "" }}, valid_session
|
117
|
+
expect(response).to render_template(:edit)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "DELETE destroy" do
|
123
|
+
it "destroys the requested supplier" do
|
124
|
+
supplier = create :supplier
|
125
|
+
expect {
|
126
|
+
delete :destroy, {:id => supplier.to_param}, valid_session
|
127
|
+
}.to change(Supplier, :count).by(0)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "redirects to the suppliers list" do
|
131
|
+
supplier = create :supplier
|
132
|
+
delete :destroy, {:id => supplier.to_param}, valid_session
|
133
|
+
expect(response).to redirect_to(suppliers_path)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :basket do
|
5
|
+
factory :basket_with_item do
|
6
|
+
items {build_list :item , 1 }
|
7
|
+
end
|
8
|
+
factory :basket_2_items do
|
9
|
+
items {[FactoryGirl.create(:item2) , FactoryGirl.create(:item22)]}
|
10
|
+
end
|
11
|
+
factory :basket_3_items do
|
12
|
+
items {build_list :item_quantity , 3 }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :clerk do
|
5
|
+
sequence( :name) { |n| "Test Clerk#{n}" }
|
6
|
+
sequence( :email) { |n| "test#{n}@test.com" }
|
7
|
+
password 'password'
|
8
|
+
password_confirmation 'password'
|
9
|
+
# confirmed_at Time.now
|
10
|
+
factory :admin do
|
11
|
+
sequence( :email) { |n| "admin#{n}@test.com" }
|
12
|
+
admin true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :item do
|
5
|
+
product
|
6
|
+
quantity 1
|
7
|
+
price {product.price}
|
8
|
+
tax 10
|
9
|
+
sequence( :name) { |n| "product #{n}" }
|
10
|
+
factory :item_quantity do
|
11
|
+
quantity 1
|
12
|
+
end
|
13
|
+
factory :item2 do
|
14
|
+
factory :item22 do
|
15
|
+
quantity 2
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# lots of buttons appear and disapear, check that that all works
|
4
|
+
|
5
|
+
describe "Basket buttons" do
|
6
|
+
before(:each) do
|
7
|
+
sign_in
|
8
|
+
end
|
9
|
+
it "should have back and update buttons" do
|
10
|
+
visit_path new_basket_path
|
11
|
+
expect(page).to have_content I18n.t(:back)
|
12
|
+
find_button I18n.t("helpers.submit.update" , :model => I18n.t(:basket))
|
13
|
+
find_link I18n.t(:new) + ' ' + I18n.t(:basket)
|
14
|
+
find_link I18n.t(:destroy)
|
15
|
+
end
|
16
|
+
it "creates a new order" do
|
17
|
+
basket = create :basket_with_item
|
18
|
+
visit_path edit_basket_path basket
|
19
|
+
expect(page).not_to have_content I18n.t(:to_order)
|
20
|
+
click_link I18n.t(:checkout)
|
21
|
+
expect(page).to have_content I18n.t("invoice.header")
|
22
|
+
end
|
23
|
+
it "goes to purchase" do
|
24
|
+
basket = create :basket_2_items
|
25
|
+
visit_path edit_basket_path(basket)
|
26
|
+
click_on I18n.t(:make_purchase)
|
27
|
+
expect(find("h2")).to have_content(I18n.t(:purchase))
|
28
|
+
end
|
29
|
+
it "finds print link" do
|
30
|
+
basket = create :basket_2_items
|
31
|
+
visit_path edit_basket_path(basket)
|
32
|
+
expect(page).to have_content(I18n.t(:checkout))
|
33
|
+
expect(find(".print_order")).to have_content(I18n.t(:checkout))
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# lots of edit possibilities for price/quantity and items
|
4
|
+
|
5
|
+
describe "edit baskets" do
|
6
|
+
before :each do
|
7
|
+
sign_in
|
8
|
+
end
|
9
|
+
it "deletes item" do
|
10
|
+
basket = create :basket_with_item
|
11
|
+
visit_path edit_basket_path(basket)
|
12
|
+
name = basket.items.first.name
|
13
|
+
within(".table") { first('a', :text => I18n.t(:delete)).click }
|
14
|
+
expect{ find(".table").find(".name" , :minimum => 1) }.to raise_error
|
15
|
+
expect(page).not_to have_content(name )
|
16
|
+
end
|
17
|
+
it "add quantity to item" do
|
18
|
+
basket = create :basket_with_item
|
19
|
+
visit_path edit_basket_path(basket)
|
20
|
+
expect(find( "//table #basket_items_attributes_0_quantity").value).to eq basket.items.first.quantity.to_s
|
21
|
+
fill_in "basket_items_attributes_0_quantity" , :with => 2
|
22
|
+
find(".commit").click()
|
23
|
+
td = find("//table #basket_items_attributes_0_quantity")
|
24
|
+
expect(td.value).to eq("2")
|
25
|
+
end
|
26
|
+
it "change item price" do
|
27
|
+
basket = create :basket_with_item
|
28
|
+
visit_path edit_basket_path(basket)
|
29
|
+
expect(find( "//table #basket_items_attributes_0_price").value).to eq basket.items.first.price.to_s
|
30
|
+
fill_in "basket_items_attributes_0_price" , :with => 20
|
31
|
+
find(".commit").click()
|
32
|
+
td = find("//table #basket_items_attributes_0_price")
|
33
|
+
expect(td.value).to eq("20.0")
|
34
|
+
end
|
35
|
+
it "discounts basket" do
|
36
|
+
basket = create :basket_with_item
|
37
|
+
total = basket.total_price
|
38
|
+
visit discount_basket_path(basket , :discount => "10")
|
39
|
+
expect_basket_total total * 0.9
|
40
|
+
end
|
41
|
+
it "discounts item" do
|
42
|
+
basket = create :basket_2_items
|
43
|
+
total = basket.total_price - basket.items.first.price*0.1
|
44
|
+
visit discount_basket_path(basket , :discount => "10" , :item => basket.items.first)
|
45
|
+
expect_basket_total total
|
46
|
+
td = find("//table #basket_items_attributes_0_price")
|
47
|
+
expect(td.value).to eq((basket.items.first.price*0.9).round(2).to_s)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Basket search functionality" do
|
4
|
+
before(:each) do
|
5
|
+
sign_in
|
6
|
+
end
|
7
|
+
# this adds the product to the basket as it finds exactly one
|
8
|
+
it "adds product by entering ean" do
|
9
|
+
visit_path new_basket_path
|
10
|
+
p = create :product , :ean => "123456Z"
|
11
|
+
within ".ean_form" do
|
12
|
+
fill_in "ean" , :with => "#{p.ean}"
|
13
|
+
click_on I18n.t(:search)
|
14
|
+
end
|
15
|
+
td = find(".table").find(".name")
|
16
|
+
expect(td).to have_content(p.name)
|
17
|
+
end
|
18
|
+
# this adds the product, but because we enter the name, it has to search and show a second page
|
19
|
+
# where we hit add
|
20
|
+
it "adds product by entering name" do
|
21
|
+
basket = create :basket
|
22
|
+
visit_path edit_basket_path basket
|
23
|
+
p = create :product
|
24
|
+
within ".ean_form" do
|
25
|
+
fill_in "ean" , :with => "#{p.name}"
|
26
|
+
click_on I18n.t(:search)
|
27
|
+
end
|
28
|
+
find(:xpath, "//tr[contains(., '#{p.name}')]/td/a", :text => I18n.t(:add_to_basket)).click
|
29
|
+
td = find(".table").find(".name")
|
30
|
+
expect(td).to have_content(p.name) # added the product, yes!
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "edit basket screen, no editing" do
|
4
|
+
before :each do
|
5
|
+
sign_in
|
6
|
+
end
|
7
|
+
it "renders items" do
|
8
|
+
basket = create :basket_2_items
|
9
|
+
visit_path edit_basket_path(basket)
|
10
|
+
td = find(".table").first(".name")
|
11
|
+
expect(td).to have_content(basket.items.first.name)
|
12
|
+
end
|
13
|
+
it "renders 2 items with amount and total" do
|
14
|
+
basket = create :basket_2_items
|
15
|
+
visit_path edit_basket_path(basket)
|
16
|
+
td = find(".table").first(".name")
|
17
|
+
expect(td).to have_content(basket.items.first.name)
|
18
|
+
expect(find(".count").text).to include( I18n.t(:count))
|
19
|
+
expect_basket_total basket.total_price
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Category do
|
4
|
+
before(:each) do
|
5
|
+
sign_in
|
6
|
+
end
|
7
|
+
it "lists product groups" do
|
8
|
+
visit_path categories_path
|
9
|
+
end
|
10
|
+
it "creates a new group" do
|
11
|
+
visit_path new_category_path
|
12
|
+
end
|
13
|
+
it :edit do
|
14
|
+
category = create(:category)
|
15
|
+
visit_path edit_category_path(category)
|
16
|
+
end
|
17
|
+
it "shows" do
|
18
|
+
category = create(:category)
|
19
|
+
visit_path category_path(category)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Clerk do
|
4
|
+
before(:each) do
|
5
|
+
sign_in
|
6
|
+
end
|
7
|
+
it "lists product groups" do
|
8
|
+
visit_path clerks_path
|
9
|
+
end
|
10
|
+
it "creates a new group" do
|
11
|
+
visit_path new_clerk_path
|
12
|
+
end
|
13
|
+
it :edit do
|
14
|
+
clerk = create(:clerk)
|
15
|
+
visit_path edit_clerk_path(clerk)
|
16
|
+
end
|
17
|
+
it "shows" do
|
18
|
+
clerk = create(:clerk)
|
19
|
+
visit_path clerk_path(clerk)
|
20
|
+
end
|
21
|
+
end
|