office_clerk 0.7 → 0.8

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +11 -0
  3. data/Gemfile.lock +8 -8
  4. data/Guardfile +1 -0
  5. data/README.md +2 -2
  6. data/app/controllers/baskets_controller.rb +1 -1
  7. data/app/controllers/office_controller.rb +3 -43
  8. data/app/controllers/orders_controller.rb +1 -5
  9. data/app/controllers/sessions_controller.rb +14 -7
  10. data/app/helpers/admin_helper.rb +0 -1
  11. data/app/helpers/categories_helper.rb +11 -0
  12. data/app/helpers/office_helper.rb +43 -0
  13. data/app/helpers/orders_helper.rb +4 -0
  14. data/app/mailers/order_mailer.rb +14 -4
  15. data/app/models/clerk.rb +9 -2
  16. data/app/models/order.rb +4 -0
  17. data/app/views/baskets/edit.html.haml +2 -2
  18. data/app/views/categories/show.html.haml +1 -1
  19. data/app/views/layouts/_header_extra.haml +6 -5
  20. data/app/views/layouts/office_clerk.haml +8 -8
  21. data/app/views/order_mailer/_order.text.erb +24 -0
  22. data/app/views/order_mailer/cancel.text.erb +4 -18
  23. data/app/views/order_mailer/confirm.text.erb +7 -20
  24. data/app/views/order_mailer/paid.text.erb +3 -16
  25. data/app/views/order_mailer/shipped.text.erb +7 -13
  26. data/app/views/orders/index.html.haml +3 -3
  27. data/app/views/products/_preview_box.haml +11 -0
  28. data/app/views/products/show.html.haml +1 -1
  29. data/app/views/sessions/sign_in.haml +9 -9
  30. data/app/views/sessions/sign_up.haml +4 -16
  31. data/bin/rspec +4 -0
  32. data/bin/spring +1 -1
  33. data/config/locales/en.yml +3 -0
  34. data/config/locales/fi.yml +3 -0
  35. data/config/routes.rb +1 -15
  36. data/lib/office_clerk/engine.rb +10 -4
  37. data/lib/office_clerk/shipping_method.rb +5 -0
  38. data/lib/office_clerk/version.rb +1 -1
  39. data/office_clerk.gemspec +6 -6
  40. data/spec/controllers/sessions_controller_spec.rb +1 -1
  41. data/spec/features/orders_spec.rb +5 -0
  42. data/spec/features/sessions_spec.rb +3 -4
  43. data/spec/mailers/order_mailer_spec.rb +57 -14
  44. data/spec/models/clerk/email_spec.rb +4 -3
  45. data/spec/models/clerk/misc_spec.rb +19 -0
  46. data/spec/support/product_helper.rb +8 -0
  47. data/test_app/config/environments/development.rb +1 -1
  48. data/test_app/config/environments/test.rb +1 -1
  49. data/test_app/config/locales/config.yml +2 -0
  50. data/test_app/config/routes.rb +4 -1
  51. metadata +33 -21
  52. data/app/controllers/shop_controller.rb +0 -91
  53. data/app/helpers/shop_helper.rb +0 -18
  54. data/app/views/layouts/_google.haml +0 -8
  55. data/app/views/layouts/sales_clerk.haml +0 -10
  56. data/app/views/shop/_product_box.haml +0 -13
@@ -13,7 +13,7 @@ describe SessionsController do
13
13
  clerk = create :clerk
14
14
  email = Clerk.where(:admin=>false).first.email
15
15
  post :create , :email => email
16
- expect(response).to redirect_to(root_path)
16
+ expect(response).to redirect_to(Rails.application.routes.url_helpers.root_path)
17
17
  expect(session['clerk_email']).to eq email
18
18
  end
19
19
  it "create action should redirect to baskets for admin if authentication is valid" do
@@ -29,4 +29,9 @@ describe "Orders" do
29
29
  find(".ship_now").click
30
30
  # expect(order.basket.items.first.product.inventory).to be order.basket.items.first.quantity
31
31
  end
32
+ it "filters by email" do
33
+ order_ab :email =>[ "torsten@villataika.fi", "raisa@villataika.fi"]
34
+ fill_in("q[email_cont]" , :with => "torsten")
35
+ expect(order_count).to eq 1
36
+ end
32
37
  end
