From 31aad2d2d272bb98606174f66d18d7110a3c6c86 Mon Sep 17 00:00:00 2001 From: Jacek Tomaszewski Date: Wed, 25 Sep 2013 21:11:22 +0200 Subject: [PATCH 1/7] Add support for relative_url_root option. This solves problem if you have set your application to be run on relative url like "/url/" (`config.action_controller.relative_url_root` option). --- app/views/api_taster/routes/show.html.erb | 2 +- lib/api_taster/route.rb | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/api_taster/routes/show.html.erb b/app/views/api_taster/routes/show.html.erb index 2825259..eeab34f 100644 --- a/app/views/api_taster/routes/show.html.erb +++ b/app/views/api_taster/routes/show.html.erb @@ -16,7 +16,7 @@ <% end %> <% @params.each do |param| %> - <%= form_tag @route[:path], :method => @route[:verb], :class => 'well form-horizontal', :remote => true do %> + <%= form_tag @route[:full_path], :method => @route[:verb], :class => 'well form-horizontal', :remote => true do %> <% if param[:url_params].empty? && param[:post_params].empty? %>
diff --git a/lib/api_taster/route.rb b/lib/api_taster/route.rb index e36c0ab..e0acfbf 100644 --- a/lib/api_taster/route.rb +++ b/lib/api_taster/route.rb @@ -116,12 +116,14 @@ def discover_rack_app(app) def normalise_route(route, path_prefix = nil) route.verb.source.split('|').map do |verb| + path = path_prefix.to_s + route.path.spec.to_s.sub('(.:format)', '') { - :id => @_route_counter+=1, - :name => route.name, - :verb => verb.gsub(/[$^]/, ''), - :path => path_prefix.to_s + route.path.spec.to_s.sub('(.:format)', ''), - :reqs => route.requirements + :id => @_route_counter+=1, + :name => route.name, + :verb => verb.gsub(/[$^]/, ''), + :path => path, + :full_path => rails_url_root + path, + :reqs => route.requirements } end end @@ -143,6 +145,10 @@ def hash_diff(h1, h2) h2[k] == v end.merge!(h2.dup.delete_if { |k, v| h1.has_key?(k) }) end + + def rails_url_root + ActionController::Base.relative_url_root.to_s.chomp('/') + end end end end From 08d137d0d1cf80f785a77dcb9a90cc21ab3c3248 Mon Sep 17 00:00:00 2001 From: Jacek Tomaszewski Date: Wed, 25 Sep 2013 21:20:40 +0200 Subject: [PATCH 2/7] Don't render layout on ApiTaster::Routes#show. It's loaded by AJAX, so it's enough we'll load only the body of the #show response. (this removes unneeded + <% if @params.is_a?(Hash) && @params.has_key?(:undefined) %> <%= render 'undefined_route', :route => @params[:undefined] %> <% else %> diff --git a/lib/api_taster/version.rb b/lib/api_taster/version.rb index a7cb31f..ec73bd3 100644 --- a/lib/api_taster/version.rb +++ b/lib/api_taster/version.rb @@ -1,3 +1,3 @@ module ApiTaster - VERSION = "0.8.0" + VERSION = "0.8.1" end From 01ff73af7c6741fdaef06cfb72bc3741215efeea Mon Sep 17 00:00:00 2001 From: Mario A Chavez Date: Wed, 11 Jun 2014 20:19:04 +0000 Subject: [PATCH 7/7] Fix failing tests Set explicit sass-rails version to help travis resolve dependencies --- .travis.yml | 2 +- api_taster.gemspec | 4 ++-- spec/route_spec.rb | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 222078e..4c9dc22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: ruby rvm: - 1.9.3 - - 2.0.0 + - 2.1.2 diff --git a/api_taster.gemspec b/api_taster.gemspec index 6363724..514c4a6 100644 --- a/api_taster.gemspec +++ b/api_taster.gemspec @@ -16,8 +16,8 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '~> 4.1.0' s.add_dependency 'jquery-rails' - s.add_dependency 'sass-rails' - s.add_dependency 'bootstrap-sass', '~> 2.1' + s.add_dependency 'sass-rails', '~> 4.0.3' + s.add_dependency 'bootstrap-sass', '~> 3.1.0.0' s.add_dependency 'redcarpet' s.add_dependency 'remotipart', '~> 1.0' diff --git a/spec/route_spec.rb b/spec/route_spec.rb index d376568..ff93817 100644 --- a/spec/route_spec.rb +++ b/spec/route_spec.rb @@ -15,9 +15,10 @@ module ApiTaster :name => 'home', :verb => 'GET', :path => '/home', + :full_path => '/home', :reqs => { - :controller => 'application', - :action => 'home' + :action => 'home', + :controller => 'application' } } end