volt 0.8.18 → 0.8.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Readme.md +2 -1
  4. data/VERSION +1 -1
  5. data/app/volt/controllers/notices_controller.rb +12 -2
  6. data/app/volt/models/user.rb +34 -1
  7. data/app/volt/tasks/store_tasks.rb +26 -23
  8. data/app/volt/tasks/user_tasks.rb +26 -2
  9. data/app/volt/views/notices/index.html +8 -6
  10. data/lib/volt.rb +47 -1
  11. data/lib/volt/cli/asset_compile.rb +24 -42
  12. data/lib/volt/config.rb +24 -14
  13. data/lib/volt/controllers/model_controller.rb +6 -1
  14. data/lib/volt/data_stores/mongo_driver.rb +7 -3
  15. data/lib/volt/models.rb +3 -0
  16. data/lib/volt/models/array_model.rb +21 -3
  17. data/lib/volt/models/model.rb +109 -48
  18. data/lib/volt/models/model_hash_behaviour.rb +25 -8
  19. data/lib/volt/models/persistors/array_store.rb +5 -2
  20. data/lib/volt/models/persistors/cookies.rb +91 -0
  21. data/lib/volt/models/persistors/model_store.rb +52 -14
  22. data/lib/volt/models/persistors/query/query_listener.rb +4 -1
  23. data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
  24. data/lib/volt/models/persistors/store_state.rb +5 -5
  25. data/lib/volt/models/validations.rb +87 -18
  26. data/lib/volt/models/validators/length_validator.rb +1 -1
  27. data/lib/volt/models/validators/presence_validator.rb +1 -1
  28. data/lib/volt/models/validators/unique_validator.rb +28 -0
  29. data/lib/volt/page/bindings/template_binding.rb +2 -2
  30. data/lib/volt/page/page.rb +4 -0
  31. data/lib/volt/page/tasks.rb +2 -2
  32. data/lib/volt/reactive/computation.rb +2 -0
  33. data/lib/volt/reactive/hash_dependency.rb +1 -3
  34. data/lib/volt/reactive/reactive_array.rb +7 -0
  35. data/lib/volt/reactive/reactive_hash.rb +17 -0
  36. data/lib/volt/server.rb +1 -1
  37. data/lib/volt/server/component_templates.rb +3 -6
  38. data/lib/volt/server/html_parser/view_scope.rb +1 -1
  39. data/lib/volt/server/rack/component_code.rb +3 -2
  40. data/lib/volt/server/rack/component_paths.rb +15 -0
  41. data/lib/volt/server/rack/index_files.rb +1 -1
  42. data/lib/volt/tasks/dispatcher.rb +26 -12
  43. data/lib/volt/tasks/task_handler.rb +17 -15
  44. data/spec/apps/kitchen_sink/app/main/config/routes.rb +3 -0
  45. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +26 -0
  46. data/spec/apps/kitchen_sink/app/main/controllers/users_test_controller.rb +27 -0
  47. data/spec/apps/kitchen_sink/app/main/views/main/cookie_test.html +25 -0
  48. data/spec/apps/kitchen_sink/app/main/views/main/flash.html +13 -0
  49. data/spec/apps/kitchen_sink/app/main/views/main/main.html +3 -0
  50. data/spec/apps/kitchen_sink/app/main/views/users_test/index.html +22 -0
  51. data/spec/apps/kitchen_sink/config/app.rb +3 -0
  52. data/spec/integration/bindings_spec.rb +1 -1
  53. data/spec/integration/cookies_spec.rb +48 -0
  54. data/spec/integration/flash_spec.rb +32 -0
  55. data/spec/models/model_spec.rb +3 -4
  56. data/spec/models/validations_spec.rb +13 -13
  57. data/spec/tasks/dispatcher_spec.rb +1 -1
  58. data/templates/project/config/app.rb.tt +6 -1
  59. data/templates/project/{public → config/base_page}/index.html +0 -0
  60. data/volt.gemspec +4 -0
  61. metadata +47 -3