@@ -11,7 +11,7 @@ describe "Sessions" do
11
11
  fill_in(:email , :with => user.email)
12
12
  fill_in(:password , :with => "password")
13
13
  click_button( I18n.t(:sign_in))
14
- ensure_path root_path
14
+ ensure_path Rails.application.routes.url_helpers.root_path
15
15
  end
16
16
  it "goes to baskets for admins" do
17
17
  user = create :admin
@@ -37,7 +37,7 @@ describe "Sessions" do
37
37
  it "signs out" do
38
38
  sign_in
39
39
  visit sign_out_path
40
- ensure_path root_path
40
+ ensure_path Rails.application.routes.url_helpers.root_path
41
41
  end
42
42
  it "signs up needs confirmation" do
43
43
  visit_path sign_up_path
@@ -45,7 +45,6 @@ describe "Sessions" do
45
45
  fill_in(:clerk_password , :with => "password")
46
46
  find(".submit").click
47
47
  ensure_path sign_up_path
48
- expect(page).to have_content("invalid")
49
48
  end
50
49
  it "signs up" do
51
50
  visit_path sign_up_path
@@ -53,6 +52,6 @@ describe "Sessions" do
53
52
  fill_in(:clerk_password , :with => "password")
54
53
  fill_in(:clerk_password_confirmation , :with => "password")
55
54
  find(".submit").click
56
- ensure_path root_path
55
+ ensure_path main_app.root_path
57
56
  end
58
57
  end
@@ -1,24 +1,67 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe OrderMailer, :type => :mailer do
4
- describe 'confirm' do
5
- let(:order) { create :order }
4
+ let(:order) { create :order }
5
+
6
+ shared_examples_for "an order mail" do
7
+ describe "mail basics" do
8
+ it 'renders the subject' do
9
+ expect(mail.subject.to_s).to include( I18n.t(:order))
10
+ expect(mail.subject.to_s).to include( order.number)
11
+ expect(mail.subject.to_s).not_to include( "missing")
12
+ end
13
+ it 'renders the receiver email' do
14
+ expect(mail.to).to eq([order.email])
15
+ end
16
+ end
17
+ describe "order details" do
18
+ it "includes the total price" do
19
+ expect(mail.body).to include(order.total_price.to_s)
20
+ end
21
+ it "includes the product name" do
22
+ expect(mail.body).to include(order.basket.items.first.product.name)
23
+ expect(mail.body).not_to include( "missing")
24
+ end
25
+ end
26
+ end
27
+
28
+ describe 'confirm mail' do
6
29
  let(:mail) { OrderMailer.confirm(order) }
7
-
8
- it 'renders the subject' do
9
- expect(mail.subject.to_s).to include('Order')
30
+ it_should_behave_like "an order mail" do
10
31
  end
11
-
12
- it 'renders the receiver email' do
13
- expect(mail.to).to eql([order.email])
32
+ it "should include ordered" do
33
+ expect(mail.body).to include("vastaanotettu")
14
34
  end
15
-
16
- it 'renders the sender email' do
17
- expect(mail.from).to eql(["me@here.now"])
35
+ end
36
+
37
+ describe 'cancel mail' do
38
+ let(:mail) { OrderMailer.cancel(order) }
39
+ it_should_behave_like "an order mail" do
18
40
  end
19
-
20
- it "includes the total price" do
21
- expect(mail.body).to include(order.total_price.to_s)
41
+ it "should include cancled" do
42
+ expect(mail.body).to include("peruttu")
22
43
  end
23
44
  end
45
+
46
+ describe 'paid mail' do
47
+ let(:mail) { OrderMailer.paid(order) }
48
+ it_should_behave_like "an order mail" do
49
+ end
50
+ it "should include paid" do
51
+ expect(mail.body).to include("kirjattu maksetuksi")
52
+ end
53
+ end
54
+
55
+ describe 'shipped mail' do
56
+ let(:mail) do
57
+ order.pay_now!
58
+ OrderMailer.shipped(order)
59
+ end
60
+ it_should_behave_like "an order mail" do
61
+ end
62
+ it "should include paid" do
63
+ expect(mail.body).to include("postitettu")
64
+ end
65
+ end
66
+
24
67
  end
