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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -7
- data/VERSION +1 -1
- data/app/volt/tasks/user_tasks.rb +7 -2
- data/lib/volt.rb +1 -0
- data/lib/volt/cli/generate.rb +28 -10
- data/lib/volt/controllers/http_controller.rb +1 -1
- data/lib/volt/extra_core/logger.rb +14 -11
- data/lib/volt/models/persistors/query/query_listener.rb +7 -1
- data/lib/volt/page/bindings/component_binding.rb +2 -2
- data/lib/volt/page/bindings/{template_binding.rb → view_binding.rb} +3 -3
- data/lib/volt/page/bindings/{template_binding → view_binding}/grouped_controllers.rb +0 -0
- data/lib/volt/page/bindings/{template_binding → view_binding}/view_lookup_for_path.rb +0 -0
- data/lib/volt/page/page.rb +1 -1
- data/lib/volt/server/html_parser/view_scope.rb +4 -1
- data/lib/volt/server/rack/component_paths.rb +1 -1
- data/lib/volt/spec/setup.rb +10 -2
- data/lib/volt/tasks/dispatcher.rb +10 -3
- data/lib/volt/utils/logging/task_argument_filterer.rb +42 -0
- data/lib/volt/utils/logging/task_logger.rb +14 -0
- data/lib/volt/utils/volt_user_error.rb +4 -0
- data/lib/volt/volt/users.rb +2 -2
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
- data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/views/main/first_last.html +13 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +2 -2
- data/spec/controllers/http_controller_spec.rb +2 -2
- data/spec/integration/bindings_spec.rb +154 -156
- data/spec/integration/cookies_spec.rb +28 -30
- data/spec/integration/first_last_spec.rb +14 -0
- data/spec/integration/http_endpoints_spec.rb +22 -24
- data/spec/integration/templates_spec.rb +7 -9
- data/spec/integration/user_spec.rb +49 -52
- data/spec/integration/yield_spec.rb +12 -14
- data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +2 -2
- data/spec/server/html_parser/view_parser_spec.rb +2 -2
- data/spec/server/rack/http_resource_spec.rb +2 -2
- data/spec/utils/task_argument_filtererer_spec.rb +17 -0
- data/templates/component/config/routes.rb +0 -5
- data/templates/component/controllers/server/.empty_directory +0 -0
- data/templates/component/lib/.empty_directory +0 -0
- data/templates/component_specs/controllers/server/.empty_directory +0 -0
- data/templates/component_specs/integration/.empty_directory +0 -0
- data/templates/component_specs/models/.empty_directory +0 -0
- data/templates/component_specs/tasks/.empty_directory +0 -0
- data/templates/controller/http_controller.rb.tt +1 -1
- data/templates/controller/http_controller_spec.rb.tt +5 -0
- data/templates/controller/model_controller.rb.tt +1 -1
- data/templates/controller/model_controller_spec.rb.tt +5 -0
- data/templates/model/model.rb.tt +1 -1
- data/templates/model/model_spec.rb.tt +5 -0
- data/templates/newgem/app/newgem/controllers/server/.empty_directory +0 -0
- data/templates/newgem/app/newgem/lib/.empty_directory +0 -0
- data/templates/newgem/lib/newgem.rb.tt +1 -1
- data/templates/project/app/main/views/main/main.html.tt +2 -2
- data/templates/project/config/app.rb.tt +5 -0
- data/templates/project/spec/app/main/controllers/server/sample_http_controller_spec.rb +5 -0
- data/templates/project/spec/app/main/tasks/sample_task_spec.rb +5 -0
- data/templates/task/task.rb.tt +0 -1
- data/templates/task/task_spec.rb.tt +5 -0
- data/templates/view/index.html.tt +5 -0
- metadata +29 -6
- data/templates/view/view.rb.tt +0 -4
data/lib/volt/volt/users.rb
CHANGED
@@ -24,7 +24,7 @@ module Volt
|
|
24
24
|
# TODO: We could cache the digest generation for even faster comparisons
|
25
25
|
if hash != Digest::SHA256.hexdigest("#{Volt.config.app_secret}::#{user_id}")
|
26
26
|
# user id has been tampered with, reject
|
27
|
-
fail 'user id or hash
|
27
|
+
fail VoltUserError, 'user id or hash is incorrectly signed. It may have been tampered with, the app secret changed, or generated in a different app.'
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -80,7 +80,7 @@ module Volt
|
|
80
80
|
|
81
81
|
# Login the user, return a promise for success
|
82
82
|
def login(username, password)
|
83
|
-
UserTasks.login(username, password).then do |result|
|
83
|
+
UserTasks.login({login: username, password: password}).then do |result|
|
84
84
|
# Assign the user_id cookie for the user
|
85
85
|
$page.cookies._user_id = result
|
86
86
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<:Title>
|
2
|
-
{{
|
2
|
+
{{ view main_path, 'title', {controller_group: 'main'} }} - KitchenSink
|
3
3
|
|
4
4
|
<:Body>
|
5
5
|
<div class="container">
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
<:volt:notices />
|
21
21
|
|
22
|
-
{{
|
22
|
+
{{ view main_path, 'body', {controller_group: 'main'} }}
|
23
23
|
|
24
24
|
<div class="footer">
|
25
25
|
<p>© Company {{ Time.now.year }}</p>
|
@@ -61,8 +61,8 @@ if RUBY_PLATFORM != 'opal'
|
|
61
61
|
controller = TestHttpController.new(
|
62
62
|
{ another: 'params', 'and_a' => 'string' }, request)
|
63
63
|
expect(controller.params.size).to eq(4)
|
64
|
-
expect(controller.params
|
65
|
-
expect(controller.params
|
64
|
+
expect(controller.params._and_a).to eq('string')
|
65
|
+
expect(controller.params._this).to eq('is_a')
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should perform the correct action' do
|
@@ -1,206 +1,204 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe 'bindings test', type: :feature, sauce: true do
|
4
|
+
it 'should load the page' do
|
5
|
+
visit '/'
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
expect(page).to have_content('Kitchen Sink')
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
describe 'text/fields' do
|
11
|
+
it 'should load the bindings page and update bindings' do
|
12
|
+
visit '/'
|
14
13
|
|
15
|
-
|
14
|
+
click_link 'Bindings'
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
# Fill in one field and see if it updates the rest
|
17
|
+
fill_in('pageName1', with: 'Page bindings')
|
18
|
+
expect(find('#pageName1').value).to eq('Page bindings')
|
19
|
+
expect(find('#pageName2').value).to eq('Page bindings')
|
20
|
+
expect(find('#pageName3')).to have_content('Page bindings')
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
fill_in('pageName2', with: 'Update everywhere')
|
23
|
+
expect(find('#pageName1').value).to eq('Update everywhere')
|
24
|
+
expect(find('#pageName2').value).to eq('Update everywhere')
|
25
|
+
expect(find('#pageName3')).to have_content('Update everywhere')
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
it 'should update params bindings and the url' do
|
29
|
+
visit '/'
|
31
30
|
|
32
|
-
|
31
|
+
click_link 'Bindings'
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
# phantom does not support the html5 history api
|
34
|
+
# TODO: We could probably polyfill this in phantom
|
35
|
+
if ENV['BROWSER'] != 'phantom'
|
36
|
+
expect(current_path).to eq('/bindings')
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
# Fill in one field and see if it updates the rest
|
40
|
+
fill_in('paramsName1', with: 'Params bindings')
|
41
|
+
expect(find('#paramsName1').value).to eq('Params bindings')
|
42
|
+
expect(find('#paramsName2').value).to eq('Params bindings')
|
43
|
+
expect(find('#paramsName3')).to have_content('Params bindings')
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
fill_in('paramsName2', with: 'Update everywhere')
|
46
|
+
expect(find('#paramsName1').value).to eq('Update everywhere')
|
47
|
+
expect(find('#paramsName2').value).to eq('Update everywhere')
|
48
|
+
expect(find('#paramsName3')).to have_content('Update everywhere')
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
end
|
50
|
+
if ENV['BROWSER'] != 'phantom'
|
51
|
+
expect(current_url).to match(/\/bindings[?]name[=]Update%20everywhere$/)
|
54
52
|
end
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
it 'should update the url and fields when bound to a param in the route' do
|
56
|
+
visit '/'
|
58
57
|
|
59
|
-
|
58
|
+
click_link 'Bindings'
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
# phantom does not support the html5 history api
|
61
|
+
# TODO: We could probably polyfill this in phantom
|
62
|
+
if ENV['BROWSER'] != 'phantom'
|
63
|
+
expect(current_path).to eq('/bindings')
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
# Fill in one field and see if it updates the rest
|
67
|
+
fill_in('routesName1', with: 'Routes bindings')
|
68
|
+
expect(find('#routesName1').value).to eq('Routes bindings')
|
69
|
+
expect(find('#routesName2').value).to eq('Routes bindings')
|
70
|
+
expect(find('#routesName3')).to have_content('Routes bindings')
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
fill_in('routesName2', with: 'bound_url')
|
73
|
+
expect(find('#routesName1').value).to eq('bound_url')
|
74
|
+
expect(find('#routesName2').value).to eq('bound_url')
|
75
|
+
expect(find('#routesName3')).to have_content('bound_url')
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
77
|
+
if ENV['BROWSER'] != 'phantom'
|
78
|
+
expect(current_path).to eq('/bindings/bound_url')
|
81
79
|
end
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
it 'should go from a url and query to params' do
|
83
|
+
visit '/bindings/testing?name=cool'
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
expect(find('#paramsName3')).to have_content('cool')
|
86
|
+
expect(find('#routesName3')).to have_content('testing')
|
87
|
+
end
|
89
88
|
|
90
|
-
|
91
|
-
|
89
|
+
it 'should load the bindings page and update bindings' do
|
90
|
+
visit '/'
|
92
91
|
|
93
|
-
|
92
|
+
click_link 'Bindings'
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
# Fill in one field and see if it updates the rest
|
95
|
+
fill_in('textareaName1', with: 'Page bindings')
|
96
|
+
expect(find('#textareaName1').value).to eq('Page bindings')
|
97
|
+
expect(find('#textareaName2').value).to eq('Page bindings')
|
98
|
+
expect(find('#textareaName3')).to have_content('Page bindings')
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
it 'should update local_store bindings' do
|
108
|
-
visit '/'
|
100
|
+
fill_in('textareaName2', with: 'Update everywhere')
|
101
|
+
expect(find('#textareaName1').value).to eq('Update everywhere')
|
102
|
+
expect(find('#textareaName2').value).to eq('Update everywhere')
|
103
|
+
expect(find('#textareaName3')).to have_content('Update everywhere')
|
104
|
+
end
|
109
105
|
|
110
|
-
|
106
|
+
it 'should update local_store bindings' do
|
107
|
+
visit '/'
|
111
108
|
|
112
|
-
|
113
|
-
fill_in('localstoreName1', with: 'Page bindings')
|
114
|
-
expect(find('#localstoreName1').value).to eq('Page bindings')
|
115
|
-
expect(find('#localstoreName2').value).to eq('Page bindings')
|
116
|
-
expect(find('#localstoreName3')).to have_content('Page bindings')
|
109
|
+
click_link 'Bindings'
|
117
110
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
111
|
+
# Fill in one field and see if it updates the rest
|
112
|
+
fill_in('localstoreName1', with: 'Page bindings')
|
113
|
+
expect(find('#localstoreName1').value).to eq('Page bindings')
|
114
|
+
expect(find('#localstoreName2').value).to eq('Page bindings')
|
115
|
+
expect(find('#localstoreName3')).to have_content('Page bindings')
|
123
116
|
|
124
|
-
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
# within '#pageSelect1' do
|
130
|
-
# find("option[value='two']").click
|
131
|
-
# end
|
132
|
-
#
|
133
|
-
# # Fill in one field and see if it updates the rest
|
134
|
-
# expect(find('#pageSelect1').value).to eq('two')
|
135
|
-
# expect(find('#pageSelect2').value).to eq('two')
|
136
|
-
# expect(find('#pageSelect3')).to have_content('two')
|
137
|
-
#
|
138
|
-
# # Fill in one field and see if it updates the rest
|
139
|
-
# fill_in('pageSelect2', :with => 'three')
|
140
|
-
# expect(find('#pageSelect1').value).to eq('three')
|
141
|
-
# expect(find('#pageSelect2').value).to eq('three')
|
142
|
-
# expect(find('#pageSelect3')).to have_content('three')
|
143
|
-
# end
|
117
|
+
fill_in('localstoreName2', with: 'Update everywhere')
|
118
|
+
expect(find('#localstoreName1').value).to eq('Update everywhere')
|
119
|
+
expect(find('#localstoreName2').value).to eq('Update everywhere')
|
120
|
+
expect(find('#localstoreName3')).to have_content('Update everywhere')
|
144
121
|
end
|
145
122
|
|
146
|
-
|
147
|
-
|
148
|
-
|
123
|
+
# it 'should update local_store bindings' do
|
124
|
+
# visit '/'
|
125
|
+
#
|
126
|
+
# click_link 'Bindings'
|
127
|
+
#
|
128
|
+
# within '#pageSelect1' do
|
129
|
+
# find("option[value='two']").click
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# # Fill in one field and see if it updates the rest
|
133
|
+
# expect(find('#pageSelect1').value).to eq('two')
|
134
|
+
# expect(find('#pageSelect2').value).to eq('two')
|
135
|
+
# expect(find('#pageSelect3')).to have_content('two')
|
136
|
+
#
|
137
|
+
# # Fill in one field and see if it updates the rest
|
138
|
+
# fill_in('pageSelect2', :with => 'three')
|
139
|
+
# expect(find('#pageSelect1').value).to eq('three')
|
140
|
+
# expect(find('#pageSelect2').value).to eq('three')
|
141
|
+
# expect(find('#pageSelect3')).to have_content('three')
|
142
|
+
# end
|
143
|
+
end
|
149
144
|
|
150
|
-
|
145
|
+
describe 'check boxes' do
|
146
|
+
it 'should load the bindings page and update checkboxes' do
|
147
|
+
visit '/'
|
151
148
|
|
152
|
-
|
153
|
-
# Fill in one field and see if it updates the rest
|
154
|
-
check('pageCheck1')
|
155
|
-
expect(find('#pageCheck1')).to be_checked
|
156
|
-
expect(find('#pageCheck2')).to be_checked
|
157
|
-
expect(find('#pageCheck3')).to have_content('true')
|
149
|
+
click_link 'Bindings'
|
158
150
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
151
|
+
expect(find('#pageCheck3')).to have_content('')
|
152
|
+
# Fill in one field and see if it updates the rest
|
153
|
+
check('pageCheck1')
|
154
|
+
expect(find('#pageCheck1')).to be_checked
|
155
|
+
expect(find('#pageCheck2')).to be_checked
|
156
|
+
expect(find('#pageCheck3')).to have_content('true')
|
164
157
|
|
165
|
-
|
166
|
-
|
158
|
+
uncheck('pageCheck1')
|
159
|
+
expect(find('#pageCheck1')).to_not be_checked
|
160
|
+
expect(find('#pageCheck2')).to_not be_checked
|
161
|
+
expect(find('#pageCheck3')).to have_content('')
|
162
|
+
end
|
167
163
|
|
168
|
-
|
164
|
+
it 'should load the bindings page and update checkboxes bound to params' do
|
165
|
+
visit '/'
|
166
|
+
|
167
|
+
click_link 'Bindings'
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
if ENV['BROWSER'] != 'phantom'
|
170
|
+
expect(current_path).to eq('/bindings')
|
171
|
+
end
|
173
172
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
173
|
+
expect(find('#paramsCheck3')).to have_content('')
|
174
|
+
# Fill in one field and see if it updates the rest
|
175
|
+
check('paramsCheck1')
|
176
|
+
expect(find('#paramsCheck1')).to be_checked
|
177
|
+
expect(find('#paramsCheck2')).to be_checked
|
178
|
+
expect(find('#paramsCheck3')).to have_content('true')
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
if ENV['BROWSER'] != 'phantom'
|
181
|
+
expect(current_url).to match(/\/bindings[?]check[=]true$/)
|
182
|
+
end
|
184
183
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
184
|
+
uncheck('paramsCheck1')
|
185
|
+
expect(find('#paramsCheck1')).to_not be_checked
|
186
|
+
expect(find('#paramsCheck2')).to_not be_checked
|
187
|
+
expect(find('#paramsCheck3')).to have_content('')
|
189
188
|
|
190
|
-
|
191
|
-
|
192
|
-
end
|
189
|
+
if ENV['BROWSER'] != 'phantom'
|
190
|
+
expect(current_url).to match(/\/bindings[?]check[=]false$/)
|
193
191
|
end
|
194
192
|
end
|
193
|
+
end
|
195
194
|
|
196
|
-
|
197
|
-
|
198
|
-
|
195
|
+
describe 'content escaping' do
|
196
|
+
it 'should escape in a tripple stash' do
|
197
|
+
visit '/'
|
199
198
|
|
200
|
-
|
199
|
+
click_link 'Bindings'
|
201
200
|
|
202
|
-
|
203
|
-
end
|
201
|
+
expect(find('#escapeContent')).to have_content('this is {{escaped}}')
|
204
202
|
end
|
205
203
|
end
|
206
204
|
end
|
@@ -1,47 +1,45 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
describe 'cookies collection', type: :feature, sauce: true do
|
4
|
+
if ENV['BROWSER'] != 'phantom'
|
5
|
+
# TODO: fails in phantom for some reason
|
6
|
+
it 'should add' do
|
7
|
+
visit '/'
|
9
8
|
|
10
|
-
|
9
|
+
click_link 'Cookies'
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
fill_in('cookieName', with: 'one')
|
12
|
+
fill_in('cookieValue', with: 'one')
|
13
|
+
click_button 'Add Cookie'
|
15
14
|
|
16
|
-
|
15
|
+
expect(page).to have_content('one: one')
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
# Reload the page
|
18
|
+
page.evaluate_script('document.location.reload()')
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
20
|
+
# Check again
|
21
|
+
expect(page).to have_content('one: one')
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
it 'should delete cookies' do
|
26
|
+
visit '/'
|
28
27
|
|
29
|
-
|
28
|
+
click_link 'Cookies'
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
fill_in('cookieName', with: 'two')
|
31
|
+
fill_in('cookieValue', with: 'two')
|
32
|
+
click_button 'Add Cookie'
|
34
33
|
|
35
|
-
|
34
|
+
expect(page).to have_content('two: two')
|
36
35
|
|
37
|
-
|
36
|
+
find('.cookieDelete').click
|
38
37
|
|
39
|
-
|
38
|
+
expect(page).to_not have_content('two: two')
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
# Reload the page
|
41
|
+
page.evaluate_script('document.location.reload()')
|
43
42
|
|
44
|
-
|
45
|
-
end
|
43
|
+
expect(page).to_not have_content('two: two')
|
46
44
|
end
|
47
45
|
end
|