add Rack::PostBodyContentTypeParser and fix locale update
This commit is contained in:
parent
f09cb3cac0
commit
6dc28f0c49
1
Gemfile
1
Gemfile
|
@ -7,6 +7,7 @@ gem 'travis-support', github: 'travis-ci/travis-support'
|
|||
gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-more-services'
|
||||
gem 'hubble', github: 'roidrage/hubble'
|
||||
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
||||
gem 'rack-contrib', github: 'rack/rack-contrib'
|
||||
gem 'gh', github: 'rkh/gh'
|
||||
gem 'bunny'
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ class Travis::Api::App
|
|||
use Hubble::Rescuer, env: Travis.env, codename: ENV['CODENAME'] if Endpoint.production? && ENV['HUBBLE_ENDPOINT']
|
||||
use Rack::Protection::PathTraversal
|
||||
use Rack::SSL if Endpoint.production?
|
||||
use Rack::PostBodyContentTypeParser
|
||||
use Rack::JSONP
|
||||
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
# TODO: Add implementation and documentation.
|
||||
put('/:id', scope: :admin) do
|
||||
put('/:id', scope: :private) do
|
||||
body service(:hooks).update(params)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'travis/api/app'
|
|||
class Travis::Api::App
|
||||
class Endpoint
|
||||
class Profile < Endpoint
|
||||
LOCALES = %w(en es fr ja eb nl pl pt-Br ru) # TODO how to figure these out
|
||||
|
||||
# Gives information about the currently logged in user.
|
||||
#
|
||||
# Example:
|
||||
|
@ -23,7 +25,7 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
put '/', scope: :private do
|
||||
raise NotImplementedError
|
||||
p params
|
||||
update_locale if valid_locale?
|
||||
'ok'
|
||||
end
|
||||
|
@ -45,17 +47,18 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
def locale
|
||||
params[:user][:locale]
|
||||
params[:profile][:locale].to_s
|
||||
end
|
||||
|
||||
def valid_locale?
|
||||
I18n.available_locales.include?(locale.to_sym) # ???
|
||||
LOCALES.include?(locale)
|
||||
end
|
||||
|
||||
def update_locale
|
||||
current_user.update_attributes!(:locale => locale.to_s)
|
||||
session[:locale] = locale # ???
|
||||
current_user.update_attribute(:locale, locale.to_s)
|
||||
# session[:locale] = locale # ???
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Travis::Api::App
|
|||
# Logging is set up by custom middleware
|
||||
disable :protection, :logging, :setup
|
||||
enable :raise_errors
|
||||
disable :dump_errors
|
||||
# disable :dump_errors
|
||||
register :subclass_tracker
|
||||
helpers :json_renderer
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user