@@ -62,8 +62,9 @@ describe Clerk do
62
62
  end
63
63
 
64
64
  # would be nice, just doesn't work yet
65
- # it "should not allow odd characters in name" do
66
- # create(:clerk, :name => 'odd ^&(@)').should have(1).error_on(:name)
67
- # end
65
+ #it "should not allow odd characters in name" do
66
+ # clerk = create(:clerk, :name => 'odd ^&(@)')
67
+ #expect(clerk.errors[:name].size).to eq 1
68
+ #end
68
69
 
69
70
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clerk do
4
+
5
+ it "should return last order address with empty for no order" do
6
+ clerk = create(:clerk)
7
+ expect(clerk.last_address).to be {}
8
+ end
9
+
10
+ it "should return last order address with last order address" do
11
+ order = create :order
12
+ order.name = "clerk name"
13
+ order.city = "my city"
14
+ order.save!
15
+ clerk = create(:clerk , :email => order.email)
16
+ expect(clerk.last_address).to eq order.address
17
+ end
18
+
19
+ end
@@ -17,7 +17,15 @@ module ProductHelper
17
17
  create_ab :category , hash
18
18
  visit categories_path
19
19
  end
20
+ def order_ab hash
21
+ create_ab :order , hash
22
+ visit orders_path
23
+ end
20
24
  alias :category_count :product_count
25
+ def order_count
26
+ click_button(:filter)
27
+ all(".number").count
28
+ end
21
29
  end
22
30
 
23
31
  RSpec.configure do |config|
@@ -28,5 +28,5 @@ TestApp::Application.configure do
28
28
  config.assets.debug = true
29
29
 
30
30
  # Raises error for missing translations
31
- # config.action_view.raise_on_missing_translations = true
31
+ config.action_view.raise_on_missing_translations = true
32
32
  end
@@ -35,5 +35,5 @@ TestApp::Application.configure do
35
35
  config.active_support.deprecation = :stderr
36
36
 
37
37
  # Raises error for missing translations
38
- # config.action_view.raise_on_missing_translations = true
38
+ config.action_view.raise_on_missing_translations = true
39
39
  end
@@ -0,0 +1,2 @@
1
+ config:
2
+ mail_from: me@here.now
@@ -1,4 +1,7 @@
1
1
  TestApp::Application.routes.draw do
2
- root :to => 'sessions#sign_in'
2
+
3
+ get '/group/:link' , :to => 'office#group', :as => :shop_group
3
4
  mount OfficeClerk::Engine => "/"
5
+ root :to => 'sessions#sign_in' , :as => :root
6
+
4
7
  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.7'
4
+ version: '0.8'
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-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.1'
20
- - - "<="
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.2'
23
23
  type: :runtime
@@ -27,13 +27,16 @@ dependencies:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '4.1'
30
- - - "<="
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: ransack
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
37
40
  - - ">="
38
41
  - !ruby/object:Gem::Version
39
42
  version: 1.5.1
@@ -41,6 +44,9 @@ dependencies:
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.5'
44
50
  - - ">="
45
51
  - !ruby/object:Gem::Version
46
52
  version: 1.5.1
@@ -48,16 +54,22 @@ dependencies:
48
54
  name: valid_email
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.0'
51
60
  - - ">="
52
61
  - !ruby/object:Gem::Version
53
- version: '0'
62
+ version: 0.0.10
54
63
  type: :runtime
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
66
  requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.0'
58
70
  - - ">="
59
71
  - !ruby/object:Gem::Version
60
- version: '0'
72
+ version: 0.0.10
61
73
  - !ruby/object:Gem::Dependency
62
74
  name: sass-rails
63
75
  requirement: !ruby/object:Gem::Requirement
@@ -104,30 +116,30 @@ dependencies:
104
116
  name: coffee-rails
105
117
  requirement: !ruby/object:Gem::Requirement
106
118
  requirements:
107
- - - ">="
119
+ - - "~>"
108
120
  - !ruby/object:Gem::Version
109
- version: '0'
121
+ version: '4.0'
110
122
  type: :runtime
111
123
  prerelease: false
112
124
  version_requirements: !ruby/object:Gem::Requirement
113
125
  requirements:
