wash_out_fork 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +36 -0
- data/Appraisals +25 -0
- data/CHANGELOG.md +102 -0
- data/Gemfile +17 -0
- data/Guardfile +12 -0
- data/LICENSE +22 -0
- data/README.md +242 -0
- data/Rakefile +25 -0
- data/app/helpers/wash_out_fork_helper.rb +110 -0
- data/app/views/wash_out_fork/document/error.builder +9 -0
- data/app/views/wash_out_fork/document/response.builder +8 -0
- data/app/views/wash_out_fork/document/wsdl.builder +68 -0
- data/app/views/wash_out_fork/rpc/error.builder +10 -0
- data/app/views/wash_out_fork/rpc/response.builder +9 -0
- data/app/views/wash_out_fork/rpc/wsdl.builder +68 -0
- data/gemfiles/rails_3.2.13.gemfile +21 -0
- data/gemfiles/rails_4.0.0.gemfile +20 -0
- data/gemfiles/rails_4.1.0.gemfile +20 -0
- data/gemfiles/rails_4.2.0.gemfile +20 -0
- data/gemfiles/rails_5.0.0.beta2.gemfile +19 -0
- data/gemfiles/rails_5.0.0.gemfile +19 -0
- data/init.rb +1 -0
- data/lib/wash_out_fork.rb +60 -0
- data/lib/wash_out_fork/configurable.rb +41 -0
- data/lib/wash_out_fork/dispatcher.rb +232 -0
- data/lib/wash_out_fork/engine.rb +12 -0
- data/lib/wash_out_fork/middleware.rb +41 -0
- data/lib/wash_out_fork/model.rb +29 -0
- data/lib/wash_out_fork/param.rb +200 -0
- data/lib/wash_out_fork/router.rb +131 -0
- data/lib/wash_out_fork/soap.rb +48 -0
- data/lib/wash_out_fork/soap_config.rb +93 -0
- data/lib/wash_out_fork/type.rb +29 -0
- data/lib/wash_out_fork/version.rb +3 -0
- data/lib/wash_out_fork/wsse.rb +101 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +23 -0
- data/spec/dummy/config/environments/test.rb +30 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/nested_refs_to_arrays.xml +19 -0
- data/spec/fixtures/ref_to_one_array.xml +11 -0
- data/spec/fixtures/refs_to_arrays.xml +16 -0
- data/spec/lib/wash_out/dispatcher_spec.rb +206 -0
- data/spec/lib/wash_out/middleware_spec.rb +33 -0
- data/spec/lib/wash_out/param_spec.rb +94 -0
- data/spec/lib/wash_out/router_spec.rb +50 -0
- data/spec/lib/wash_out/type_spec.rb +41 -0
- data/spec/lib/wash_out_spec.rb +797 -0
- data/spec/spec_helper.rb +88 -0
- data/wash_out_fork.gemspec +20 -0
- metadata +130 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "rails/test_unit/railtie"
|
5
|
+
|
6
|
+
if Rails::VERSION::MAJOR >= 4
|
7
|
+
# Ugly hack to make Rails 4 JRuby-compatible to escape Travis errors
|
8
|
+
Rails::Engine.class_eval do
|
9
|
+
def railties
|
10
|
+
@railties ||= self.class.const_get(:Railties).new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Bundler.require
|
16
|
+
require "wash_out_fork"
|
17
|
+
|
18
|
+
module Dummy
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Settings in config/environments/* take precedence over those specified here.
|
21
|
+
# Application configuration should go into files in config/initializers
|
22
|
+
# -- all .rb files in that directory are automatically loaded.
|
23
|
+
|
24
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
25
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
26
|
+
|
27
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
28
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
29
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
30
|
+
|
31
|
+
# Activate observers that should always be running.
|
32
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
33
|
+
|
34
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
35
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
36
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
37
|
+
|
38
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
39
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
40
|
+
# config.i18n.default_locale = :de
|
41
|
+
|
42
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
43
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
44
|
+
|
45
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
46
|
+
config.encoding = "utf-8"
|
47
|
+
|
48
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
49
|
+
config.filter_parameters += [:password]
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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 webserver 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_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Print deprecation notices to the Rails logger
|
18
|
+
config.active_support.deprecation = :log
|
19
|
+
|
20
|
+
# Only use best-standards-support built into browsers
|
21
|
+
config.action_dispatch.best_standards_support = :builtin
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,30 @@
|
|
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
|
+
config.eager_load = 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
|
+
# Raise exceptions instead of rendering exception templates
|
17
|
+
config.action_dispatch.show_exceptions = false
|
18
|
+
|
19
|
+
# Disable request forgery protection in test environment
|
20
|
+
config.action_controller.allow_forgery_protection = false
|
21
|
+
|
22
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
23
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
24
|
+
# like if you have constraints or database-specific column types
|
25
|
+
# config.active_record.schema_format = :sql
|
26
|
+
|
27
|
+
# Print deprecation notices to the stderr
|
28
|
+
config.active_support.deprecation = :stderr
|
29
|
+
config.active_support.test_order = :random
|
30
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'b8d5d5687c012c2ef1a7a6e8006172402c48a3dcccca67c076eaad81c4712ad236ca2717c3706df7b286468c749d223f22acb0d96c27bdf33bbdbb9684ad46e5'
|
8
|
+
Dummy::Application.config.secret_key_base = 'ed27a919186a27649accc93ad8c2750a022ef255780e8a15a439658e9f8c520ed70ea071e596b2d23ed41163cf36c21ff5afcd31d19439bb1e4c420f2a57bce6'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => "welcome#index"
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id(.:format)))'
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
2
|
+
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
5
|
+
<parent href="#id1" />
|
6
|
+
<q2:child id="id1" xsi:type="q2:child" xmlns:q2="urn:FakeService">
|
7
|
+
<first_list href="#id2" />
|
8
|
+
<second_list href="#id3" />
|
9
|
+
</q2:child>
|
10
|
+
<q3:Array id="id2" q3:arrayType="xsd:int[1]" xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/">
|
11
|
+
<Item>1</Item>
|
12
|
+
<Item>2</Item>
|
13
|
+
</q3:Array>
|
14
|
+
<q4:Array id="id3" q4:arrayType="xsd:int[1]" xmlns:q4="http://schemas.xmlsoap.org/soap/encoding/">
|
15
|
+
<Item>11</Item>
|
16
|
+
<Item>22</Item>
|
17
|
+
</q4:Array>
|
18
|
+
</s:Body>
|
19
|
+
</s:Envelope>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
2
|
+
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
5
|
+
<list href="#id1" />
|
6
|
+
<q1:Array id="id1" q1:arrayType="xsd:int[1]" xmlns:q1="http://schemas.xmlsoap.org/soap/encoding/">
|
7
|
+
<Item>1</Item>
|
8
|
+
<Item>2</Item>
|
9
|
+
</q1:Array>
|
10
|
+
</s:Body>
|
11
|
+
</s:Envelope>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
2
|
+
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
5
|
+
<first_list href="#id1" />
|
6
|
+
<second_list href="#id2" />
|
7
|
+
<q1:Array id="id1" q1:arrayType="xsd:int[1]" xmlns:q1="http://schemas.xmlsoap.org/soap/encoding/">
|
8
|
+
<Item>1</Item>
|
9
|
+
<Item>2</Item>
|
10
|
+
</q1:Array>
|
11
|
+
<q2:Array id="id2" q2:arrayType="xsd:int[1]" xmlns:q2="http://schemas.xmlsoap.org/soap/encoding/">
|
12
|
+
<Item>11</Item>
|
13
|
+
<Item>22</Item>
|
14
|
+
</q2:Array>
|
15
|
+
</s:Body>
|
16
|
+
</s:Envelope>
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe WashOutFork::Dispatcher do
|
6
|
+
|
7
|
+
class Dispatcher < ApplicationController
|
8
|
+
soap_service
|
9
|
+
|
10
|
+
def params
|
11
|
+
@_params
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".deep_select" do
|
16
|
+
blk = lambda{|v| v.is_a?(Hash) && v.has_key?(:@id)}
|
17
|
+
|
18
|
+
it "find no elements if there aren't any ids" do
|
19
|
+
expect(WashOutFork::Dispatcher.deep_select({k: {v: :v2}}, &blk)).to eq []
|
20
|
+
end
|
21
|
+
|
22
|
+
it "finds elements with ids in a hash" do
|
23
|
+
expect(WashOutFork::Dispatcher.deep_select({k: {:@id => 5, x: :y}}, &blk)).to eq [{:@id => 5, x: :y}]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "finds elements with ids in a array" do
|
27
|
+
expect(WashOutFork::Dispatcher.deep_select({k: [{:@id => 5, x: :y}]}, &blk)).to eq [{:@id => 5, x: :y}]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "finds elements with ids in hashes" do
|
31
|
+
expect(WashOutFork::Dispatcher.deep_select(
|
32
|
+
{
|
33
|
+
k: {:@id => 5, x: :y},
|
34
|
+
k2: {:@id => 6, n: :m}
|
35
|
+
}, &blk)).to eq [{:@id => 5, x: :y}, {:@id => 6, n: :m}]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "finds elements in a hash and in a array" do
|
39
|
+
expect(WashOutFork::Dispatcher.deep_select(
|
40
|
+
{
|
41
|
+
k: [{:@id => 5, x: :y}],
|
42
|
+
k2: {:@id => 6, n: :m}
|
43
|
+
}, &blk)).to contain_exactly({:@id => 5, x: :y}, {:@id => 6, n: :m})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "finds elements with ids in multiple arrays" do
|
47
|
+
expect(WashOutFork::Dispatcher.deep_select(
|
48
|
+
{
|
49
|
+
k: [{:@id => 5, x: :y}],
|
50
|
+
k2: [{:@id => 6, n: :m}]
|
51
|
+
}, &blk)).to eq [{:@id => 5, x: :y}, {:@id => 6, n: :m}]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".deep_replace_href" do
|
56
|
+
it "replaces nested hashed" do
|
57
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(
|
58
|
+
{:foo => {:@href => 1}},
|
59
|
+
{1 => 2})).to eq(
|
60
|
+
{:foo => 2}
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "replaces deeper nested hashes" do
|
65
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(
|
66
|
+
{:bar => {:foo => {:@href => 1}}},
|
67
|
+
{1 => 2}
|
68
|
+
)).to eq(
|
69
|
+
{:bar => {:foo => 2}}
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "replace nested refs" do
|
74
|
+
hash = {fizz: {:@href => "#id4"}}
|
75
|
+
replaces = {
|
76
|
+
"#id4" => {:@href => "#id6"},
|
77
|
+
"#id6" => {foo: :bar}
|
78
|
+
}
|
79
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(hash, replaces)).to eq({
|
80
|
+
fizz: {foo: :bar}})
|
81
|
+
end
|
82
|
+
|
83
|
+
it "replace really nested refs" do
|
84
|
+
hash = {fizz: {:@href => "#id4"}}
|
85
|
+
replaces = {
|
86
|
+
"#id4" => {:@href => "#id6"},
|
87
|
+
"#id6" => {:@href => "#id7"},
|
88
|
+
"#id7" => {foo: :bar}
|
89
|
+
}
|
90
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(hash, replaces)).to eq({
|
91
|
+
fizz: {foo: :bar}})
|
92
|
+
end
|
93
|
+
|
94
|
+
it "replaces arrays in nested hashes" do
|
95
|
+
hash = {
|
96
|
+
fizz: {:@href => "#id4"},
|
97
|
+
Array: [
|
98
|
+
{Item: [{:@href => "#id6"}, {:@href => "#id7"}]},
|
99
|
+
{Item: {loo: :iioo}}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
replaces = {
|
103
|
+
"#id4" => {Item: [{:@href => "#id6"}, {:@href => "#id7"}]},
|
104
|
+
"#id6" => {foo: :bar},
|
105
|
+
"#id7" => {baz: :bats}
|
106
|
+
}
|
107
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(hash, replaces)).to eq({
|
108
|
+
fizz: {Item: [
|
109
|
+
{foo: :bar},
|
110
|
+
{baz: :bats}
|
111
|
+
]},
|
112
|
+
Array: [
|
113
|
+
{Item: [{foo: :bar}, {baz: :bats}]},
|
114
|
+
{Item: {loo: :iioo}}
|
115
|
+
]
|
116
|
+
})
|
117
|
+
end
|
118
|
+
|
119
|
+
it "can traverse arrays that do not contain hashes" do
|
120
|
+
hash = {
|
121
|
+
fizz: {:@href => "#id1"},
|
122
|
+
}
|
123
|
+
replaces = {
|
124
|
+
"#id1" => {Item: ["1", "2"]},
|
125
|
+
}
|
126
|
+
expect(WashOutFork::Dispatcher.deep_replace_href(hash, replaces)).to eq({
|
127
|
+
fizz: {Item: ["1", "2"]},
|
128
|
+
})
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
xit "parses typical request" do
|
133
|
+
dispatcher = Dispatcher.mock("<foo>1</foo>")
|
134
|
+
dispatcher._parse_soap_parameters
|
135
|
+
expect(dispatcher.params).to eq({:foo => "1"})
|
136
|
+
end
|
137
|
+
|
138
|
+
xit "parses href request" do
|
139
|
+
dispatcher = Dispatcher.mock <<-XML
|
140
|
+
<root>
|
141
|
+
<request>
|
142
|
+
<entities href="#id1">
|
143
|
+
</entities>
|
144
|
+
</request>
|
145
|
+
<entity id="id1">
|
146
|
+
<foo><bar>1</bar></foo>
|
147
|
+
<sub href="#id2" />
|
148
|
+
</entity>
|
149
|
+
<ololo id="id2">
|
150
|
+
<foo>1</foo>
|
151
|
+
</ololo>
|
152
|
+
</root>
|
153
|
+
XML
|
154
|
+
dispatcher._parse_soap_parameters
|
155
|
+
expect(dispatcher.params[:root][:request][:entities]).to eq({
|
156
|
+
:foo => {:bar=>"1"},
|
157
|
+
:sub => {:foo=>"1", :@id=>"id2"},
|
158
|
+
:@id => "id1"
|
159
|
+
})
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "#_map_soap_parameters" do
|
163
|
+
let(:dispatcher) { Dispatcher.new }
|
164
|
+
let(:soap_config) { WashOutFork::SoapConfig.new(camelize_wsdl: false) }
|
165
|
+
|
166
|
+
before do
|
167
|
+
allow(dispatcher).to receive(:action_spec).and_return(in: WashOutFork::Param.parse_def(soap_config, { foo: { "@bar" => :string, empty: :string } } ))
|
168
|
+
allow(dispatcher).to receive(:xml_data).and_return(foo: { "@bar" => "buzz", empty: { :"@xsi:type" => "xsd:string" } })
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should handle empty strings that have been parsed wrong by nori, but preserve attrs" do
|
172
|
+
dispatcher._map_soap_parameters
|
173
|
+
expect(dispatcher.params).to eq("foo" => { "bar" => "buzz", "empty" => nil })
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#_load_params" do
|
178
|
+
let(:dispatcher) { Dispatcher.new }
|
179
|
+
let(:soap_config) { WashOutFork::SoapConfig.new({ camelize_wsdl: false }) }
|
180
|
+
it "should load params for an array" do
|
181
|
+
spec = WashOutFork::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
182
|
+
xml_data = {:my_array => [1, 2, 3]}
|
183
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"my_array" => [1, 2, 3]})
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should load params for an empty array" do
|
187
|
+
spec = WashOutFork::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
188
|
+
xml_data = {}
|
189
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({})
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should load params for a nested array" do
|
193
|
+
spec = WashOutFork::Param.parse_def(soap_config, {:nested => {:my_array => [:integer]}} )
|
194
|
+
xml_data = {:nested => {:my_array => [1, 2, 3]}}
|
195
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {"my_array" => [1, 2, 3]}})
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should load params for an empty nested array" do
|
199
|
+
spec = WashOutFork::Param.parse_def(soap_config, {:nested => {:empty => [:integer] }} )
|
200
|
+
xml_data = {:nested => nil}
|
201
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {}})
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|