diff --git a/Gemfile b/Gemfile index 01bb5f3a..22cd778d 100644 --- a/Gemfile +++ b/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' diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index d8531f8d..200c1d6c 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -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 diff --git a/lib/travis/api/app/endpoint/hooks.rb b/lib/travis/api/app/endpoint/hooks.rb index fd590db5..c28de0fa 100644 --- a/lib/travis/api/app/endpoint/hooks.rb +++ b/lib/travis/api/app/endpoint/hooks.rb @@ -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 diff --git a/lib/travis/api/app/endpoint/profile.rb b/lib/travis/api/app/endpoint/profile.rb index e5b62f3e..2544f56b 100644 --- a/lib/travis/api/app/endpoint/profile.rb +++ b/lib/travis/api/app/endpoint/profile.rb @@ -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 + diff --git a/lib/travis/api/app/responder.rb b/lib/travis/api/app/responder.rb index 6fc6bcff..36e3a5c4 100644 --- a/lib/travis/api/app/responder.rb +++ b/lib/travis/api/app/responder.rb @@ -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