volt 0.9.0.pre3 → 0.9.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -7
  3. data/VERSION +1 -1
  4. data/app/volt/tasks/user_tasks.rb +7 -2
  5. data/lib/volt.rb +1 -0
  6. data/lib/volt/cli/generate.rb +28 -10
  7. data/lib/volt/controllers/http_controller.rb +1 -1
  8. data/lib/volt/extra_core/logger.rb +14 -11
  9. data/lib/volt/models/persistors/query/query_listener.rb +7 -1
  10. data/lib/volt/page/bindings/component_binding.rb +2 -2
  11. data/lib/volt/page/bindings/{template_binding.rb → view_binding.rb} +3 -3
  12. data/lib/volt/page/bindings/{template_binding → view_binding}/grouped_controllers.rb +0 -0
  13. data/lib/volt/page/bindings/{template_binding → view_binding}/view_lookup_for_path.rb +0 -0
  14. data/lib/volt/page/page.rb +1 -1
  15. data/lib/volt/server/html_parser/view_scope.rb +4 -1
  16. data/lib/volt/server/rack/component_paths.rb +1 -1
  17. data/lib/volt/spec/setup.rb +10 -2
  18. data/lib/volt/tasks/dispatcher.rb +10 -3
  19. data/lib/volt/utils/logging/task_argument_filterer.rb +42 -0
  20. data/lib/volt/utils/logging/task_logger.rb +14 -0
  21. data/lib/volt/utils/volt_user_error.rb +4 -0
  22. data/lib/volt/volt/users.rb +2 -2
  23. data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
  24. data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
  25. data/spec/apps/kitchen_sink/app/main/views/main/first_last.html +13 -0
  26. data/spec/apps/kitchen_sink/app/main/views/main/main.html +2 -2
  27. data/spec/controllers/http_controller_spec.rb +2 -2
  28. data/spec/integration/bindings_spec.rb +154 -156
  29. data/spec/integration/cookies_spec.rb +28 -30
  30. data/spec/integration/first_last_spec.rb +14 -0
  31. data/spec/integration/http_endpoints_spec.rb +22 -24
  32. data/spec/integration/templates_spec.rb +7 -9
  33. data/spec/integration/user_spec.rb +49 -52
  34. data/spec/integration/yield_spec.rb +12 -14
  35. data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +2 -2
  36. data/spec/server/html_parser/view_parser_spec.rb +2 -2
  37. data/spec/server/rack/http_resource_spec.rb +2 -2
  38. data/spec/utils/task_argument_filtererer_spec.rb +17 -0
  39. data/templates/component/config/routes.rb +0 -5
  40. data/templates/component/controllers/server/.empty_directory +0 -0
  41. data/templates/component/lib/.empty_directory +0 -0
  42. data/templates/component_specs/controllers/server/.empty_directory +0 -0
  43. data/templates/component_specs/integration/.empty_directory +0 -0
  44. data/templates/component_specs/models/.empty_directory +0 -0
  45. data/templates/component_specs/tasks/.empty_directory +0 -0
  46. data/templates/controller/http_controller.rb.tt +1 -1
  47. data/templates/controller/http_controller_spec.rb.tt +5 -0
  48. data/templates/controller/model_controller.rb.tt +1 -1
  49. data/templates/controller/model_controller_spec.rb.tt +5 -0
  50. data/templates/model/model.rb.tt +1 -1
  51. data/templates/model/model_spec.rb.tt +5 -0
  52. data/templates/newgem/app/newgem/controllers/server/.empty_directory +0 -0
  53. data/templates/newgem/app/newgem/lib/.empty_directory +0 -0
  54. data/templates/newgem/lib/newgem.rb.tt +1 -1
  55. data/templates/project/app/main/views/main/main.html.tt +2 -2
  56. data/templates/project/config/app.rb.tt +5 -0
  57. data/templates/project/spec/app/main/controllers/server/sample_http_controller_spec.rb +5 -0
  58. data/templates/project/spec/app/main/tasks/sample_task_spec.rb +5 -0
  59. data/templates/task/task.rb.tt +0 -1
  60. data/templates/task/task_spec.rb.tt +5 -0
  61. data/templates/view/index.html.tt +5 -0
  62. metadata +29 -6
  63. data/templates/view/view.rb.tt +0 -4
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'first, last', type: :feature, sauce: true do
4
+ # Currently failing, fixing
5
+ # it 'should render first with a number argument' do
6
+ # store._messages << {body: 'hey, sup?'}
7
+ # store._messages << {body: 'not much'}
8
+ # store._messages << {body: 'you?'}
9
+ # store._messages << {body: 'just being awesome?'}
10
+ # store._messages << {body: 'writing some specs'}
11
+ #
12
+ # visit '/first_last'
13
+ # end
14
+ end
@@ -1,29 +1,27 @@
1
- if ENV['BROWSER']
2
- require 'spec_helper'
1
+ require 'spec_helper'
3
2
 
