Skip to content

Commit

Permalink
Fix wsdl route lookup (closes #215); Tick to stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
inossidabile committed Dec 9, 2016
1 parent 75e86be commit 25e7ef2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
6 changes: 0 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
appraise "rails-3.2.13" do
gem "rails", "3.2.13"
gem "test-unit"
gem "listen", "< 3.1.0"
end

appraise "rails-4.0.0" do
gem "rails", "4.0.0"
gem "listen", "< 3.1.0"
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require 'bundler/gem_tasks'
require 'appraisal'
require 'rspec/core/rake_task'


RSpec::Core::RakeTask.new

task :console do
Expand Down
32 changes: 13 additions & 19 deletions lib/wash_out/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@ module WashOut
# This class is a Rack middleware used to route SOAP requests to a proper
# action of a given SOAP controller.
class Router
def self.lookup_soap_routes(controller_name, routes)
results = []

def self.lookup_soap_routes(controller_name, routes, path: [], &block)
routes.each do |x|
defaults = x.defaults
defaults = defaults[:defaults] if defaults.include?(:defaults) # Rails 5
if defaults[:controller] == controller_name && defaults[:action] == 'soap'
results << x
yield path + [x]
end

app = x.app
app = app.app if app.respond_to?(:app)
if app.respond_to?(:routes)
results += lookup_soap_routes(controller_name, app.routes.routes)
lookup_soap_routes(controller_name, app.routes.routes, path: path+[x], &block)
end
end

results
end

def self.url(request, controller_name)
route = lookup_soap_routes(controller_name, Rails.application.routes.routes).first

path = if route.respond_to?(:optimized_path) # Rails 4
route.optimized_path
elsif route.path.respond_to?(:build_formatter) # Rails 5
route.path.build_formatter.evaluate(nil)
else
route.format({}) # Rails 3.2
end
lookup_soap_routes(controller_name, Rails.application.routes.routes) do |routes|

path = if routes.first.respond_to?(:optimized_path) # Rails 4
routes.map(&:optimized_path)
elsif routes.first.path.respond_to?(:build_formatter) # Rails 5
routes.map{|x| x.path.build_formatter.evaluate(nil)}
else
routes.map{|x| x.format({})} # Rails 3.2
end

path = path.join('') if path.is_a?(Array)

request.protocol + request.host_with_port + path
return request.protocol + request.host_with_port + path.flatten.join('')
end
end

def initialize(controller_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/wash_out/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WashOut
VERSION = "0.11.0.beta.2"
VERSION = "0.11.0"
end

0 comments on commit 25e7ef2

Please sign in to comment.