rad_core 0.2.6 → 0.2.7
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.
- data/Rakefile +2 -2
- data/bin/rad +20 -25
- data/lib/components/config.rb +1 -1
- data/lib/components/configurators.rb +2 -2
- data/lib/components/controller.rb +2 -2
- data/lib/components/conveyors.rb +2 -2
- data/lib/components/environment.rb +1 -1
- data/lib/components/environment.yml +28 -28
- data/lib/components/flash.rb +1 -1
- data/lib/components/html.rb +1 -1
- data/lib/components/http.rb +1 -1
- data/lib/components/http.yml +1 -1
- data/lib/components/logger.rb +2 -2
- data/lib/components/mailer.rb +2 -2
- data/lib/components/remote.rb +1 -1
- data/lib/components/router.rb +3 -3
- data/lib/components/template.rb +2 -2
- data/lib/components/web.rb +3 -3
- data/lib/rad.rb +1 -1
- data/lib/rad/_support/active_support.rb +7 -7
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +8 -8
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +4 -4
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +5 -5
- data/lib/rad/_support/active_support/time.rb +2 -2
- data/lib/rad/_support/addressable.rb +6 -6
- data/lib/rad/_support/class_loader.rb +1 -1
- data/lib/rad/_support/extensions.rb +5 -5
- data/lib/rad/_support/filters.rb +13 -13
- data/lib/rad/_support/hacks_and_fixes.rb +5 -5
- data/lib/rad/_support/mime.rb +4 -4
- data/lib/rad/_support/module.rb +11 -11
- data/lib/rad/_support/require.rb +5 -5
- data/lib/rad/_support/rson.rb +4 -4
- data/lib/rad/_support/string.rb +9 -9
- data/lib/rad/cli/helper.rb +5 -5
- data/lib/rad/configurators/_require.rb +2 -2
- data/lib/rad/configurators/abstract.rb +5 -5
- data/lib/rad/configurators/web.rb +8 -8
- data/lib/rad/controller/_abstract.rb +15 -14
- data/lib/rad/controller/_abstract/miscellaneous.rb +5 -5
- data/lib/rad/controller/_abstract/render.rb +40 -40
- data/lib/rad/controller/_abstract/responder.rb +1 -1
- data/lib/rad/controller/_context.rb +1 -1
- data/lib/rad/controller/_http.rb +11 -11
- data/lib/rad/controller/_require.rb +6 -6
- data/lib/rad/controller/processors/controller_caller.rb +3 -3
- data/lib/rad/controller/processors/controller_error_handling.rb +14 -14
- data/lib/rad/controller/processors/controller_logger.rb +1 -1
- data/lib/rad/conveyors/_conveyor.rb +9 -9
- data/lib/rad/conveyors/_conveyors.rb +4 -4
- data/lib/rad/conveyors/_params.rb +5 -5
- data/lib/rad/conveyors/_processor.rb +2 -2
- data/lib/rad/conveyors/_workspace.rb +5 -5
- data/lib/rad/conveyors/processors/conveyor_logger.rb +3 -3
- data/lib/rad/environment/_config.rb +4 -4
- data/lib/rad/environment/_environment.rb +10 -10
- data/lib/rad/environment/_files_helper.rb +5 -5
- data/lib/rad/environment/_logger.rb +9 -9
- data/lib/rad/environment/_require.rb +4 -4
- data/lib/rad/gems.rb +14 -14
- data/lib/rad/html/_flash.rb +5 -5
- data/lib/rad/html/_helpers/basic_html_helper.rb +12 -12
- data/lib/rad/html/_helpers/form_helper.rb +19 -19
- data/lib/rad/html/_helpers/javascript_helper.rb +6 -6
- data/lib/rad/html/_helpers/model_helper.rb +17 -17
- data/lib/rad/html/_require.rb +1 -1
- data/lib/rad/html/processors/prepare_flash.rb +3 -3
- data/lib/rad/html/processors/scoped_params.rb +4 -4
- data/lib/rad/http/_http.rb +4 -4
- data/lib/rad/http/_http_adapter.rb +5 -5
- data/lib/rad/http/_request.rb +11 -11
- data/lib/rad/http/_require.rb +8 -8
- data/lib/rad/http/_response.rb +5 -5
- data/lib/rad/http/_support/rack/fixes.rb +3 -3
- data/lib/rad/http/_support/rack/rack_adapter.rb +5 -5
- data/lib/rad/http/processors/evaluate_format.rb +4 -4
- data/lib/rad/http/processors/http_logger.rb +3 -3
- data/lib/rad/http/processors/http_writer.rb +7 -7
- data/lib/rad/http/processors/prepare_params.rb +5 -5
- data/lib/rad/mailer/_letter.rb +1 -1
- data/lib/rad/mailer/_mailer.rb +1 -1
- data/lib/rad/mailer/_mailer_controller.rb +6 -6
- data/lib/rad/mailer/_require.rb +1 -1
- data/lib/rad/mailer/processors/letter_builder.rb +6 -6
- data/lib/rad/profiles/mailer.rb +2 -2
- data/lib/rad/profiles/web.rb +13 -13
- data/lib/rad/remote/processors/remote_caller.rb +10 -10
- data/lib/rad/remote/processors/remote_logger.rb +1 -1
- data/lib/rad/router/_abstract_router.rb +9 -9
- data/lib/rad/router/_alias_router.rb +34 -34
- data/lib/rad/router/_basic_router.rb +12 -12
- data/lib/rad/router/_configurator.rb +6 -6
- data/lib/rad/router/_core_routing_helper.rb +4 -4
- data/lib/rad/router/_object_router.rb +45 -45
- data/lib/rad/router/_require.rb +8 -8
- data/lib/rad/router/_restful_router.rb +25 -25
- data/lib/rad/router/_router.rb +78 -78
- data/lib/rad/router/_simple_router.rb +5 -5
- data/lib/rad/router/processors/router.rb +6 -6
- data/lib/rad/spec/controller.rb +9 -9
- data/lib/rad/spec/environment.rb +7 -7
- data/lib/rad/spec/http.rb +2 -2
- data/lib/rad/spec/http_controller.rb +22 -22
- data/lib/rad/spec/mailer.rb +4 -4
- data/lib/rad/spec/remote.rb +1 -1
- data/lib/rad/spec/router.rb +4 -4
- data/lib/rad/spec/template.rb +2 -2
- data/lib/rad/tasks.rb +2 -2
- data/lib/rad/template/_context.rb +15 -15
- data/lib/rad/template/_relative_path_resolver.rb +1 -1
- data/lib/rad/template/_support/tilt.rb +17 -17
- data/lib/rad/template/_support/tilt_fixes.rb +3 -3
- data/lib/rad/template/_template.rb +47 -47
- data/lib/rad/web/_ajax_helper.rb +4 -4
- data/lib/rad/web/_controller_miscellaneous_helper.rb +5 -5
- data/lib/rad/web/_ensure_no_www.rb +5 -5
- data/lib/rad/web/_protect_from_forgery.rb +18 -18
- data/lib/rad/web/_require.rb +7 -7
- data/lib/rad/web/_router/abstract_routing_helper.rb +4 -4
- data/lib/rad/web/_router/controller_routing_helper.rb +15 -15
- data/lib/rad/web/_router/view_routing_helper.rb +12 -12
- data/readme.md +5 -5
- data/spec/controller/abstract_spec.rb +29 -29
- data/spec/controller/context_spec.rb +32 -32
- data/spec/controller/error_handling_spec.rb +31 -31
- data/spec/controller/helper_spec.rb +13 -13
- data/spec/controller/http_spec.rb +32 -32
- data/spec/controller/render_spec.rb +59 -59
- data/spec/conveyors/conveyors_spec.rb +32 -32
- data/spec/environment/config_spec.rb +6 -6
- data/spec/environment/environment_spec.rb +7 -7
- data/spec/environment/minimal_app_spec.rb +4 -4
- data/spec/environment/standard_app_spec.rb +10 -10
- data/spec/html/basic_html_helper_spec.rb +6 -6
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +4 -4
- data/spec/html/model_helper_spec.rb +12 -12
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +3 -3
- data/spec/http/http_spec.rb +9 -9
- data/spec/http/miscellaneous_spec.rb +2 -2
- data/spec/mailer/mail_controller_spec.rb +23 -23
- data/spec/remote/remote_spec.rb +26 -26
- data/spec/router/alias_router_spec.rb +22 -22
- data/spec/router/basic_router_spec.rb +8 -8
- data/spec/router/configurator_spec.rb +4 -4
- data/spec/router/integration_spec.rb +17 -17
- data/spec/router/object_router_spec.rb +47 -47
- data/spec/router/persistent_params_spec.rb +18 -18
- data/spec/router/restful_router_spec.rb +39 -39
- data/spec/router/router_spec.rb +37 -37
- data/spec/router/routing_helper_spec.rb +18 -18
- data/spec/support/filters_spec.rb +11 -13
- data/spec/template/template_spec.rb +43 -45
- data/spec/template/template_spec/views/layout/content_for/content.erb +3 -1
- data/spec/template/template_spec/views/layout/content_for/layout.erb +1 -1
- data/spec/template/tilt_spec.rb +24 -24
- data/spec/web/basic_spec.rb +25 -25
- data/spec/web/controller_routing_helper_spec.rb +26 -26
- data/spec/web/flash_spec.rb +31 -31
- data/spec/web/protect_from_forgery_spec.rb +44 -44
- data/spec/web/spec_helper_spec.rb +16 -16
- data/spec/web/view_routing_helper_spec.rb +31 -31
- metadata +46 -49
- data/lib/rad/_support/callbacks.rb +0 -166
- data/lib/rad/_support/ruby_ext_with_active_support.rb +0 -4
- data/spec/support/callbacks_spec.rb +0 -157
|
@@ -4,32 +4,32 @@ require 'rad/spec/environment'
|
|
|
4
4
|
|
|
5
5
|
describe "Environment basic spec" do
|
|
6
6
|
with_load_path "#{spec_dir}/path1", "#{spec_dir}/path2"
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
before :all do
|
|
9
9
|
@path1, @path2 = "#{spec_dir}/path1", "#{spec_dir}/path2"
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
describe 'files' do
|
|
11
|
+
|
|
12
|
+
describe 'files' do
|
|
13
13
|
it "find_files?" do
|
|
14
14
|
environment.file_exist?('/some_folder/some_file').should be_true
|
|
15
15
|
environment.file_exist?('/file1').should be_true
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
it "find_file" do
|
|
19
19
|
lambda{environment.find_file('/some_folder/some_file')}.should raise_error(/Found multiple files/)
|
|
20
20
|
environment.find_file('/file1').should == "#{@path1}/file1"
|
|
21
21
|
lambda{environment.find_file('file1')}.should raise_error(AssertionError)
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
it "find_files" do
|
|
25
25
|
environment.find_files('/some_folder/some_file').sort.should == ["#{@path1}/some_folder/some_file", "#{@path2}/some_folder/some_file"]
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
it "find_files_by_pattern" do
|
|
29
29
|
environment.find_files_by_pattern('/*/some_file').sort.should == ["#{@path1}/some_folder/some_file", "#{@path2}/some_folder/some_file"]
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
describe 'config' do
|
|
34
34
|
it "smoke test" do
|
|
35
35
|
rad.config
|
|
@@ -2,21 +2,21 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
require 'rad'
|
|
4
4
|
|
|
5
|
-
describe "Minimal App" do
|
|
5
|
+
describe "Minimal App" do
|
|
6
6
|
# inject env: :environment
|
|
7
7
|
|
|
8
8
|
# with_micon
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
before :all do
|
|
11
11
|
load "#{spec_dir}/app.rb"
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
it "core components" do
|
|
15
15
|
rad.logger.should_not be_nil
|
|
16
16
|
rad.environment.should_not be_nil
|
|
17
17
|
rad.config.should_not be_nil
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
# it "application runtime_path" do
|
|
21
21
|
# environment.config.runtime_path?.should be_false
|
|
22
22
|
# end
|
|
@@ -3,34 +3,34 @@ require 'spec_helper'
|
|
|
3
3
|
require 'rad'
|
|
4
4
|
require 'rad/spec/environment'
|
|
5
5
|
|
|
6
|
-
describe "Environment basic spec" do
|
|
6
|
+
describe "Environment basic spec" do
|
|
7
7
|
the_spec_dir = with_tmp_spec_dir
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
with_load_path(
|
|
10
|
-
"#{the_spec_dir}/plugin_a/lib",
|
|
11
|
-
"#{the_spec_dir}/plugin_b/lib",
|
|
10
|
+
"#{the_spec_dir}/plugin_a/lib",
|
|
11
|
+
"#{the_spec_dir}/plugin_b/lib",
|
|
12
12
|
"#{the_spec_dir}/app/lib"
|
|
13
13
|
)
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
before do
|
|
16
16
|
rad.runtime_path = the_spec_dir, true
|
|
17
17
|
$spec_result = []
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
after :all do
|
|
21
21
|
rad.delete_all :custom_component
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
before do
|
|
25
25
|
load "app/init.rb"
|
|
26
|
-
end
|
|
27
|
-
|
|
26
|
+
end
|
|
27
|
+
|
|
28
28
|
it "core components" do
|
|
29
29
|
rad.logger.should_not be_nil
|
|
30
30
|
rad.environment.should_not be_nil
|
|
31
31
|
rad.config.should_not be_nil
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
it "loading order" do
|
|
35
35
|
rad.environment
|
|
36
36
|
rad.register(:custom_component){true}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
require 'html/spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "BasicHtmlHelper" do
|
|
4
|
-
before do
|
|
4
|
+
before do
|
|
5
5
|
@t = Rad::MockTemplateContext.new
|
|
6
|
-
@t.class_eval do
|
|
6
|
+
@t.class_eval do
|
|
7
7
|
def url_for *args
|
|
8
8
|
args.join(' ')
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
it "tag" do
|
|
14
14
|
@t.tag(:div, 'content', class: 'hidden').should == %(<div class="hidden">content</div>)
|
|
15
15
|
@t.tag(:div, class: 'hidden'){'content'}
|
|
16
16
|
@t.buffer.should == %(<div class="hidden">content</div>)
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
it "stylesheet_link_tag" do
|
|
20
20
|
@t.stylesheet_link_tag('/public/js/app.css').should == %(<link href="/public/js/app.css" media="screen" rel="stylesheet" type="text/css"></link>)
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
it "image_tag" do
|
|
24
24
|
@t.image_tag('face.png', width: 100).should == %(<img src="face.png" width="100"></img>)
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
describe "basic html tags" do
|
|
28
28
|
it "label" do
|
|
29
29
|
@t.label_tag('book', 'Book').should == %(<label for="book">Book</label>)
|
|
@@ -5,10 +5,10 @@ describe "FormHelper" do
|
|
|
5
5
|
class MockFormHelperContext < Rad::MockTemplateContext
|
|
6
6
|
include Rad::Html::FormHelper
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
@t = MockFormHelperContext.new
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
it "check_box_tag" do
|
|
13
13
|
@t.check_box_tag('item').should == %(<input class=" checkbox_input" name="item" type="checkbox" value="1"></input>)
|
|
14
14
|
end
|
|
@@ -43,10 +43,10 @@ describe "FormHelper" do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "select_tag" do
|
|
46
|
-
@t.select_tag('item', nil, [["Dollar", "$"], ["Kroner", "DKK"]]).should ==
|
|
46
|
+
@t.select_tag('item', nil, [["Dollar", "$"], ["Kroner", "DKK"]]).should ==
|
|
47
47
|
%(<select class=" select_input" name="item">\n<option value="$">Dollar</option>\n<option value="DKK">Kroner</option>\n</select>)
|
|
48
|
-
|
|
49
|
-
@t.select_tag('item', '$', [["Dollar", "$"], ["Kroner", "DKK"]], class: 'highlight').should ==
|
|
48
|
+
|
|
49
|
+
@t.select_tag('item', '$', [["Dollar", "$"], ["Kroner", "DKK"]], class: 'highlight').should ==
|
|
50
50
|
%(<select class="highlight select_input" name="item">\n<option selected="selected" value="$">Dollar</option>\n\
|
|
51
51
|
<option value="DKK">Kroner</option>\n</select>)
|
|
52
52
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
require 'html/spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "BasicHtmlHelper" do
|
|
4
|
-
before do
|
|
4
|
+
before do
|
|
5
5
|
class MockJavascriptHelperContext < Rad::MockTemplateContext
|
|
6
6
|
inherit Rad::Html::JavascriptHelper
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def url_for *args
|
|
9
9
|
args.join(' ')
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
@t = MockJavascriptHelperContext.new
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
it "javascript_include_tag" do
|
|
17
17
|
@t.javascript_include_tag('/public/js/app.js').should == %(<script src="/public/js/app.js" type="text/javascript"></script>)
|
|
18
18
|
end
|
|
@@ -5,26 +5,26 @@ describe "ModelHelper" do
|
|
|
5
5
|
class MockModelHelperContext < Rad::MockTemplateContext
|
|
6
6
|
inherit Rad::Html::FormHelper
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
@t = MockModelHelperContext.new
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
if String.method_defined? :to_xhtml
|
|
13
13
|
it "form_for" do
|
|
14
14
|
@t.form_for(:aname, nil, id: 'the_form', action: '/'){"content"}
|
|
15
15
|
@t.buffer.to_xhtml('#the_form').to_fuzzy_hash.should == {id: 'the_form', action: '/', content: 'content', method: 'post'}
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
it "error_messages" do
|
|
19
19
|
@t.form_for(:aname, nil){|f| f.error_messages}
|
|
20
20
|
lambda{@t.buffer.to_xhtml('form div')}.should raise_error(/not found/)
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
model = {errors: {base: ['some error']}}
|
|
23
23
|
@t.buffer = ""
|
|
24
24
|
@t.form_for(:book, model){|f| f.error_messages}
|
|
25
25
|
@t.buffer.to_xhtml('form div').to_fuzzy_hash.should == {class: 'error_messages', content: 'some error'}
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
it "field error" do
|
|
29
29
|
model = {
|
|
30
30
|
title: "Super Hero",
|
|
@@ -35,25 +35,25 @@ describe "ModelHelper" do
|
|
|
35
35
|
doc.css("form div.field_error_messages").first.content.should == "some error in title"
|
|
36
36
|
doc.css("form span.field_with_errors input").first.to_fuzzy_hash.should == {name: "book[title]", value: "Super Hero"}
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
it "should insert human readable label if not specified" do
|
|
40
40
|
model = {}
|
|
41
41
|
model.stub(:t).and_return{|k| "translated #{k}"}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
@t.form_for(:book, model){|f| f.text_field(:title)}
|
|
44
44
|
@t.buffer.should =~ /translated title/
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
@t.form_for(:book, model){|f| f.text_field(:title, label: 'some label')}
|
|
47
47
|
@t.buffer.should =~ /some label/
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
it "field_helpers" do
|
|
51
51
|
model = {
|
|
52
52
|
available: false,
|
|
53
53
|
title: "Super Hero",
|
|
54
54
|
theme: 'simple'
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
@t.form_for(:book, model){|f| %{
|
|
58
58
|
#{f.check_box :available}
|
|
59
59
|
#{f.file_field :title}
|
|
@@ -66,11 +66,11 @@ describe "ModelHelper" do
|
|
|
66
66
|
#{f.select :theme, %w(a b)}
|
|
67
67
|
} }
|
|
68
68
|
doc = @t.buffer.to_xhtml
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
# checkbox is special case, we are using it with <input type='hidden' .../> tag.
|
|
71
71
|
doc.css("*[type='hidden']").first.to_fuzzy_hash.should == {name: "book[available]", value: '0'}
|
|
72
72
|
doc.css("*[type='checkbox']").first.to_fuzzy_hash.should == {name: "book[available]", value: '1'}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
doc.css("*[type='file']").first.to_fuzzy_hash.should == {name: "book[title]"}
|
|
75
75
|
doc.css("*[type='hidden']").last.to_fuzzy_hash.should == {name: "book[title]", value: 'Super Hero'}
|
|
76
76
|
doc.css("*[type='password']").first.to_fuzzy_hash.should == {name: "book[title]"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'html/spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "ScopedParams" do
|
|
4
|
-
it "basic" do
|
|
4
|
+
it "basic" do
|
|
5
5
|
workspace = Rad::Conveyors::Workspace.new.update(params: {"book[title]" => "Super Hero"})
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
@processor = Rad::Html::Processors::ScopedParams.new(lambda{})
|
|
8
8
|
@processor.stub(:workspace).and_return(workspace)
|
|
9
9
|
@processor.call
|
data/spec/html/spec_helper.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
class Rad::MockTemplateContext
|
|
4
4
|
inherit Rad::Html::BasicHtmlHelper
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
inject workspace: :workspace
|
|
7
7
|
|
|
8
8
|
attr_accessor :output, :capture, :buffer
|
|
@@ -10,10 +10,10 @@ class Rad::MockTemplateContext
|
|
|
10
10
|
def capture &block
|
|
11
11
|
block.call
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def concat value = nil
|
|
15
15
|
@buffer ||= ""
|
|
16
16
|
@buffer << value
|
|
17
17
|
nil
|
|
18
|
-
end
|
|
18
|
+
end
|
|
19
19
|
end
|
data/spec/http/http_spec.rb
CHANGED
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe "Http basics" do
|
|
4
4
|
with_prepare_params
|
|
5
|
-
inject environment: :environment, conveyors: :conveyors
|
|
6
|
-
|
|
5
|
+
inject environment: :environment, conveyors: :conveyors
|
|
6
|
+
|
|
7
7
|
isolate :conveyors
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
before do
|
|
10
10
|
rad.conveyors.web do |web|
|
|
11
11
|
web.use Rad::Http::Processors::HttpWriter
|
|
@@ -13,18 +13,18 @@ describe "Http basics" do
|
|
|
13
13
|
web.use Rad::Http::Processors::EvaluateFormat
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
|
|
17
|
-
it "http call" do
|
|
16
|
+
|
|
17
|
+
it "http call" do
|
|
18
18
|
workspace = nil
|
|
19
19
|
|
|
20
|
-
rad.http.call Rad::Http::Request.stub_environment do |c|
|
|
20
|
+
rad.http.call Rad::Http::Request.stub_environment do |c|
|
|
21
21
|
c.call
|
|
22
22
|
workspace = rad.workspace
|
|
23
23
|
end
|
|
24
|
-
# .should == [200, {"Content-Type" => "text/html"}, ""]
|
|
25
|
-
|
|
24
|
+
# .should == [200, {"Content-Type" => "text/html"}, ""]
|
|
25
|
+
|
|
26
26
|
workspace.delete(:env).should be_a(Hash)
|
|
27
27
|
expected_result = {path: "/", response: [200, {"Content-Type" => "text/html"}, ""], params: {format: 'html'}}
|
|
28
|
-
workspace.to_h.subset(expected_result.keys).should == expected_result
|
|
28
|
+
workspace.to_h.subset(expected_result.keys).should == expected_result
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -3,10 +3,10 @@ require 'spec_helper'
|
|
|
3
3
|
describe "Http basics" do
|
|
4
4
|
it "response should accept string status messages" do
|
|
5
5
|
response = Rad::Http::Response.new
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
response.status = :error
|
|
8
8
|
response.status.should == 500
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
response.status = :ok
|
|
11
11
|
response.status.should == 200
|
|
12
12
|
end
|
|
@@ -2,64 +2,64 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe "MailerController" do
|
|
4
4
|
with_view_path "#{spec_dir}/views"
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
isolate :conveyors
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
before{load 'rad/profiles/mailer.rb'}
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
after :all do
|
|
11
|
-
remove_constants %w(
|
|
11
|
+
remove_constants %w(
|
|
12
12
|
ExplicitBodySpec
|
|
13
13
|
BodyTemplateSpec
|
|
14
14
|
CopyParamsSpec
|
|
15
15
|
)
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def common_letter
|
|
19
19
|
{from: "john@mail.com", to: "ben@mail.com", subject: "hi there"}.to_openobject
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
describe "building letter" do
|
|
23
|
-
it "shouldn't render view if body explicitly specified" do
|
|
23
|
+
it "shouldn't render view if body explicitly specified" do
|
|
24
24
|
class ::ExplicitBodySpec
|
|
25
25
|
inherit Rad::Mailer::MailerController
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def signup model
|
|
28
28
|
@from, @to, @subject = model.from, model.to, model.subject
|
|
29
29
|
@body = "Hello Ben, signup notification."
|
|
30
30
|
end
|
|
31
|
-
end
|
|
32
|
-
|
|
31
|
+
end
|
|
32
|
+
|
|
33
33
|
letter = ExplicitBodySpec.signup(common_letter.merge(body: 'Hello Ben, signup notification.'))
|
|
34
34
|
letter.to_h.to_openobject.should == common_letter.merge(body: 'Hello Ben, signup notification.')
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
it "should use template for body" do
|
|
38
38
|
class ::BodyTemplateSpec
|
|
39
39
|
inherit Rad::Mailer::MailerController
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
def signup model, name
|
|
42
42
|
@name = name
|
|
43
43
|
@from, @to, @subject = model.from, model.to, model.subject
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
letter = BodyTemplateSpec.signup(common_letter, "Ben")
|
|
48
48
|
letter.to_h.to_openobject.should == common_letter.merge(body: 'Hello Ben, signup notification.')
|
|
49
49
|
end
|
|
50
|
-
|
|
51
|
-
it "should copy workspace variables from current :cycle (from error, all checks important, don't delete anything!)" do
|
|
50
|
+
|
|
51
|
+
it "should copy workspace variables from current :cycle (from error, all checks important, don't delete anything!)" do
|
|
52
52
|
class ::CopyParamsSpec
|
|
53
53
|
inherit Rad::Mailer::MailerController
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
def signup model
|
|
56
56
|
@from, @to, @subject = model.from, model.to, model.subject
|
|
57
57
|
@body = "language: #{params.l}, key: #{workspace.key}, space: #{rad.space}"
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
rad.register :space, scope: :cycle
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
letter = nil
|
|
64
64
|
rad.activate :cycle, {} do
|
|
65
65
|
rad.space = 'space'
|
|
@@ -67,19 +67,19 @@ describe "MailerController" do
|
|
|
67
67
|
w.key = 'value'
|
|
68
68
|
w.params = Rad::Conveyors::Params.new
|
|
69
69
|
w.params.l = 'ru'
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
letter = CopyParamsSpec.signup(common_letter)
|
|
72
72
|
end
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
letter.to_h.to_openobject.should == common_letter.merge(body: 'language: ru, key: value, space: space')
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
it "delivering" do
|
|
79
79
|
letter = Rad::Mailer::Letter.new common_letter.merge(body: "some text")
|
|
80
80
|
letter.deliver
|
|
81
81
|
letter.deliver
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
sent_letters.should == [letter, letter]
|
|
84
|
-
end
|
|
84
|
+
end
|
|
85
85
|
end
|