4
- describe 'http endpoints', type: :feature, sauce: true do
5
- it 'should show the page' do
6
- visit '/simple_http'
7
- expect(page).to have_content('this is just some text')
8
- end
3
+ describe 'http endpoints', type: :feature, sauce: true do
4
+ it 'should show the page' do
5
+ visit '/simple_http'
6
+ expect(page).to have_content('this is just some text')
7
+ end
9
8
 
10
- it 'should have access to the store' do
11
- DataStore.new.drop_database
12
- $page.store._simple_http_tests << { name: 'hello' }
13
- visit '/simple_http/store'
14
- expect(page).to have_content('You had me at hello')
15
- DataStore.new.drop_database
16
- end
9
+ it 'should have access to the store' do
10
+ DataStore.new.drop_database
11
+ $page.store._simple_http_tests << { name: 'hello' }
12
+ visit '/simple_http/store'
13
+ expect(page).to have_content('You had me at hello')
14
+ DataStore.new.drop_database
15
+ end
17
16
 
18
- it 'should upload and store a file' do
19
- file = 'tmp/uploaded_file'
20
- FileUtils.rm(file) if File.exist?(file)
21
- visit '/upload'
22
- attach_file('file', __FILE__)
23
- find('#submit_file_upload').click
24
- expect(page).to have_content('successfully uploaded')
25
- expect(File.exist?(file)).to be(true)
26
- FileUtils.rm(file) if File.exist?(file)
27
- end
17
+ it 'should upload and store a file' do
18
+ file = 'tmp/uploaded_file'
19
+ FileUtils.rm(file) if File.exist?(file)
20
+ visit '/upload'
21
+ attach_file('file', __FILE__)
22
+ find('#submit_file_upload').click
23
+ expect(page).to have_content('successfully uploaded')
24
+ expect(File.exist?(file)).to be(true)
25
+ FileUtils.rm(file) if File.exist?(file)
28
26
  end
29
27
  end
@@ -1,14 +1,12 @@
1
- if ENV['BROWSER']
2
- require 'spec_helper'
1
+ require 'spec_helper'
3
2
 
4
- describe 'bindings test', type: :feature, sauce: true do
5
- it 'should change the title when changing pages' do
6
- visit '/'
3
+ describe 'bindings test', type: :feature, sauce: true do
4
+ it 'should change the title when changing pages' do
5
+ visit '/'
7
6
 
8
- expect(page).to have_title 'KitchenSink - KitchenSink'
9
- click_link 'Bindings'
7
+ expect(page).to have_title 'KitchenSink - KitchenSink'
8
+ click_link 'Bindings'
10
9
 
11
- expect(page).to have_title 'Bindings - KitchenSink'
12
- end
10
+ expect(page).to have_title 'Bindings - KitchenSink'
13
11
  end
14
12
  end
@@ -1,78 +1,75 @@
1
- if ENV['BROWSER']
2
- require 'spec_helper'
1
+ require 'spec_helper'
3
2
 
4
- describe 'user accounts', type: :feature, sauce: true do
5
- before(:each) do
6
- # Clear out db
7
- DataStore.new.drop_database
8
- end
3
+ describe 'user accounts', type: :feature, sauce: true do
4
+ before(:each) do
5
+ # Clear out db
6
+ DataStore.new.drop_database
7
+ end
9
8
 
10
- after(:each) do
11
- # Clear out db
12
- DataStore.new.drop_database
13
- end
9
+ after(:each) do
10
+ # Clear out db
11
+ DataStore.new.drop_database
12
+ end
14
13
 
15
- it 'should create an account' do
16
- visit '/'
14
+ it 'should create an account' do
15
+ visit '/'
17
16
 
18
- # sleep 300
17
+ # sleep 300
19
18
 
20
- click_link 'Login'
19
+ click_link 'Login'
21
20
 
22
- click_link 'Signup here'
21
+ click_link 'Signup here'
23
22
 
24
- fields = all(:css, 'form .form-control')
23
+ fields = all(:css, 'form .form-control')
25
24
 
26
- fields[0].set('test@test.com')
27
- fields[1].set('awes0mesEcRet')
28
- fields[2].set('Test Account 9550')
25
+ fields[0].set('test@test.com')
26
+ fields[1].set('awes0mesEcRet')
27
+ fields[2].set('Test Account 9550')
29
28
 
30
- click_button 'Signup'
29
+ click_button 'Signup'
31
30
 
32
- expect(page).to have_content('Test Account 9550')
33
- end
31
+ expect(page).to have_content('Test Account 9550')
32
+ end
34
33
 
