office_clerk 0.0.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +14 -9
  3. data/README.md +1 -0
  4. data/app/assets/images/shop/ikkuna.jpg +0 -0
  5. data/app/assets/images/shop/violetti-lev.jpg +0 -0
  6. data/app/assets/javascripts/admin.js +2 -2
  7. data/app/assets/javascripts/shop.js +2 -1
  8. data/app/assets/stylesheets/shop-receipt.css.scss +1 -1
  9. data/app/assets/stylesheets/shop.css.scss +52 -31
  10. data/app/controllers/application_controller.rb +11 -5
  11. data/app/controllers/baskets_controller.rb +3 -27
  12. data/app/controllers/categories_controller.rb +2 -1
  13. data/app/controllers/clerks_controller.rb +3 -8
  14. data/app/controllers/manage_controller.rb +7 -0
  15. data/app/controllers/orders_controller.rb +16 -2
  16. data/app/controllers/products_controller.rb +20 -40
  17. data/app/controllers/purchases_controller.rb +2 -1
  18. data/app/controllers/sessions_controller.rb +15 -22
  19. data/app/helpers/admin_helper.rb +6 -8
  20. data/app/helpers/orders_helper.rb +6 -0
  21. data/app/models/basket.rb +1 -2
  22. data/app/models/category.rb +2 -0
  23. data/app/models/product.rb +43 -17
  24. data/app/models/purchase.rb +7 -6
  25. data/app/views/baskets/edit.html.haml +6 -8
  26. data/app/views/baskets/show.html.haml +1 -1
  27. data/app/views/clerks/edit.html.haml +1 -1
  28. data/app/views/layouts/_admin_menu.html.haml +2 -0
  29. data/app/views/layouts/admin.html.haml +9 -4
  30. data/app/views/layouts/shop.html.haml +8 -5
  31. data/app/views/manage/all.haml +3 -0
  32. data/app/views/orders/ship.haml +91 -0
  33. data/app/views/orders/show.html.haml +12 -4
  34. data/app/views/products/_head.haml +12 -0
  35. data/app/views/products/_line.html.haml +4 -8
  36. data/app/views/products/_online.html.haml +1 -1
  37. data/app/views/products/edit.html.haml +1 -7
  38. data/app/views/products/index.html.haml +4 -1
  39. data/app/views/products/show.html.haml +4 -18
  40. data/app/views/purchases/show.html.haml +3 -3
  41. data/app/views/sessions/{new.html.haml → sign_in.haml} +1 -1
  42. data/app/views/sessions/{new_clerk.html.haml → sign_up.haml} +2 -2
  43. data/app/views/shop/checkout.haml +3 -3
  44. data/app/views/shop/liikkeemme.html.haml +59 -0
  45. data/app/views/shop/order.haml +20 -15
  46. data/app/views/shop/product_list.html.haml +16 -13
  47. data/app/views/shop/tilaushistoria.html.haml +221 -0
  48. data/app/views/shop/toimitusehdot.html.haml +99 -0
  49. data/config/locales/config.yml +2 -1
  50. data/config/locales/en.yml +4 -5
  51. data/config/locales/fi.yml +13 -6
  52. data/config/routes.rb +11 -12
  53. data/lib/office_clerk/shipping_method.rb +1 -1
  54. data/office_clerk.gemspec +1 -1
  55. data/spec/controllers/products_controller_spec.rb +3 -3
  56. data/spec/controllers/sessions_controller_spec.rb +11 -3
  57. data/spec/factories/orders.rb +7 -1
  58. data/spec/factories/products.rb +16 -0
  59. data/spec/factories/purchases.rb +8 -4
  60. data/spec/features/baskets/buttons_spec.rb +1 -2
  61. data/spec/features/baskets/index_spec.rb +10 -4
  62. data/spec/features/clerks_spec.rb +22 -6
  63. data/spec/features/orders_spec.rb +18 -0
  64. data/spec/features/products/edit_spec.rb +32 -0
  65. data/spec/features/products/header_spec.rb +48 -0
  66. data/spec/features/products/index_spec.rb +4 -18
  67. data/spec/features/purchases_spec.rb +19 -0
  68. data/spec/features/sessions_spec.rb +58 -0
  69. data/spec/features/shop_spec.rb +63 -0
  70. data/spec/features/suppliers_spec.rb +2 -0
  71. data/spec/models/product_spec.rb +54 -8
  72. data/spec/models/purchase_spec.rb +20 -1
  73. data/spec/models/shipping_spec.rb +25 -0
  74. metadata +22 -9
  75. data/app/views/products/_name.html.haml +0 -4
  76. data/spec/features/products/new_spec.rb +0 -20
  77. data/spec/features/shops_spec.rb +0 -18
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe ShopController do
4
+ it "lists shows root" do
5
+ prod = create :shop_product
6
+ visit_path root_path
7
+ end
8
+ it "shows a product" do
9
+ prod = create :shop_product
10
+ visit_path shop_product_path(prod.link)
11
+ end
12
+ it "redirects for non product" do
13
+ prod = create :shop_product
14
+ visit shop_product_path("no_such_thing")
15
+ ensure_path shop_group_path("no_such_thing")
16
+ end
17
+ it "shows a group" do
18
+ prod = create :shop_product
19
+ visit_path shop_group_path(prod.category.link)
20
+ end
21
+ it "adds a product" do
22
+ prod = create :shop_product
23
+ visit_path shop_product_path(prod.link)
24
+ click_button "add-to-cart-button"
25
+ ensure_path shop_group_path(prod.category.link)
26
+ end
27
+ it "adds a product" do
28
+ prod = create :shop_product
29
+ visit_path shop_product_path(prod.link)
30
+ click_button "add-to-cart-button"
31
+ ensure_path shop_group_path(prod.category.link)
32
+ end
33
+ it "adds a product to checkout" do
34
+ prod = create :shop_product
35
+ visit_path shop_product_path(prod.link)
36
+ click_button "add-to-cart-button"
37
+ visit_path shop_checkout_path
38
+ end
39
+ it "fails checkout without email" do
40
+ prod = create :shop_product
41
+ visit_path shop_product_path(prod.link)
42
+ click_button "add-to-cart-button"
43
+ visit_path shop_checkout_path
44
+ click_button "make_order"
45
+ expect(page).to have_content("Error")
46
+ ensure_path shop_checkout_path
47
+ end
48
+ it "checks out with email" do
49
+ prod = create :shop_product
50
+ visit_path shop_product_path(prod.link)
51
+ click_button "add-to-cart-button"
52
+ visit_path shop_checkout_path
53
+ fill_in :order_email , :with => "some@valid.it"
54
+ click_button "make_order"
55
+ ensure_path shop_order_path(Order.last.id)
56
+ end
57
+ it "shows a page" do
58
+ visit_path shop_page_path :tuotteista
59
+ end
60
+ it "renders welcome page" do
61
+ visit_path shop_welcome_path
62
+ end
63
+ end
@@ -5,6 +5,8 @@ describe "Suppliers" do
5
5
  sign_in