@@ -0,0 +1,32 @@
1
+ if ENV['BROWSER']
2
+ require 'spec_helper'
3
+
4
+ describe 'flash messages', type: :feature do
5
+ it 'should flash on sucesses, notices, warnings, and errors' do
6
+ visit '/'
7
+
8
+ click_link 'Flash'
9
+
10
+ click_link 'Flash Notice'
11
+ expect(page).to have_content('A notice message')
12
+ find('.alert').click
13
+ expect(page).to_not have_content('A notice message')
14
+
15
+ click_link 'Flash Success'
16
+ expect(page).to have_content('A success message')
17
+ find('.alert').click
18
+ expect(page).to_not have_content('A success message')
19
+
20
+ click_link 'Flash Warning'
21
+ expect(page).to have_content('A warning message')
22
+ find('.alert').click
23
+ expect(page).to_not have_content('A warning message')
24
+
25
+ click_link 'Flash Error'
26
+ expect(page).to have_content('An error message')
27
+ find('.alert').click
28
+ expect(page).to_not have_content('An error message')
29
+
30
+ end
31
+ end
32
+ end
@@ -204,17 +204,16 @@ describe Volt::Model do
204
204
  a._blue._green = 5
205
205
  Volt::Computation.flush!
206
206
 
207
- # TODO: Should equal 2
208
- expect(count).to eq(2)
207
+ expect(count).to eq(1)
209
208
 
210
209
  a._blue = 22
211
210
  Volt::Computation.flush!
212
- expect(count).to eq(3)
211
+ expect(count).to eq(2)
213
212
 
214
213
  a._blue = { green: 50 }
215
214
  expect(a._blue._green).to eq(50)
216
215
  Volt::Computation.flush!
217
- expect(count).to eq(4)
216
+ expect(count).to eq(3)
218
217
  end
219
218
 
220
219
  it 'should trigger changed when a value is deleted' do
@@ -1,17 +1,17 @@
1
1
  require 'volt/models'
2
2
 
3
3
  class TestModel < Volt::Model
4
- validate :_name, length: 4
5
- validate :_description, length: { message: 'needs to be longer', length: 50 }
6
- validate :_username, presence: true
4
+ validate :name, length: 4
5
+ validate :description, length: { message: 'needs to be longer', length: 50 }
6
+ validate :username, presence: true
7
7
  end
8
8
 
9
9
  describe Volt::Model do
10
10
  it 'should validate the name' do
11
11
  expect(TestModel.new.errors).to eq(
12
- _name: ['must be at least 4 characters'],
13
- _description: ['needs to be longer'],
14
- _username: ['must be specified']
12
+ name: ['must be at least 4 characters'],
13
+ description: ['needs to be longer'],
14
+ username: ['must be specified']
15
15
  )
16
16
  end
17
17
 
@@ -20,10 +20,10 @@ describe Volt::Model do
20
20
 
21
21
  expect(model.marked_errors).to eq({})
22
22
 
23
- model.mark_field!(:_name)
23
+ model.mark_field!(:name)
24
24
 
25
25
  expect(model.marked_errors).to eq(
26
- _name: ['must be at least 4 characters']
26
+ name: ['must be at least 4 characters']
27
27
  )
28
28
  end
29
29
 
@@ -34,7 +34,7 @@ describe Volt::Model do
34
34
 
35
35
  model.save!
36
36
 
37
- expect(model.marked_errors.keys).to eq([:_name, :_description, :_username])
37
+ expect(model.marked_errors.keys).to eq([:name, :description, :username])
38
38
  end
39
39
 
40
40
  describe 'length' do
@@ -43,10 +43,10 @@ describe Volt::Model do
43
43
 
44
44
  expect(model.marked_errors).to eq({})
45
45
 
46
- model.mark_field!(:_description)
46
+ model.mark_field!(:description)
47
47
 
48
48
  expect(model.marked_errors).to eq(
49
- _description: ['needs to be longer']
49
+ description: ['needs to be longer']
50
50
  )