35
- it 'should login and logout' do
36
- visit '/'
34
+ it 'should login and logout' do
35
+ visit '/'
37
36
 
38
- # Add the user
39
- store._users! << { email: 'test@test.com', password: 'awes0mesEcRet', name: 'Test Account 9550' }
37
+ # Add the user
38
+ store._users! << { email: 'test@test.com', password: 'awes0mesEcRet', name: 'Test Account 9550' }
40
39
 
41
- click_link 'Login'
40
+ click_link 'Login'
42
41
 
43
- fields = all(:css, 'form .form-control')
44
- fields[0].set('test@test.com')
45
- fields[1].set('awes0mesEcRet')
46
- click_button 'Login'
42
+ fields = all(:css, 'form .form-control')
43
+ fields[0].set('test@test.com')
44
+ fields[1].set('awes0mesEcRet')
45
+ click_button 'Login'
47
46
 
48
- expect(page).to have_content('Test Account 9550')
47
+ expect(page).to have_content('Test Account 9550')
49
48
 
50
- # Click the logout link
51
- click_link 'Test Account 9550'
52
- click_link 'Logout'
49
+ # Click the logout link
50
+ click_link 'Test Account 9550'
51
+ click_link 'Logout'
53
52
 
54
- expect(page).to_not have_content('Test Account 9550')
55
- end
53
+ expect(page).to_not have_content('Test Account 9550')
54
+ end
56
55
 
57
- it 'should fail to create an account without a valid email and password' do
58
- visit '/'
56
+ it 'should fail to create an account without a valid email and password' do
57
+ visit '/'
59
58
 
60
- click_link 'Login'
61
- click_link 'Signup here'
59
+ click_link 'Login'
60
+ click_link 'Signup here'
62
61
 
63
- expect(page).to_not have_content('must be at least 8 characters')
62
+ expect(page).to_not have_content('must be at least 8 characters')
64
63
 
65
- fields = all(:css, 'form .form-control')
64
+ fields = all(:css, 'form .form-control')
66
65
 
67
- fields[0].set('test')
68
- fields[1].set('awe')
69
- fields[2].set('Tes')
66
+ fields[0].set('test')
67
+ fields[1].set('awe')
68
+ fields[2].set('Tes')
70
69
 
71
- # some capybara drivers don't trigger blur correctly
72
- page.execute_script("$('.form-control').blur()")
70
+ # some capybara drivers don't trigger blur correctly
71
+ page.execute_script("$('.form-control').blur()")
73
72
 
74
- expect(page).to have_content('must be at least 8 characters')
75
- end
73
+ expect(page).to have_content('must be at least 8 characters')
76
74
  end
77
-
78
75
  end
@@ -1,18 +1,16 @@
1
- if ENV['BROWSER']
2
- require 'spec_helper'
1
+ require 'spec_helper'
3
2
 
4
- describe 'yield binding', type: :feature, sauce: true do
5
- before do
6
- visit '/yield'
7
- end
3
+ describe 'yield binding', type: :feature, sauce: true do
4
+ before do
5
+ visit '/yield'
6
+ end
8
7
 
9
- it 'should render the yielded content multiple times' do
10
- expect(page).to have_content("My yielded content 1")
11
- expect(page).to have_content("My yielded content 2")
12
- end
8
+ it 'should render the yielded content multiple times' do
9
+ expect(page).to have_content("My yielded content 1")
10
+ expect(page).to have_content("My yielded content 2")
11
+ end
13
12
 
14
- it 'should render the content from the tag\'s controller when yielding' do
15
- expect(page).to have_content('This is my content')
16
- end
13
+ it 'should render the content from the tag\'s controller when yielding' do
14
+ expect(page).to have_content('This is my content')
17
15
  end
18
- end
16
+ end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'volt/page/bindings/template_binding'
2
+ require 'volt/page/bindings/view_binding'
3
3
 
4
4
  # Setup page stub
5
5
 
@@ -7,7 +7,7 @@ class Volt::Page
7
7
  attr_accessor :templates
8
8
  end
9
9
 
10
- describe Volt::TemplateBinding do
10
+ describe Volt::ViewBinding do
11
11
  before do
12
12
  @page = double('volt/page')
13
13
  expect(@page).to receive(:templates).at_least(1).times { @templates }
@@ -164,7 +164,7 @@ describe Volt::ViewParser do
164
164
 
165
165
  it 'should parse a template' do
166
166
  html = <<-END
167
- {{ template "/home/temp/path" }}
167
+ {{ view "/home/temp/path" }}
168
168
  END
169
169
 
170
170
  view = Volt::ViewParser.new(html, 'main/main/main')