114
- - - ">="
126
+ - - "~>"
115
127
  - !ruby/object:Gem::Version
116
- version: '0'
128
+ version: '4.0'
117
129
  - !ruby/object:Gem::Dependency
118
130
  name: gon
119
131
  requirement: !ruby/object:Gem::Requirement
120
132
  requirements:
121
- - - ">="
133
+ - - "~>"
122
134
  - !ruby/object:Gem::Version
123
- version: '0'
135
+ version: '5.2'
124
136
  type: :runtime
125
137
  prerelease: false
126
138
  version_requirements: !ruby/object:Gem::Requirement
127
139
  requirements:
128
- - - ">="
140
+ - - "~>"
129
141
  - !ruby/object:Gem::Version
130
- version: '0'
142
+ version: '5.2'
131
143
  - !ruby/object:Gem::Dependency
132
144
  name: jquery-ui-rails
133
145
  requirement: !ruby/object:Gem::Requirement
@@ -160,14 +172,14 @@ dependencies:
160
172
  name: best_in_place
161
173
  requirement: !ruby/object:Gem::Requirement
162
174
  requirements:
163
- - - ">="
175
+ - - "~>"
164
176
  - !ruby/object:Gem::Version
165
177
  version: '0'
166
178
  type: :runtime
167
179
  prerelease: false
168
180
  version_requirements: !ruby/object:Gem::Requirement
169
181
  requirements:
170
- - - ">="
182
+ - - "~>"
171
183
  - !ruby/object:Gem::Version
172
184
  version: '0'
173
185
  - !ruby/object:Gem::Dependency
@@ -305,7 +317,6 @@ files:
305
317
  - app/controllers/products_controller.rb
306
318
  - app/controllers/purchases_controller.rb
307
319
  - app/controllers/sessions_controller.rb
308
- - app/controllers/shop_controller.rb
309
320
  - app/controllers/suppliers_controller.rb
310
321
  - app/helpers/admin_helper.rb
311
322
  - app/helpers/baskets_helper.rb
@@ -314,7 +325,6 @@ files:
314
325
  - app/helpers/orders_helper.rb
315
326
  - app/helpers/products_helper.rb
316
327
  - app/helpers/purchases_helper.rb
317
- - app/helpers/shop_helper.rb
318
328
  - app/helpers/suppliers_helper.rb
319
329
  - app/mailers/order_mailer.rb
320
330
  - app/models/basket.rb
@@ -340,14 +350,13 @@ files:
340
350
  - app/views/clerks/index.html.haml
341
351
  - app/views/clerks/show.html.haml
342
352
  - app/views/layouts/_admin_menu.html.haml
343
- - app/views/layouts/_google.haml
344
353
  - app/views/layouts/_header_extra.haml
345
354
  - app/views/layouts/_messages.html.haml
346
355
  - app/views/layouts/office_clerk.csv.erb
347
356
  - app/views/layouts/office_clerk.haml
348
- - app/views/layouts/sales_clerk.haml
349
357
  - app/views/manage/_hash.haml
350
358
  - app/views/manage/all.haml
359
+ - app/views/order_mailer/_order.text.erb
351
360
  - app/views/order_mailer/cancel.text.erb
352
361
  - app/views/order_mailer/confirm.text.erb
353
362
  - app/views/order_mailer/paid.text.erb
@@ -360,6 +369,7 @@ files:
360
369
  - app/views/products/_head.haml
361
370
  - app/views/products/_line.html.haml
362
371
  - app/views/products/_online.html.haml
372
+ - app/views/products/_preview_box.haml
363
373
  - app/views/products/_triple.html.haml
364
374
  - app/views/products/edit.html.haml
365
375
  - app/views/products/index.html.haml
@@ -369,7 +379,6 @@ files:
369
379
  - app/views/purchases/show.html.haml
370
380
  - app/views/sessions/sign_in.haml
371
381
  - app/views/sessions/sign_up.haml
372
- - app/views/shop/_product_box.haml
373
382
  - app/views/suppliers/edit.html.haml
374
383
  - app/views/suppliers/index.html.haml
375
384
  - app/views/suppliers/show.html.haml
@@ -458,6 +467,7 @@ files:
458
467
  - spec/models/baskets/taxes_spec.rb