51
51
  end
52
52
  end
@@ -57,10 +57,10 @@ describe Volt::Model do
57
57
 
58
58
  expect(model.marked_errors).to eq({})
59
59
 
60
- model.mark_field!(:_username)
60
+ model.mark_field!(:username)
61
61
 
62
62
  expect(model.marked_errors).to eq(
63
- _username: ['must be specified']
63
+ username: ['must be specified']
64
64
  )
65
65
  end
66
66
  end
@@ -13,7 +13,7 @@ if RUBY_PLATFORM != 'opal'
13
13
 
14
14
  expect(channel).to receive(:send_message).with('response', 0, 'yes works', nil)
15
15
 
16
- Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :allowed_method, ' works'])
16
+ Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :allowed_method, {}, ' works'])
17
17
  end
18
18
 
19
19
  it 'should not allow eval' do
@@ -1,6 +1,11 @@
1
- Volt.setup do |config|
1
+ Volt.configure do |config|
2
2
  # Setup your global app config here.
3
3
 
4
+ # Your app secret is used for signing things like the user cookie so it can't
5
+ # be tampered with. A random value is generated on new projects that will work
6
+ # without the need to customize. Make sure this value doesn't leave your server.
7
+ config.app_secret = '<%= SecureRandom.urlsafe_base64(50) %>'
8
+
4
9
  # The app name defaults to the folder it is run in.
5
10
  # config.app_name = '<%= config[:name] %>'
6
11
 
data/volt.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'rake', '~> 10.0.4'
31
31
  spec.add_dependency 'listen', '~> 2.7.0'
32
32
  spec.add_dependency 'uglifier', '~> 2.4.0'
33
+ spec.add_dependency "configurations", "~> 2.0.0.pre"
33
34
  spec.add_dependency 'yui-compressor', '~> 0.12.0'
34
35
  spec.add_dependency 'opal', '~> 0.6.0'
35
36
  spec.add_dependency 'opal-jquery', '~> 0.2.0'
@@ -42,6 +43,9 @@ Gem::Specification.new do |spec|
42
43
  spec.add_dependency 'opal-rspec', '0.3.0.beta3'
43
44
  spec.add_dependency 'bundler', '>= 1.5'
44
45
 
46
+ # For user passwords
47
+ spec.add_dependency 'bcrypt', '~> 3.1.9'
48
+
45
49
  # spec.add_dependency "promise.rb", "~> 0.6.1"
46
50
 
47
51
  # spec.add_dependency "rack-colorized_logger", "~> 1.0.4"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.18
4
+ version: 0.8.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.4.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: configurations
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.0.0.pre
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.0.0.pre
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: yui-compressor
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +304,20 @@ dependencies:
290
304
  - - ">="
291
305
  - !ruby/object:Gem::Version
292
306
  version: '1.5'
307
+ - !ruby/object:Gem::Dependency
308
+ name: bcrypt
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: 3.1.9
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: 3.1.9
293
321
  - !ruby/object:Gem::Dependency
294
322
  name: guard
295
323
  requirement: !ruby/object:Gem::Requirement
@@ -411,6 +439,7 @@ files:
411
439
  - lib/volt/models/model_wrapper.rb
412
440
  - lib/volt/models/persistors/array_store.rb
413
441
  - lib/volt/models/persistors/base.rb
442
+ - lib/volt/models/persistors/cookies.rb
414
443
  - lib/volt/models/persistors/flash.rb
415
444
  - lib/volt/models/persistors/local_store.rb
416
445
  - lib/volt/models/persistors/model_identity_map.rb
@@ -425,6 +454,7 @@ files:
425
454
  - lib/volt/models/validations.rb
426
455
  - lib/volt/models/validators/length_validator.rb
427
456
  - lib/volt/models/validators/presence_validator.rb
457
+ - lib/volt/models/validators/unique_validator.rb
428
458
  - lib/volt/page/bindings/attribute_binding.rb