6
6
  end
7
7
  it "lists suppliers" do
8
+ create(:supplier)
9
+ create(:supplier)
8
10
  visit_path suppliers_path
9
11
  end
10
12
  it "shows" do
@@ -5,25 +5,71 @@ describe Product do
5
5
  pro = build :product
6
6
  expect(pro.save).to be true
7
7
  end
8
- it "defaults work" do
8
+ it "default factory produces values" do
9
9
  pro = create :product
10
10
  expect(pro.tax).not_to be nil
11
11
  expect(pro.link).not_to be nil
12
12
  expect(pro.cost).not_to be nil
13
13
  expect(pro.ean).not_to be nil
14
14
  expect(pro.scode).not_to be nil
15
+ expect(pro.inventory). to be > 0
16
+ expect(pro.type).to be :product
15
17
  end
18
+
19
+ it "default factory product and not items" do
20
+ pro = create :product
21
+ expect(pro.line?).to be false
22
+ expect(pro.product_item?).to be false
23
+ end
24
+
25
+ it "factory creates product lines ok" do
26
+ line = create :product_line
27
+ expect(line.line?).to be true
28
+ expect(line.type).to be :product_line
29
+ expect(line.products.first.line?).to be false
30
+ expect(line.products.first.type).to be :product_item
31
+ expect(line.products.first.product_item?).to be true
32
+ end
33
+
34
+ it "validates a name" do
35
+ pro = Product.new
36
+ expect(pro.save).to be false
37
+ end
38
+
16
39
  it "validates a name" do
17
40
  pro = Product.new
18
41
  expect(pro.save).to be false
19
42
  end
20
- it "deletes" do
43
+
44
+ it "deletes if inventory is 0" do
21
45
  pro = create :product