459
468
  - spec/models/category_spec.rb
460
469
  - spec/models/clerk/email_spec.rb
470
+ - spec/models/clerk/misc_spec.rb
461
471
  - spec/models/clerk/password_spec.rb
462
472
  - spec/models/item_spec.rb
463
473
  - spec/models/locale_spec.rb
@@ -505,6 +515,7 @@ files:
505
515
  - test_app/config/initializers/secret_token.rb
506
516
  - test_app/config/initializers/session_store.rb
507
517
  - test_app/config/initializers/wrap_parameters.rb
518
+ - test_app/config/locales/config.yml
508
519
  - test_app/config/locales/en.yml
509
520
  - test_app/config/routes.rb
510
521
  - test_app/db/migrate/20141114205525_clerks.office.rb
@@ -588,6 +599,7 @@ test_files:
588
599
  - spec/models/baskets/taxes_spec.rb
589
600
  - spec/models/category_spec.rb
590
601
  - spec/models/clerk/email_spec.rb
602
+ - spec/models/clerk/misc_spec.rb
591
603
  - spec/models/clerk/password_spec.rb
592
604
  - spec/models/item_spec.rb
593
605
  - spec/models/locale_spec.rb
@@ -1,91 +0,0 @@
1
- class ShopController < OfficeController
2
- before_action :load
3
-
4
- layout "sales_clerk"
5
-
6
- def welcome
7
- @groups = Category.online.where( :category_id => nil )
8
- render :layout => false
9
- end
10
-
11
- def product
12
- @product = Product.shop_products.where(:link => params[:link]).first
13
- unless @product
14
- redirect_to :action => :group
15
- return
16
- end
17
- @group = @product.category
18
- #error handling
19
- # @group = Category.find(@product.category_id)
20
- end
21
-
22
- # the checkout page creates an order upon completion. So before a checkout the basket is attached to the session
23
- # and by filling out all data an order is created with the basket and the session zeroed
24
- def checkout
25
- @order = Order.new :ordered_on => Date.today
26
- @order.basket = current_basket
27
- if(request.get?)
28
- @order.email = current_clerk.email if current_clerk
29
- @order.shipment_type = "pickup" # price is 0 automatically
30
- else
31
- order_ps = params.require(:order).permit( :email,:name , :street , :city , :phone , :shipment_type )
32
- if @order.update_attributes(order_ps)
33
- new_basket
34
- OrderMailer.confirm(@order).deliver
35
- redirect_to shop_order_path(@order), :notice => t(:thanks)
36
- return
37
- end
38
- end
39
- end
40
-
41
- def order
42
- if( params[:id])
43
- @order = Order.find( params[:id] )
44
- else
45
- raise "last order of logged person"
46
- end
47
- end
48
-
49
- def add
50
- prod = Product.find( params[:id]) # no id will raise which in turn will show home page
51
- current_basket.add_product(prod)
52
- if request.get?
53
- redirect_to shop_checkout_path
54
- else
55
- redirect_to shop_group_path(prod.category.link), :notice => "#{t(:product_added)}: #{prod.name}"
56
- end
57
- end
58
- def remove
59
- prod = Product.find( params[:id]) # no id will raise which in turn will show home page
60
- current_basket.add_product(prod , -1)
61
- redirect_to shop_checkout_path
62
- end
63
-
64
- def group
65
- @group = Category.online.where(:link => params[:link]).first
66
- if @group
67
- @products = @group.shop_products
68
- template = "product_list"
69
- @groups = @group.categories.online
70
- else
71
- @groups = Category.online.where( :category_id => nil )
72
- template = "main_group"
73
- end
74
- render template
75
- end
76
-
77
- def page
78
- @products = Product.shop_products.limit(50)
79
- template = params[:id]
80
- template = "tuotteista" if template.blank?
81
- render template
82
- end
83
- private
84
- def load
85
- @menu = {"/page/kotisivu" => "KOTISIVU" ,
86
- "/group/start" => "VERKKOKAUPPA" ,
87
- "/page/tuotteista" => "TUOTTEISTA",
88
- "/page/toimitusehdot" => "TOIMITUSEHDOT" ,
89
- "/page/liike" => "LIIKKEEMME" }
90
- end
91
- end