@@ -173,7 +173,7 @@ describe Volt::ViewParser do
173
173
  'html' => " <!-- $0 --><!-- $/0 -->\n",
174
174
  'bindings' => {
175
175
  0 => [
176
- "lambda { |__p, __t, __c, __id| Volt::TemplateBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
176
+ "lambda { |__p, __t, __c, __id| Volt::ViewBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
177
177
  ]
178
178
  }
179
179
  })
@@ -19,8 +19,8 @@ if RUBY_PLATFORM != 'opal'
19
19
  end
20
20
 
21
21
  def show
22
- render text: "show with id #{params[:stuff_id]} " \
23
- "and #{params[:test]} called"
22
+ render text: "show with id #{params._stuff_id} " \
23
+ "and #{params._test} called"
24
24
  end
25
25
  end
26
26
 
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ if RUBY_PLATFORM != 'opal'
4
+ describe TaskArgumentFilterer do
5
+ it 'should filter arguments' do
6
+ filtered_args = TaskArgumentFilterer.new({login: 'jim@jim.com', password: 'some password no one should see'}).run
7
+
8
+ expect(filtered_args).to eq({:login=>"jim@jim.com", :password=>"[FILTERED]"})
9
+ end
10
+
11
+ it 'should filter in nested args' do
12
+ filtered_args = TaskArgumentFilterer.new([:login, {login: 'jim@jim.com', password: 'some password'}]).run
13
+
14
+ expect(filtered_args).to eq([:login, {:login=>"jim@jim.com", :password=>"[FILTERED]"}])
15
+ end
16
+ end
17
+ end
@@ -1,6 +1 @@
1
1
  # See https://github.com/voltrb/volt#routes for more info on routes
2
-
3
- client '/about', action: 'about'
4
-
5
- # The main route, this should be last. It will match any params not previously matched.
6
- client '/', {}
File without changes
File without changes
File without changes
@@ -2,4 +2,4 @@ module <%= config[:component_module] %>
2
2
  class <%= config[:http_controller_name] %> < Volt::HttpController
3
3
 
4
4
  end
5
- end
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= config[:component_module] %>::<%= config[:http_controller_name] %>, type: :http_controller do
4
+ # Specs here
5
+ end
@@ -2,4 +2,4 @@ module <%= config[:component_module] %>
2
2
  class <%= config[:model_controller_name] %> < Volt::ModelController
3
3
 
4
4
  end
5
- end
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe '<%= config[:name] %>', type: :feature do
4
+ # Specs here
5
+ end
@@ -1,3 +1,3 @@
1
1
  class <%= config[:model_name] %> < Volt::Model
2
2
 
3
- end
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= config[:model_name] %> do
4
+ # Specs here
5
+ end
File without changes
@@ -1,5 +1,5 @@
1
1
  <%- config[:constant_array].each_with_index do |c,i| -%>
2
- <%= ' '*i %><% if c == 'Volt' %>module<% else %>class<% end %> <%= c %>
2
+ <%= ' '*i %>module <%= c %>
3
3
  <%- end -%>
4
4
  <%= ' '*config[:constant_array].size %># Your code goes here...
5
5
  <%- (config[:constant_array].size-1).downto(0) do |i| -%>
@@ -1,5 +1,5 @@
1
1
  <:Title>
2
- {{ template main_path, "title", {controller_group: 'main'} }}
2
+ {{ view main_path, "title", {controller_group: 'main'} }}
3
3
 
4
4
  <:Body>
5
5
  <div class="container">
@@ -14,7 +14,7 @@
14
14
 
15
15
  <:volt:notices />
16
16
 
17
- {{ template main_path, 'body', {controller_group: 'main'} }}
17
+ {{ view main_path, 'body', {controller_group: 'main'} }}
18
18
 
19
19
  <div class="footer">
20
20
  <p>&copy; Company {{ Time.now.year }}</p>
@@ -12,6 +12,11 @@ Volt.configure do |config|
12
12
  #
13
13
  config.app_secret = '<%= SecureRandom.urlsafe_base64(50) %>'
14
14
 
15
+ # Data updates from the client come in via Tasks. The task dispatcher logs all calls to tasks.
16
+ # By default hashes in the arguments can be filtered based on keys. So any hash with a key of
17
+ # password will be filtered. You can add more fields to filter below:
18
+ config.filter_keys = [:password]
19
+
15
20
  # Database config all start with db_ and can be set either in the config
16
21
  # file or with an environment variable (DB_NAME for example).
17
22
 
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'sample http controller test', type: :http_controller do
4
+ # Specs here
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe "sample task", type: :task do
4
+ # Specs here
5
+ end
@@ -1,4 +1,3 @@
1
1
  class <%= config[:task_name] %> < Volt::Task
2
2
 
3
3
  end
4
-