22
- on = Product.find pro.id
23
- expect(on.id).to be pro.id
24
- on.delete
25
- expect(on.save).to be true
26
- on = Product.where(:id => pro.id).first
27
- expect(on).to be nil
46
+ pro.inventory = 0
47
+ pro.delete
48
+ expect(pro.save).to be true
49
+ expect(Product.where(:id => pro.id).first).to be nil
50
+ expect(Product.unscoped.find(pro.id)).not_to be nil
51
+ end
52
+
53
+ it "does not delete if there is inventory" do
54
+ pro = create :product
55
+ pro.delete
56
+ expect(pro.save).to be false
57
+ end
58
+
59
+ it "removes ean if make line" do
60
+ line = create :product , :ean => "1234"
61
+ item = line.new_product_item
62
+ item.name = "my unique name"
63
+ expect(item.save).to be true
64
+ expect(item.link).to be_blank
65
+ expect(line.reload.ean).to be_blank
66
+ end
67
+ it "removes link for items" do
68
+ line = create :product_line
69
+ item = line.products.first
70
+ expect(item.link).to be_blank
71
+ item.link = item.name
72
+ expect(item.save).to be true
73
+ expect(item.link).to be_blank
28
74
  end
29
75
  end
@@ -2,7 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe Purchase do
4
4
  it "factory is ok" do
5
- p = Purchase.new attributes_for :purchase
5
+ p = build :purchase
6
6
  expect(p.save).to be true
7
7
  end
8
+ it "orders ok" do
9
+ p = create :purchase
10
+ expect(p.order!).to be true
11
+ end
12
+ it "receives ok" do
13
+ p = create :purchase
14
+ expect(p.receive!).to be p.basket.items.first.quantity
15
+ end
16
+ it "doesn't receives twice" do
17
+ p = create :purchase
18
+ expect(p.receive!).to be p.basket.items.first.quantity
19
+ expect{p.receive!}.to raise_error RuntimeError
20
+ end
21
+ it "inventories ok" do
22
+ p = create :purchase
23
+ item = p.basket.items.first
24
+ diff = item.quantity - item.product.inventory
25
+ expect(p.inventory!).to be diff
26
+ end
8
27
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ShippingMethod" do
4
+ it "has at least one method with data" do
5
+ methods = OfficeClerk::ShippingMethod.all
6
+ expect(methods).not_to be_empty
7
+ expect(methods.values.first.data).to be_a(Hash)
8
+ end
9
+ it "provides pickup" do
10
+ method = OfficeClerk::ShippingMethod.all[:pickup]
11
+ expect(method).not_to be nil
12
+ expect(method.name).not_to be nil
13
+ expect(method.type).not_to be nil
14
+ end
15
+ it "Pickup is free" do
16
+ method = OfficeClerk::ShippingMethod.all[:pickup]
17
+ basket = create :basket
18
+ expect(method.price_for(basket)).to eq 0.0
19
+ end
20
+ it "creates Pickup with data" do
21
+ method = OfficeClerk::Pickup.new(:name => "me" , :type => :pick2)
22
+ expect(method.name).to eq "me"
23
+ expect(method.type).to eq :pick2
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: office_clerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torsten Rüger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -304,6 +304,7 @@ files:
304
304
  - app/assets/images/shop/header.gif
305
305
  - app/assets/images/shop/header.jpg
306
306
  - app/assets/images/shop/header.png
307
+ - app/assets/images/shop/ikkuna.jpg
307
308
  - app/assets/images/shop/kansi.jpg
308
309
  - app/assets/images/shop/kansi.png
309
310
  - app/assets/images/shop/logo.png
@@ -339,6 +340,7 @@ files:
339
340
  - app/controllers/baskets_controller.rb
340
341
  - app/controllers/categories_controller.rb
341
342
  - app/controllers/clerks_controller.rb
343
+ - app/controllers/manage_controller.rb
342
344
  - app/controllers/orders_controller.rb
343
345
  - app/controllers/products_controller.rb
344
346
  - app/controllers/purchases_controller.rb
@@ -382,11 +384,13 @@ files:
382
384
  - app/views/layouts/_messages.html.haml
383
385
  - app/views/layouts/admin.html.haml
384
386
  - app/views/layouts/shop.html.haml
387
+ - app/views/manage/all.haml
385
388
  - app/views/orders/edit.html.haml
386
389
  - app/views/orders/index.html.haml
390
+ - app/views/orders/ship.haml
387
391
  - app/views/orders/show.html.haml
392
+ - app/views/products/_head.haml
388
393
  - app/views/products/_line.html.haml
389
- - app/views/products/_name.html.haml
390
394
  - app/views/products/_online.html.haml
391
395
  - app/views/products/_triple.html.haml
392
396
  - app/views/products/edit.html.haml
@@ -395,19 +399,22 @@ files:
395
399
  - app/views/purchases/edit.html.haml
396
400
  - app/views/purchases/index.html.haml
397
401
  - app/views/purchases/show.html.haml
398
- - app/views/sessions/new.html.haml
399
- - app/views/sessions/new_clerk.html.haml
402
+ - app/views/sessions/sign_in.haml
403
+ - app/views/sessions/sign_up.haml
400
404
  - app/views/shop/_groups.html.haml
