canmoia 0.0.2 → 0.0.3
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/lib/canmoia/concerns/order.rb +1 -1
- data/lib/canmoia/version.rb +1 -1
- metadata +6 -47
- data/lib/canmoia/concerns/notification.rb~ +0 -38
- data/lib/canmoia/concerns/order.rb~ +0 -65
- data/lib/canmoia/concerns/work.rb~ +0 -33
- data/lib/canmoia/features/notification.rb~ +0 -38
- data/lib/canmoia.rb~ +0 -6
- data/spec/concerns/order_spec.rb~ +0 -41
- data/spec/dummy/app/mailers/notifiable_order_mailer.rb~ +0 -14
- data/spec/dummy/app/mailers/work_order_mailer.rb~ +0 -14
- data/spec/dummy/app/models/employee.rb~ +0 -3
- data/spec/dummy/app/models/order.rb~ +0 -4
- data/spec/dummy/app/models/user.rb~ +0 -4
- data/spec/dummy/app/models/work_order.rb~ +0 -3
- data/spec/dummy/config/application.rb~ +0 -59
- data/spec/dummy/config/environment.rb~ +0 -5
- data/spec/dummy/config/environments/development.rb~ +0 -37
- data/spec/dummy/config/environments/test.rb~ +0 -37
- data/spec/dummy/config/mongoid.yml~ +0 -68
- data/spec/dummy/spec/mailers/notifiable_order_mailer_spec.rb~ +0 -18
- data/spec/dummy/spec/mailers/work_order_mailer_spec.rb~ +0 -20
- data/spec/fabricators/item_fabricator.rb~ +0 -5
- data/spec/fabricators/order_fabricator.rb~ +0 -9
- data/spec/fabricators/user_fabricator.rb~ +0 -7
- data/spec/spec_helper.rb~ +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5164694cffe2c1ffa622ada7775f847d81dfc5e4
|
|
4
|
+
data.tar.gz: 7aa65b2101b6c8fe3f90ad81cb3073d59de609f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f29669c86b9da4e37587949c688b73a9254e25bee307c83441d0079d4308ef6950aa663e41034abe57c4de8521e8b027dd0a597eebd748d95373d978ef03a9d7
|
|
7
|
+
data.tar.gz: 1161fb40d0461e8479c316f8b5c062d70b1a6196506bd1a82ce51055d053f5b0fff8af173034a41e4c7c3d2406035ddb652fd8a7f6b51688dfbfed2245757a82
|
data/lib/canmoia/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: canmoia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Heitor Salazar Baldelli
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-08-
|
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - '>='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - '>='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: mongoid
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -255,17 +255,12 @@ executables: []
|
|
|
255
255
|
extensions: []
|
|
256
256
|
extra_rdoc_files: []
|
|
257
257
|
files:
|
|
258
|
-
- lib/canmoia/concerns/notification.rb~
|
|
259
258
|
- lib/canmoia/concerns/order.rb
|
|
260
|
-
- lib/canmoia/concerns/order.rb~
|
|
261
259
|
- lib/canmoia/concerns/work.rb
|
|
262
|
-
- lib/canmoia/concerns/work.rb~
|
|
263
260
|
- lib/canmoia/features/notification.rb
|
|
264
|
-
- lib/canmoia/features/notification.rb~
|
|
265
261
|
- lib/canmoia/tasks/install.rb.erb
|
|
266
262
|
- lib/canmoia/version.rb
|
|
267
263
|
- lib/canmoia.rb
|
|
268
|
-
- lib/canmoia.rb~
|
|
269
264
|
- lib/tasks/canmoia_tasks.rake
|
|
270
265
|
- lib/tasks/canmoia_tasks.rb.erb
|
|
271
266
|
- WTFP-LICENSE
|
|
@@ -273,37 +268,26 @@ files:
|
|
|
273
268
|
- README.md
|
|
274
269
|
- Guardfile
|
|
275
270
|
- spec/concerns/order_spec.rb
|
|
276
|
-
- spec/concerns/order_spec.rb~
|
|
277
271
|
- spec/concerns/work_spec.rb
|
|
278
272
|
- spec/dummy/app/assets/javascripts/application.js
|
|
279
273
|
- spec/dummy/app/assets/stylesheets/application.css
|
|
280
274
|
- spec/dummy/app/controllers/application_controller.rb
|
|
281
275
|
- spec/dummy/app/helpers/application_helper.rb
|
|
282
|
-
- spec/dummy/app/mailers/notifiable_order_mailer.rb~
|
|
283
276
|
- spec/dummy/app/mailers/work_order_mailer.rb
|
|
284
|
-
- spec/dummy/app/mailers/work_order_mailer.rb~
|
|
285
277
|
- spec/dummy/app/models/employee.rb
|
|
286
|
-
- spec/dummy/app/models/employee.rb~
|
|
287
278
|
- spec/dummy/app/models/item.rb
|
|
288
279
|
- spec/dummy/app/models/order.rb
|
|
289
|
-
- spec/dummy/app/models/order.rb~
|
|
290
280
|
- spec/dummy/app/models/user.rb
|
|
291
|
-
- spec/dummy/app/models/user.rb~
|
|
292
281
|
- spec/dummy/app/models/work_order.rb
|
|
293
|
-
- spec/dummy/app/models/work_order.rb~
|
|
294
282
|
- spec/dummy/app/views/layouts/application.html.erb
|
|
295
283
|
- spec/dummy/app/views/work_order_mailer/close_notification_to_responsible.text.erb
|
|
296
284
|
- spec/dummy/config/application.rb
|
|
297
|
-
- spec/dummy/config/application.rb~
|
|
298
285
|
- spec/dummy/config/boot.rb
|
|
299
286
|
- spec/dummy/config/database.yml
|
|
300
287
|
- spec/dummy/config/environment.rb
|
|
301
|
-
- spec/dummy/config/environment.rb~
|
|
302
288
|
- spec/dummy/config/environments/development.rb
|
|
303
|
-
- spec/dummy/config/environments/development.rb~
|
|
304
289
|
- spec/dummy/config/environments/production.rb
|
|
305
290
|
- spec/dummy/config/environments/test.rb
|
|
306
|
-
- spec/dummy/config/environments/test.rb~
|
|
307
291
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
308
292
|
- spec/dummy/config/initializers/inflections.rb
|
|
309
293
|
- spec/dummy/config/initializers/mime_types.rb
|
|
@@ -312,7 +296,6 @@ files:
|
|
|
312
296
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
|
313
297
|
- spec/dummy/config/locales/en.yml
|
|
314
298
|
- spec/dummy/config/mongoid.yml
|
|
315
|
-
- spec/dummy/config/mongoid.yml~
|
|
316
299
|
- spec/dummy/config/routes.rb
|
|
317
300
|
- spec/dummy/config.ru
|
|
318
301
|
- spec/dummy/db/development.sqlite3
|
|
@@ -326,17 +309,11 @@ files:
|
|
|
326
309
|
- spec/dummy/README.rdoc
|
|
327
310
|
- spec/dummy/script/rails
|
|
328
311
|
- spec/dummy/spec/fixtures/work_order_mailer/close_notification_to_responsible
|
|
329
|
-
- spec/dummy/spec/mailers/notifiable_order_mailer_spec.rb~
|
|
330
312
|
- spec/dummy/spec/mailers/work_order_mailer_spec.rb
|
|
331
|
-
- spec/dummy/spec/mailers/work_order_mailer_spec.rb~
|
|
332
313
|
- spec/fabricators/item_fabricator.rb
|
|
333
|
-
- spec/fabricators/item_fabricator.rb~
|
|
334
314
|
- spec/fabricators/order_fabricator.rb
|
|
335
|
-
- spec/fabricators/order_fabricator.rb~
|
|
336
315
|
- spec/fabricators/user_fabricator.rb
|
|
337
|
-
- spec/fabricators/user_fabricator.rb~
|
|
338
316
|
- spec/spec_helper.rb
|
|
339
|
-
- spec/spec_helper.rb~
|
|
340
317
|
- spec/support/concern_macros.rb
|
|
341
318
|
- spec/support/fabrication.rb
|
|
342
319
|
- spec/support/fabricator.rb
|
|
@@ -367,37 +344,26 @@ specification_version: 4
|
|
|
367
344
|
summary: Canmöia (can = order, möia = work). The core functionality of Order domain.
|
|
368
345
|
test_files:
|
|
369
346
|
- spec/concerns/order_spec.rb
|
|
370
|
-
- spec/concerns/order_spec.rb~
|
|
371
347
|
- spec/concerns/work_spec.rb
|
|
372
348
|
- spec/dummy/app/assets/javascripts/application.js
|
|
373
349
|
- spec/dummy/app/assets/stylesheets/application.css
|
|
374
350
|
- spec/dummy/app/controllers/application_controller.rb
|
|
375
351
|
- spec/dummy/app/helpers/application_helper.rb
|
|
376
|
-
- spec/dummy/app/mailers/notifiable_order_mailer.rb~
|
|
377
352
|
- spec/dummy/app/mailers/work_order_mailer.rb
|
|
378
|
-
- spec/dummy/app/mailers/work_order_mailer.rb~
|
|
379
353
|
- spec/dummy/app/models/employee.rb
|
|
380
|
-
- spec/dummy/app/models/employee.rb~
|
|
381
354
|
- spec/dummy/app/models/item.rb
|
|
382
355
|
- spec/dummy/app/models/order.rb
|
|
383
|
-
- spec/dummy/app/models/order.rb~
|
|
384
356
|
- spec/dummy/app/models/user.rb
|
|
385
|
-
- spec/dummy/app/models/user.rb~
|
|
386
357
|
- spec/dummy/app/models/work_order.rb
|
|
387
|
-
- spec/dummy/app/models/work_order.rb~
|
|
388
358
|
- spec/dummy/app/views/layouts/application.html.erb
|
|
389
359
|
- spec/dummy/app/views/work_order_mailer/close_notification_to_responsible.text.erb
|
|
390
360
|
- spec/dummy/config/application.rb
|
|
391
|
-
- spec/dummy/config/application.rb~
|
|
392
361
|
- spec/dummy/config/boot.rb
|
|
393
362
|
- spec/dummy/config/database.yml
|
|
394
363
|
- spec/dummy/config/environment.rb
|
|
395
|
-
- spec/dummy/config/environment.rb~
|
|
396
364
|
- spec/dummy/config/environments/development.rb
|
|
397
|
-
- spec/dummy/config/environments/development.rb~
|
|
398
365
|
- spec/dummy/config/environments/production.rb
|
|
399
366
|
- spec/dummy/config/environments/test.rb
|
|
400
|
-
- spec/dummy/config/environments/test.rb~
|
|
401
367
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
402
368
|
- spec/dummy/config/initializers/inflections.rb
|
|
403
369
|
- spec/dummy/config/initializers/mime_types.rb
|
|
@@ -406,7 +372,6 @@ test_files:
|
|
|
406
372
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
|
407
373
|
- spec/dummy/config/locales/en.yml
|
|
408
374
|
- spec/dummy/config/mongoid.yml
|
|
409
|
-
- spec/dummy/config/mongoid.yml~
|
|
410
375
|
- spec/dummy/config/routes.rb
|
|
411
376
|
- spec/dummy/config.ru
|
|
412
377
|
- spec/dummy/db/development.sqlite3
|
|
@@ -420,17 +385,11 @@ test_files:
|
|
|
420
385
|
- spec/dummy/README.rdoc
|
|
421
386
|
- spec/dummy/script/rails
|
|
422
387
|
- spec/dummy/spec/fixtures/work_order_mailer/close_notification_to_responsible
|
|
423
|
-
- spec/dummy/spec/mailers/notifiable_order_mailer_spec.rb~
|
|
424
388
|
- spec/dummy/spec/mailers/work_order_mailer_spec.rb
|
|
425
|
-
- spec/dummy/spec/mailers/work_order_mailer_spec.rb~
|
|
426
389
|
- spec/fabricators/item_fabricator.rb
|
|
427
|
-
- spec/fabricators/item_fabricator.rb~
|
|
428
390
|
- spec/fabricators/order_fabricator.rb
|
|
429
|
-
- spec/fabricators/order_fabricator.rb~
|
|
430
391
|
- spec/fabricators/user_fabricator.rb
|
|
431
|
-
- spec/fabricators/user_fabricator.rb~
|
|
432
392
|
- spec/spec_helper.rb
|
|
433
|
-
- spec/spec_helper.rb~
|
|
434
393
|
- spec/support/concern_macros.rb
|
|
435
394
|
- spec/support/fabrication.rb
|
|
436
395
|
- spec/support/fabricator.rb
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module Canmoia::Notification
|
|
2
|
-
|
|
3
|
-
def notify entity_name = :responsible, on: -> { raise "on is required" }, via: :email
|
|
4
|
-
raise "Recipient named as '#{entity_name}' not found for #{self.name}" unless instance_methods.include? entity_name.to_sym
|
|
5
|
-
|
|
6
|
-
on.each do |event|
|
|
7
|
-
add_notification_method event, entity_name, via
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
# TODO use method missing
|
|
14
|
-
def add_notification_method event, entity_name, via
|
|
15
|
-
mail_method = "#{event}_notification_to_#{entity_name}"
|
|
16
|
-
|
|
17
|
-
define_method "#{event}!" do |*args|
|
|
18
|
-
returned = super *args
|
|
19
|
-
# TODO better error message when mailer is not found
|
|
20
|
-
# TODO allow specification of custom mailer
|
|
21
|
-
mailer = "#{self.class.name}Mailer".classify.constantize
|
|
22
|
-
|
|
23
|
-
# TODO better error message when mail method is not found
|
|
24
|
-
entity = send entity_name
|
|
25
|
-
mail = mailer.send mail_method, self, entity
|
|
26
|
-
|
|
27
|
-
mail.deliver or returned
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# - on :open , close: :reviewing, cancel: :canceled, notify: :responsible
|
|
32
|
-
# V on :review, reject: :rejected, accept: :accepted
|
|
33
|
-
# - on :accept, notify: :buyer
|
|
34
|
-
# - on :reject, notify: :buyer
|
|
35
|
-
# - on :cancel, notify: [:buyer, via: :email] }
|
|
36
|
-
# - on :finish, notify: [:buyer, via: :email] }
|
|
37
|
-
|
|
38
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
require 'active_support/concern'
|
|
2
|
-
|
|
3
|
-
module Canmoia
|
|
4
|
-
module Order
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
include ::Workflow
|
|
9
|
-
include CalculationMethods
|
|
10
|
-
# extend Notification
|
|
11
|
-
|
|
12
|
-
# Fields
|
|
13
|
-
field :total, type: Float
|
|
14
|
-
field :state, type: Symbol
|
|
15
|
-
|
|
16
|
-
# Relations
|
|
17
|
-
embeds_many :items
|
|
18
|
-
has_one :client, :class_name => "::User"
|
|
19
|
-
|
|
20
|
-
# States
|
|
21
|
-
workflow_column :state
|
|
22
|
-
workflow do
|
|
23
|
-
|
|
24
|
-
state :opened do
|
|
25
|
-
event :close , transitions_to: :reviewing
|
|
26
|
-
event :cancel, transitions_to: :canceled
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
state :reviewing do
|
|
30
|
-
event :accept, transitions_to: :accepted
|
|
31
|
-
event :reject, transitions_to: :rejected
|
|
32
|
-
|
|
33
|
-
event :cancel, transitions_to: :canceled
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
state :accepted do
|
|
37
|
-
event :complete, transitions_to: :completed
|
|
38
|
-
event :cancel , transitions_to: :canceled
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
state :rejected do
|
|
42
|
-
event :complete, transitions_to: :completed
|
|
43
|
-
event :cancel , transitions_to: :canceled
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
state :completed
|
|
47
|
-
state :canceled
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
module CalculationMethods
|
|
52
|
-
def total
|
|
53
|
-
@total ||= super or items.sum(&:value)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# - on :open , close: :reviewing, cancel: :canceled, notify: :responsible
|
|
58
|
-
# V on :review, reject: :rejected, accept: :accepted
|
|
59
|
-
# - on :accept, notify: :buyer
|
|
60
|
-
# - on :reject, notify: :buyer
|
|
61
|
-
# - on :cancel, notify: [:buyer, via: :email] }
|
|
62
|
-
# - on :finish, notify: [:buyer, via: :email] }
|
|
63
|
-
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require 'active_support/concern'
|
|
2
|
-
|
|
3
|
-
module Canmoia
|
|
4
|
-
module Work
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
include Order
|
|
9
|
-
|
|
10
|
-
# Fields
|
|
11
|
-
|
|
12
|
-
# Relations
|
|
13
|
-
belongs_to :responsible, :class_name => "::User"
|
|
14
|
-
|
|
15
|
-
# States Notifications
|
|
16
|
-
notify :responsible
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
module CalculationMethods
|
|
20
|
-
def total
|
|
21
|
-
@total ||= items.sum(&:value)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# - on :open , close: :reviewing, cancel: :canceled, notify: :responsible
|
|
26
|
-
# V on :review, reject: :rejected, accept: :accepted
|
|
27
|
-
# - on :accept, notify: :buyer
|
|
28
|
-
# - on :reject, notify: :buyer
|
|
29
|
-
# - on :cancel, notify: [:buyer, via: :email] }
|
|
30
|
-
# - on :finish, notify: [:buyer, via: :email] }
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# require 'active_support/concern'
|
|
2
|
-
|
|
3
|
-
module Canmoia
|
|
4
|
-
module Notification
|
|
5
|
-
# TODO add when needed extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
def notify entity_name = :responsible, on: -> { raise "on is required" }, via: :email
|
|
8
|
-
raise "Recipient named as '#{entity_name}' not found for #{self.name}" unless instance_methods.include? entity_name.to_sym
|
|
9
|
-
|
|
10
|
-
on.each do |event|
|
|
11
|
-
add_notification_method event, entity_name, via
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
# TODO use method missing
|
|
18
|
-
def add_notification_method event, entity_name, via
|
|
19
|
-
mail_method = "#{event}_notification_to_#{entity_name}"
|
|
20
|
-
|
|
21
|
-
# TODO only define notification method if method is present on mailer
|
|
22
|
-
# TODO create task to generate / update mailer with notification settings
|
|
23
|
-
|
|
24
|
-
define_method "#{event}!" do |*args|
|
|
25
|
-
returned = super *args
|
|
26
|
-
# TODO better error message when mailer is not found
|
|
27
|
-
# TODO allow specification of custom mailer
|
|
28
|
-
mailer = "#{self.class.name}Mailer".classify.constantize
|
|
29
|
-
|
|
30
|
-
# TODO better error message when mail method is not found
|
|
31
|
-
entity = send entity_name
|
|
32
|
-
mail = mailer.send mail_method, self, entity
|
|
33
|
-
|
|
34
|
-
mail.deliver or returned
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
data/lib/canmoia.rb~
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe Canmoia::Order do
|
|
4
|
-
|
|
5
|
-
it 'should include Camnoia::Order module ' do
|
|
6
|
-
order = Fabricate :order
|
|
7
|
-
order.class.included_modules.should include Canmoia::Order
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it 'should define core domain states for a Order' do
|
|
11
|
-
order = Fabricate :order # Order class must include Canmoia::Order
|
|
12
|
-
order.should respond_to :opened?
|
|
13
|
-
order.should respond_to :reviewing?
|
|
14
|
-
order.should respond_to :accepted?
|
|
15
|
-
order.should respond_to :rejected?
|
|
16
|
-
order.should respond_to :canceled?
|
|
17
|
-
order.should respond_to :completed?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should compute total value' do
|
|
21
|
-
order = Fabricate :accepted_order
|
|
22
|
-
order.items.sum(&:value).should == order.total
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'should not compute total value after opened state' do
|
|
26
|
-
order = Fabricate :order
|
|
27
|
-
first_item = order.items.first
|
|
28
|
-
|
|
29
|
-
order.close!
|
|
30
|
-
|
|
31
|
-
first_item.value = 1
|
|
32
|
-
|
|
33
|
-
order.items.sum(&:value).should == order.total
|
|
34
|
-
|
|
35
|
-
first_item.value = 2
|
|
36
|
-
|
|
37
|
-
order.items.sum(&:value).should == order.total
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# it 'should ignore workflow_column call if workflow_column already called'
|
|
41
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
class NotifiableOrderMailer < ActionMailer::Base
|
|
2
|
-
default from: "from@example.com"
|
|
3
|
-
|
|
4
|
-
# Subject can be set in your I18n file at config/locales/en.yml
|
|
5
|
-
# with the following lookup:
|
|
6
|
-
#
|
|
7
|
-
# en.notifiable_order_mailer.close_notification_to_responsible.subject
|
|
8
|
-
#
|
|
9
|
-
def close_notification_to_responsible
|
|
10
|
-
@greeting = "Hi"
|
|
11
|
-
|
|
12
|
-
mail to: "to@example.org"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
class WorkOrderMailer < ActionMailer::Base
|
|
2
|
-
default from: "from@example.com"
|
|
3
|
-
|
|
4
|
-
# Subject can be set in your I18n file at config/locales/en.yml
|
|
5
|
-
# with the following lookup:
|
|
6
|
-
#
|
|
7
|
-
# en.work_order_mailer.close_notification_to_responsible.subject
|
|
8
|
-
#
|
|
9
|
-
def close_notification_to_responsible
|
|
10
|
-
@greeting = "Hi"
|
|
11
|
-
|
|
12
|
-
mail to: "to@example.org"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
|
2
|
-
|
|
3
|
-
require 'rails/all'
|
|
4
|
-
|
|
5
|
-
Bundler.require(*Rails.groups)
|
|
6
|
-
require "canmoia"
|
|
7
|
-
|
|
8
|
-
module Dummy
|
|
9
|
-
class Application < Rails::Application
|
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
-
# Application configuration should go into files in config/initializers
|
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
-
|
|
14
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
|
15
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
|
16
|
-
|
|
17
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
18
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
19
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
20
|
-
|
|
21
|
-
# Activate observers that should always be running.
|
|
22
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
23
|
-
|
|
24
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
25
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
26
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
|
27
|
-
|
|
28
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
29
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
30
|
-
# config.i18n.default_locale = :de
|
|
31
|
-
|
|
32
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
|
33
|
-
config.encoding = "utf-8"
|
|
34
|
-
|
|
35
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
|
36
|
-
config.filter_parameters += [:password]
|
|
37
|
-
|
|
38
|
-
# Enable escaping HTML in JSON.
|
|
39
|
-
config.active_support.escape_html_entities_in_json = true
|
|
40
|
-
|
|
41
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
|
42
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
43
|
-
# like if you have constraints or database-specific column types
|
|
44
|
-
# config.active_record.schema_format = :sql
|
|
45
|
-
|
|
46
|
-
# Enforce whitelist mode for mass assignment.
|
|
47
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
|
48
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
|
49
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
|
50
|
-
config.active_record.whitelist_attributes = true
|
|
51
|
-
|
|
52
|
-
# Enable the asset pipeline
|
|
53
|
-
config.assets.enabled = true
|
|
54
|
-
|
|
55
|
-
# Version of your assets, change this if you want to expire all your assets
|
|
56
|
-
config.assets.version = '1.0'
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Dummy::Application.configure do
|
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
-
|
|
4
|
-
# In the development environment your application's code is reloaded on
|
|
5
|
-
# every request. This slows down response time but is perfect for development
|
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
|
7
|
-
config.cache_classes = false
|
|
8
|
-
|
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
|
10
|
-
config.whiny_nils = true
|
|
11
|
-
|
|
12
|
-
# Show full error reports and disable caching
|
|
13
|
-
config.consider_all_requests_local = true
|
|
14
|
-
config.action_controller.perform_caching = false
|
|
15
|
-
|
|
16
|
-
# Don't care if the mailer can't send
|
|
17
|
-
config.action_mailer.raise_delivery_errors = false
|
|
18
|
-
|
|
19
|
-
# Print deprecation notices to the Rails logger
|
|
20
|
-
config.active_support.deprecation = :log
|
|
21
|
-
|
|
22
|
-
# Only use best-standards-support built into browsers
|
|
23
|
-
config.action_dispatch.best_standards_support = :builtin
|
|
24
|
-
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
|
27
|
-
|
|
28
|
-
# Log the query plan for queries taking more than this (works
|
|
29
|
-
# with SQLite, MySQL, and PostgreSQL)
|
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
|
31
|
-
|
|
32
|
-
# Do not compress assets
|
|
33
|
-
config.assets.compress = false
|
|
34
|
-
|
|
35
|
-
# Expands the lines which load the assets
|
|
36
|
-
config.assets.debug = true
|
|
37
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Dummy::Application.configure do
|
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
-
|
|
4
|
-
# The test environment is used exclusively to run your application's
|
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
-
config.cache_classes = true
|
|
9
|
-
|
|
10
|
-
# Configure static asset server for tests with Cache-Control for performance
|
|
11
|
-
config.serve_static_assets = true
|
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
|
13
|
-
|
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
|
15
|
-
config.whiny_nils = true
|
|
16
|
-
|
|
17
|
-
# Show full error reports and disable caching
|
|
18
|
-
config.consider_all_requests_local = true
|
|
19
|
-
config.action_controller.perform_caching = false
|
|
20
|
-
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
|
22
|
-
config.action_dispatch.show_exceptions = false
|
|
23
|
-
|
|
24
|
-
# Disable request forgery protection in test environment
|
|
25
|
-
config.action_controller.allow_forgery_protection = false
|
|
26
|
-
|
|
27
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
|
28
|
-
# The :test delivery method accumulates sent emails in the
|
|
29
|
-
# ActionMailer::Base.deliveries array.
|
|
30
|
-
config.action_mailer.delivery_method = :test
|
|
31
|
-
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
|
34
|
-
|
|
35
|
-
# Print deprecation notices to the stderr
|
|
36
|
-
config.active_support.deprecation = :stderr
|
|
37
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
development:
|
|
2
|
-
# Configure available database sessions. (required)
|
|
3
|
-
sessions:
|
|
4
|
-
# Defines the default session. (required)
|
|
5
|
-
default:
|
|
6
|
-
# Defines the name of the default database that Mongoid can connect to.
|
|
7
|
-
# (required).
|
|
8
|
-
database: kuva_development
|
|
9
|
-
# Provides the hosts the default session can connect to. Must be an array
|
|
10
|
-
# of host:port pairs. (required)
|
|
11
|
-
hosts:
|
|
12
|
-
- localhost:27017
|
|
13
|
-
options:
|
|
14
|
-
# Change whether the session persists in safe mode by default.
|
|
15
|
-
# (default: false)
|
|
16
|
-
# safe: false
|
|
17
|
-
|
|
18
|
-
# Change the default consistency model to :eventual or :strong.
|
|
19
|
-
# :eventual will send reads to secondaries, :strong sends everything
|
|
20
|
-
# to master. (default: :eventual)
|
|
21
|
-
consistency: :strong
|
|
22
|
-
# Configure Mongoid specific options. (optional)
|
|
23
|
-
options:
|
|
24
|
-
# Configuration for whether or not to allow access to fields that do
|
|
25
|
-
# not have a field definition on the model. (default: true)
|
|
26
|
-
# allow_dynamic_fields: true
|
|
27
|
-
|
|
28
|
-
# Enable the identity map, needed for eager loading. (default: false)
|
|
29
|
-
# identity_map_enabled: false
|
|
30
|
-
|
|
31
|
-
# Includes the root model name in json serialization. (default: false)
|
|
32
|
-
# include_root_in_json: false
|
|
33
|
-
|
|
34
|
-
# Include the _type field in serializaion. (default: false)
|
|
35
|
-
# include_type_for_serialization: false
|
|
36
|
-
|
|
37
|
-
# Preload all models in development, needed when models use
|
|
38
|
-
# inheritance. (default: false)
|
|
39
|
-
# preload_models: false
|
|
40
|
-
|
|
41
|
-
# Protect id and type from mass assignment. (default: true)
|
|
42
|
-
# protect_sensitive_fields: true
|
|
43
|
-
|
|
44
|
-
# Raise an error when performing a #find and the document is not found.
|
|
45
|
-
# (default: true)
|
|
46
|
-
# raise_not_found_error: true
|
|
47
|
-
|
|
48
|
-
# Raise an error when defining a scope with the same name as an
|
|
49
|
-
# existing method. (default: false)
|
|
50
|
-
# scope_overwrite_exception: false
|
|
51
|
-
|
|
52
|
-
# Skip the database version check, used when connecting to a db without
|
|
53
|
-
# admin access. (default: false)
|
|
54
|
-
# skip_version_check: false
|
|
55
|
-
|
|
56
|
-
# User Active Support's time zone in conversions. (default: true)
|
|
57
|
-
# use_activesupport_time_zone: true
|
|
58
|
-
|
|
59
|
-
# Ensure all times are UTC in the app side. (default: false)
|
|
60
|
-
# use_utc: false
|
|
61
|
-
test:
|
|
62
|
-
sessions:
|
|
63
|
-
default:
|
|
64
|
-
database: kuva_test
|
|
65
|
-
hosts:
|
|
66
|
-
- localhost:27017
|
|
67
|
-
options:
|
|
68
|
-
consistency: :strong
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe NotifiableOrderMailer do
|
|
4
|
-
describe "close_notification_to_responsible" do
|
|
5
|
-
let(:mail) { NotifiableOrderMailer.close_notification_to_responsible }
|
|
6
|
-
|
|
7
|
-
it "renders the headers" do
|
|
8
|
-
mail.subject.should eq("Close notification to responsible")
|
|
9
|
-
mail.to.should eq(["to@example.org"])
|
|
10
|
-
mail.from.should eq(["from@example.com"])
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "renders the body" do
|
|
14
|
-
mail.body.encoded.should match("Hi")
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe WorkOrderMailer do
|
|
4
|
-
describe "close_notification_to_responsible" do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let(:mail) { WorkOrderMailer.close_notification_to_responsible }
|
|
8
|
-
|
|
9
|
-
it "renders the headers" do
|
|
10
|
-
mail.subject.should eq("Close notification to responsible")
|
|
11
|
-
mail.to.should eq(["to@example.org"])
|
|
12
|
-
mail.from.should eq(["from@example.com"])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "renders the body" do
|
|
16
|
-
mail.body.encoded.should match("Hi")
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
data/spec/spec_helper.rb~
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Configure Rails Envinronment
|
|
2
|
-
ENV["RAILS_ENV"] ||= "test"
|
|
3
|
-
|
|
4
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
5
|
-
|
|
6
|
-
require 'rspec/rails'
|
|
7
|
-
require 'rspec/autorun'
|
|
8
|
-
require 'rails/mongoid'
|
|
9
|
-
require 'forgery'
|
|
10
|
-
require 'database_cleaner'
|
|
11
|
-
|
|
12
|
-
Rails.backtrace_cleaner.remove_silencers!
|
|
13
|
-
|
|
14
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
15
|
-
# in spec/support/ and its subdirectories.
|
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
17
|
-
|
|
18
|
-
RSpec.configure do |config|
|
|
19
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
20
|
-
config.run_all_when_everything_filtered = true
|
|
21
|
-
config.filter_run :focus
|
|
22
|
-
|
|
23
|
-
# Database Cleaner support
|
|
24
|
-
config.before(:each) do
|
|
25
|
-
DatabaseCleaner.strategy = :truncation, {:except => %w[ ]}
|
|
26
|
-
DatabaseCleaner.clean
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Run specs in random order to surface order dependencies. If you find an
|
|
30
|
-
# order dependency and want to debug it, you can fix the order by providing
|
|
31
|
-
# the seed, which is printed after each run.
|
|
32
|
-
# --seed 1234
|
|
33
|
-
config.order = 'random'
|
|
34
|
-
end
|