Skip to content

Commit

Permalink
update router and controller to handle mime type corect
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Sep 30, 2016
1 parent 000c627 commit ca9cf82
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ appraise "rails-5.0.0" do
gem "rails", "5.0.0"
gem 'rails-controller-testing'
end

appraise "rails-api-4.2.7" do
gem 'rails', '4.2.7.1'
gem 'rails-api', '0.4.0'
gem 'actionpack' , '4.2.7.1'
end
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ gemspec

gem 'wash_out', github: 'inossidabile/wash_out'

if RUBY_VERSION >= "2.2.0"
gem 'activesupport', '>= 4.0', '>= 4.0'
else
if RUBY_VERSION < "2.2.0"
gem 'activesupport', '>= 4.0', '< 5.0'
end
24 changes: 19 additions & 5 deletions app/controllers/washout_builder/washout_builder_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,33 @@ def all
route_details = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
if route_details.present? && defined?(controller_class(params[:name]))
@document = WashoutBuilder::Document::Generator.new(route_details, controller_class(params[:name]).controller_path)
render template: 'wash_with_html/doc', layout: false,
content_type: 'text/html'
render_html('wash_with_html/doc')
elsif
@services = all_services
render template: 'wash_with_html/all_services', layout: false,
content_type: 'text/html'
render_html('wash_with_html/all_services')
end
end

private

def env_controller_path
request.env['washout_builder.controller_path']
request.env['washout_builder.controller_path']
end


def render_html(path, options= { layout: false, content_type: 'text/html' })
options = options.merge(template: path)
respond_to do |format|
format.json { render options }
render_html_format_all(format, options)
end
end

def render_html_format_all(format, options)
format.all do
response.content_type = 'text/html; charset=utf-8'
render options.merge(formats: [:html])
end
end

# tries to find all services by searching through the rails controller
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails_4.0.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "http://rubygems.org"

gem "wash_out", :github => "inossidabile/wash_out"
gem "activesupport", ">= 4.0", ">= 4.0"
gem "rails", "4.0.0"

gemspec :path => "../"
1 change: 0 additions & 1 deletion gemfiles/rails_4.1.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "http://rubygems.org"

gem "wash_out", :github => "inossidabile/wash_out"
gem "activesupport", ">= 4.0", ">= 4.0"
gem "rails", "4.1.1"

gemspec :path => "../"
1 change: 0 additions & 1 deletion gemfiles/rails_4.2.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "http://rubygems.org"

gem "wash_out", :github => "inossidabile/wash_out"
gem "activesupport", ">= 4.0", ">= 4.0"
gem "rails", "4.2.0"

gemspec :path => "../"
1 change: 0 additions & 1 deletion gemfiles/rails_5.0.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "http://rubygems.org"

gem "wash_out", :github => "inossidabile/wash_out"
gem "activesupport", ">= 4.0", ">= 4.0"
gem "rails", "5.0.0"
gem "rails-controller-testing"

Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails_api_4.2.7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "wash_out", :github => "inossidabile/wash_out"
gem "rails", "4.2.7.1"
gem "rails-api", "0.4.0"
gem "actionpack", "4.2.7.1"

gemspec :path => "../"
1 change: 0 additions & 1 deletion lib/washout_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def wash_out(controller_name, options={})
controller_class_name = controller_name.to_s.underscore
end
match "#{controller_name}/soap_doc" => WashoutBuilder::Router.new(controller_class_name), via: :get,
format: false,
as: "#{controller_class_name}_soap_doc"
end
original_wash_out(controller_name, options)
Expand Down
1 change: 1 addition & 0 deletions lib/washout_builder/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(controller_path)

def call(env)
env['washout_builder.controller_path'] = @controller_path
env["action_dispatch.request.content_type"] = Mime[:html]
::WashoutBuilder::WashoutBuilderController.action(:all).call(env)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module VERSION
# the minor version of the gem
MINOR = 6
# the tiny version of the gem
TINY = 2
TINY = 3
# if the version should be a prerelease
PRE = nil

Expand Down

0 comments on commit ca9cf82

Please sign in to comment.