401
405
  - app/views/shop/_menu.html.haml
402
406
  - app/views/shop/_sub.html.haml
403
407
  - app/views/shop/checkout.haml
404
408
  - app/views/shop/group.html.haml
409
+ - app/views/shop/liikkeemme.html.haml
405
410
  - app/views/shop/main_group.html.haml
406
411
  - app/views/shop/order.haml
407
412
  - app/views/shop/product.html.haml
408
413
  - app/views/shop/product_list.html.haml
409
414
  - app/views/shop/saved_search.html
410
415
  - app/views/shop/sub_group.html.haml
416
+ - app/views/shop/tilaushistoria.html.haml
417
+ - app/views/shop/toimitusehdot.html.haml
411
418
  - app/views/shop/tuotteista.html.haml
412
419
  - app/views/shop/welcome.html.haml
413
420
  - app/views/suppliers/edit.html.haml
@@ -495,10 +502,12 @@ files:
495
502
  - spec/features/categories_spec.rb
496
503
  - spec/features/clerks_spec.rb
497
504
  - spec/features/orders_spec.rb
505
+ - spec/features/products/edit_spec.rb
506
+ - spec/features/products/header_spec.rb
498
507
  - spec/features/products/index_spec.rb
499
- - spec/features/products/new_spec.rb
500
508
  - spec/features/purchases_spec.rb
501
- - spec/features/shops_spec.rb
509
+ - spec/features/sessions_spec.rb
510
+ - spec/features/shop_spec.rb
502
511
  - spec/features/suppliers_spec.rb
503
512
  - spec/models/baskets/inventory_spec.rb
504
513
  - spec/models/baskets/items_spec.rb
@@ -511,6 +520,7 @@ files:
511
520
  - spec/models/order_spec.rb
512
521
  - spec/models/product_spec.rb
513
522
  - spec/models/purchase_spec.rb
523
+ - spec/models/shipping_spec.rb
514
524
  - spec/models/supplier_spec.rb
515
525
  - spec/routing/baskets_routing_spec.rb
516
526
  - spec/routing/categories_routing_spec.rb
@@ -580,10 +590,12 @@ test_files:
580
590
  - spec/features/categories_spec.rb
581
591
  - spec/features/clerks_spec.rb
582
592
  - spec/features/orders_spec.rb
593
+ - spec/features/products/edit_spec.rb
594
+ - spec/features/products/header_spec.rb
583
595
  - spec/features/products/index_spec.rb
584
- - spec/features/products/new_spec.rb
585
596
  - spec/features/purchases_spec.rb
586
- - spec/features/shops_spec.rb
597
+ - spec/features/sessions_spec.rb
598
+ - spec/features/shop_spec.rb
587
599
  - spec/features/suppliers_spec.rb
588
600
  - spec/models/baskets/inventory_spec.rb
589
601
  - spec/models/baskets/items_spec.rb
@@ -596,6 +608,7 @@ test_files:
596
608
  - spec/models/order_spec.rb
597
609
  - spec/models/product_spec.rb
598
610
  - spec/models/purchase_spec.rb
611
+ - spec/models/shipping_spec.rb
599
612
  - spec/models/supplier_spec.rb
600
613
  - spec/routing/baskets_routing_spec.rb
601
614
  - spec/routing/categories_routing_spec.rb
@@ -1,4 +0,0 @@
1
- %h2
2
- = @product.name
3
- %small
4
- = @product.online ? "online" : "not online"
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "new product" do
4
- before :each do
5
- sign_in
6
- visit_path new_product_path
7
- expect(page).to have_content I18n.t(:product)
8
- fill_in "product[name]", :with => 'product 12'
9
- fill_in "product[price]", :with => '12'
10
- end
11
- it "submits ok" do
12
- click_button( I18n.t(:create))
13
- expect(page).to have_content I18n.t(:create_success)
14
- end
15
- scenario "redirects ok" do
16
- fill_in "product_price", :with => ''
17
- click_button( I18n.t(:create))
18
- expect(page).to have_content I18n.t("errors.messages.not_a_number")
19
- end
20
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Shops" do
4
- describe "GET /prod" do
5
- it "get something" do
6
- p = create :product , :online => true
7
- g = create :category
8
- visit_path shop_product_path(:link => p.link)
9
- expect(status_code).to be(200)
10
- end
11
-
12
- it "redirects for wrong input" do
13
- visit shop_product_path(:link => "nonexistant")
14
- expect(page.current_path).to include "group"
15
- expect(status_code).to be(200)
16
- end
17
- end
18
- end