429
459
  - lib/volt/page/bindings/base_binding.rb
430
460
  - lib/volt/page/bindings/component_binding.rb
@@ -505,12 +535,17 @@ files:
505
535
  - spec/apps/kitchen_sink/app/main/config/routes.rb
506
536
  - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
507
537
  - spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb
538
+ - spec/apps/kitchen_sink/app/main/controllers/users_test_controller.rb
508
539
  - spec/apps/kitchen_sink/app/main/views/main/bindings.html
540
+ - spec/apps/kitchen_sink/app/main/views/main/cookie_test.html
541
+ - spec/apps/kitchen_sink/app/main/views/main/flash.html
509
542
  - spec/apps/kitchen_sink/app/main/views/main/index.html
510
543
  - spec/apps/kitchen_sink/app/main/views/main/main.html
511
544
  - spec/apps/kitchen_sink/app/main/views/main/store.html
512
545
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
546
+ - spec/apps/kitchen_sink/app/main/views/users_test/index.html
513
547
  - spec/apps/kitchen_sink/config.ru
548
+ - spec/apps/kitchen_sink/config/app.rb
514
549
  - spec/apps/kitchen_sink/public/index.html
515
550
  - spec/controllers/reactive_accessors_spec.rb
516
551
  - spec/extra_core/array_spec.rb
@@ -520,6 +555,8 @@ files:
520
555
  - spec/extra_core/string_transformations_spec.rb
521
556
  - spec/extra_core/symbol_spec.rb
522
557
  - spec/integration/bindings_spec.rb
558
+ - spec/integration/cookies_spec.rb
559
+ - spec/integration/flash_spec.rb
523
560
  - spec/integration/list_spec.rb
524
561
  - spec/integration/templates_spec.rb
525
562
  - spec/integration/url_spec.rb
@@ -596,8 +633,8 @@ files:
596
633
  - templates/project/app/main/views/main/main.html.tt
597
634
  - templates/project/config.ru
598
635
  - templates/project/config/app.rb.tt
636
+ - templates/project/config/base_page/index.html
599
637
  - templates/project/lib/.empty_directory
600
- - templates/project/public/index.html
601
638
  - templates/project/spec/sample_spec.rb
602
639
  - templates/project/spec/spec_helper.rb
603
640
  - volt.gemspec
@@ -640,12 +677,17 @@ test_files:
640
677
  - spec/apps/kitchen_sink/app/main/config/routes.rb
641
678
  - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
642
679
  - spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb
680
+ - spec/apps/kitchen_sink/app/main/controllers/users_test_controller.rb
643
681
  - spec/apps/kitchen_sink/app/main/views/main/bindings.html
682
+ - spec/apps/kitchen_sink/app/main/views/main/cookie_test.html
683
+ - spec/apps/kitchen_sink/app/main/views/main/flash.html
644
684
  - spec/apps/kitchen_sink/app/main/views/main/index.html
645
685
  - spec/apps/kitchen_sink/app/main/views/main/main.html
646
686
  - spec/apps/kitchen_sink/app/main/views/main/store.html
647
687
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
688
+ - spec/apps/kitchen_sink/app/main/views/users_test/index.html
648
689
  - spec/apps/kitchen_sink/config.ru
690
+ - spec/apps/kitchen_sink/config/app.rb
649
691
  - spec/apps/kitchen_sink/public/index.html
650
692
  - spec/controllers/reactive_accessors_spec.rb
651
693
  - spec/extra_core/array_spec.rb
@@ -655,6 +697,8 @@ test_files:
655
697
  - spec/extra_core/string_transformations_spec.rb
656
698
  - spec/extra_core/symbol_spec.rb
657
699
  - spec/integration/bindings_spec.rb
700
+ - spec/integration/cookies_spec.rb
701
+ - spec/integration/flash_spec.rb
658
702
  - spec/integration/list_spec.rb
659
703
  - spec/integration/templates_spec.rb
660
704
  - spec/integration/url_spec.rb