From 97e06c556f038b5acfea7771ccb7328fac976629 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 25 Sep 2012 17:16:27 +0200 Subject: [PATCH 01/13] add hubble --- lib/travis/api/app.rb | 3 +++ lib/travis/api/app/responder.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 7a06db03..f242ce93 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -10,6 +10,8 @@ require 'rack/contrib' require 'active_record' require 'redis' require 'gh' +require 'hubble' +require 'hubble/middleware' # Rack class implementing the HTTP API. # Instances respond to #call. @@ -51,6 +53,7 @@ class Travis::Api::App def initialize @app = Rack::Builder.app do + 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::JSONP diff --git a/lib/travis/api/app/responder.rb b/lib/travis/api/app/responder.rb index db20f7ef..6fc6bcff 100644 --- a/lib/travis/api/app/responder.rb +++ b/lib/travis/api/app/responder.rb @@ -20,6 +20,8 @@ class Travis::Api::App # # Logging is set up by custom middleware disable :protection, :logging, :setup + enable :raise_errors + disable :dump_errors register :subclass_tracker helpers :json_renderer end From 68caf0e26e8400c2c033f651626535b4949f5d6d Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 25 Sep 2012 17:54:13 +0200 Subject: [PATCH 02/13] add newrelic --- config/newrelic.yml | 39 +++++++++++++++++++++++++++++++++++++++ lib/travis/api/app.rb | 1 + 2 files changed, 40 insertions(+) create mode 100644 config/newrelic.yml diff --git a/config/newrelic.yml b/config/newrelic.yml new file mode 100644 index 00000000..d1ab9cd0 --- /dev/null +++ b/config/newrelic.yml @@ -0,0 +1,39 @@ +--- +staging: + error_collector: + capture_source: true + enabled: true + ignore_errors: ActionController::RoutingError + apdex_t: 0.5 + ssl: false + monitor_mode: true + license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %> + developer_mode: false + app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> + transaction_tracer: + record_sql: obfuscated + enabled: true + stack_trace_threshold: 0.5 + transaction_threshold: apdex_f + capture_params: false + log_level: info + +production: + error_collector: + capture_source: true + enabled: true + ignore_errors: ActionController::RoutingError + apdex_t: 0.5 + ssl: false + monitor_mode: true + license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %> + developer_mode: false + app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> + transaction_tracer: + record_sql: obfuscated + enabled: true + stack_trace_threshold: 0.5 + transaction_threshold: apdex_f + capture_params: false + log_level: info + diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index f242ce93..8be6e2ee 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -12,6 +12,7 @@ require 'redis' require 'gh' require 'hubble' require 'hubble/middleware' +require 'newrelic_rpm' # Rack class implementing the HTTP API. # Instances respond to #call. From f09cb3cac0290dcb745ae6a913b73188c375199b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 25 Sep 2012 18:47:05 +0200 Subject: [PATCH 03/13] set the amqp configuration --- lib/travis/api/app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 8be6e2ee..d8531f8d 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -84,6 +84,7 @@ class Travis::Api::App end def self.setup_travis + Travis::Amqp.config = Travis.config.amqp Travis::Database.connect Travis::Services.constants.each do |name| From 6dc28f0c49cef93dd24ee980b018719af02180df Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 26 Sep 2012 11:58:57 +0200 Subject: [PATCH 04/13] add Rack::PostBodyContentTypeParser and fix locale update --- Gemfile | 1 + lib/travis/api/app.rb | 1 + lib/travis/api/app/endpoint/hooks.rb | 2 +- lib/travis/api/app/endpoint/profile.rb | 13 ++++++++----- lib/travis/api/app/responder.rb | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) 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 From b21deccf2d76a0f8d00ab417a3609e4fb9d9bf98 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 26 Sep 2012 12:33:51 +0200 Subject: [PATCH 05/13] fix hooks --- lib/travis/api/app/endpoint/hooks.rb | 2 +- lib/travis/api/app/endpoint/profile.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app/endpoint/hooks.rb b/lib/travis/api/app/endpoint/hooks.rb index c28de0fa..cfea0a89 100644 --- a/lib/travis/api/app/endpoint/hooks.rb +++ b/lib/travis/api/app/endpoint/hooks.rb @@ -12,7 +12,7 @@ class Travis::Api::App # TODO: Add implementation and documentation. put('/:id', scope: :private) do - body service(:hooks).update(params) + body service(:hooks).update(params[:hook]) end end end diff --git a/lib/travis/api/app/endpoint/profile.rb b/lib/travis/api/app/endpoint/profile.rb index 2544f56b..74d45f9a 100644 --- a/lib/travis/api/app/endpoint/profile.rb +++ b/lib/travis/api/app/endpoint/profile.rb @@ -24,8 +24,7 @@ class Travis::Api::App body service(:user).find_one, type: :user end - put '/', scope: :private do -p params + put '/:id?', scope: :private do update_locale if valid_locale? 'ok' end From 228f71f407787f669d6d5ee731a2d5409918dc8e Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 26 Sep 2012 23:36:18 +0200 Subject: [PATCH 06/13] bundle update --- Gemfile.lock | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c7f16036..509e81b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,13 @@ GIT specs: micro_migrations (0.0.1) +GIT + remote: git://github.com/rack/rack-contrib.git + revision: b7e7c38fd02c3b5da91aa57af78b3f571c6ebcd0 + specs: + rack-contrib (1.1.0) + rack (>= 0.9.1) + GIT remote: git://github.com/rkh/gh.git revision: affde20a4fecb1023f2e7031734b9386a76d22c2 @@ -33,7 +40,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: ea7a1678a0388e586ac4778a9b6ee56a11dfb0aa + revision: a4b1446e3746a5ff59a5438a34f7b2471e33a731 branch: sf-more-services specs: travis-core (0.0.1) @@ -162,8 +169,6 @@ GEM rack (1.4.1) rack-cache (1.2) rack (>= 0.4) - rack-contrib (1.1.0) - rack (>= 0.9.1) rack-protection (1.2.0) rack rack-ssl (1.3.2) @@ -235,6 +240,7 @@ DEPENDENCIES hubble! micro_migrations! mocha (~> 0.12) + rack-contrib! rake (~> 0.9.2) rerun rspec (~> 2.11) From 4808981f4f627a3125b4161a46c1fb09a1e96eb4 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 27 Sep 2012 15:27:26 +0200 Subject: [PATCH 07/13] allow using an oauth proxy --- lib/travis/api/app/endpoint/authorization.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index f9be8f6a..73b1d960 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -126,13 +126,18 @@ class Travis::Api::App private + def oauth_endpoint + proxy = Travis.config.oauth2.proxy + proxy ? File.join(proxy, request.fullpath) : url + end + def handshake config = Travis.config.oauth2 endpoint = Addressable::URI.parse(config.authorization_server) values = { client_id: config.client_id, scope: config.scope, - redirect_uri: url + redirect_uri: oauth_endpoint } if params[:code] and state_ok?(params[:state]) From f2e8ccafc1efb0da8e14c2e03021d27dd1b40431 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 27 Sep 2012 15:38:56 +0200 Subject: [PATCH 08/13] remove /profile, add /user and /accounts --- lib/travis/api/app/endpoint/accounts.rb | 11 ++++ lib/travis/api/app/endpoint/authorization.rb | 4 +- lib/travis/api/app/endpoint/profile.rb | 63 -------------------- lib/travis/api/app/endpoint/user.rb | 43 +++++++++++++ 4 files changed, 56 insertions(+), 65 deletions(-) create mode 100644 lib/travis/api/app/endpoint/accounts.rb delete mode 100644 lib/travis/api/app/endpoint/profile.rb create mode 100644 lib/travis/api/app/endpoint/user.rb diff --git a/lib/travis/api/app/endpoint/accounts.rb b/lib/travis/api/app/endpoint/accounts.rb new file mode 100644 index 00000000..0626e94f --- /dev/null +++ b/lib/travis/api/app/endpoint/accounts.rb @@ -0,0 +1,11 @@ +require 'travis/api/app' + +class Travis::Api::App + class Endpoint + class Accounts < Endpoint + get '/', scope: :private do + body service(:account).find_all, type: :account + end + end + end +end diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index f9be8f6a..940237fd 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -180,8 +180,8 @@ class Travis::Api::App def user_for_github_token(token) data = GH.with(token: token.to_s) { GH['user'] } scopes = parse_scopes data.headers['x-oauth-scopes'] - user = User.find_by_github_id(data['id']) - user ||= User.create! user_info(data, github_oauth_token: token) + user = ::User.find_by_github_id(data['id']) + user ||= ::User.create! user_info(data, github_oauth_token: token) halt 403, 'not a Travis user' if user.nil? halt 403, 'insufficient access' unless acceptable? scopes diff --git a/lib/travis/api/app/endpoint/profile.rb b/lib/travis/api/app/endpoint/profile.rb deleted file mode 100644 index 74d45f9a..00000000 --- a/lib/travis/api/app/endpoint/profile.rb +++ /dev/null @@ -1,63 +0,0 @@ -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: - # - # { - # "user": { - # "email": "svenfuchs@artweb-design.de", - # "gravatar_id": "402602a60e500e85f2f5dc1ff3648ecb", - # "is_syncing": false, - # "locale": "de", - # "login": "svenfuchs", - # "name": "Sven Fuchs", - # "synced_at": "2012-08-14T22:11:21Z" - # } - # } - get '/', scope: :private do - body service(:user).find_one, type: :user - end - - put '/:id?', scope: :private do - update_locale if valid_locale? - 'ok' - end - - # TODO: Add implementation and documentation. - post '/sync', scope: :private do - sync_user(current_user) - 204 - end - - private - - def sync_user(user) - unless user.is_syncing? - publisher = Travis::Amqp::Publisher.new('sync.user') - publisher.publish({ user_id: user.id }, type: 'sync') - user.update_column(:is_syncing, true) - end - end - - def locale - params[:profile][:locale].to_s - end - - def valid_locale? - LOCALES.include?(locale) - end - - def update_locale - current_user.update_attribute(:locale, locale.to_s) - # session[:locale] = locale # ??? - end - end - end -end - diff --git a/lib/travis/api/app/endpoint/user.rb b/lib/travis/api/app/endpoint/user.rb new file mode 100644 index 00000000..2d012c45 --- /dev/null +++ b/lib/travis/api/app/endpoint/user.rb @@ -0,0 +1,43 @@ +require 'travis/api/app' + +class Travis::Api::App + class Endpoint + class User < Endpoint + # Gives information about the currently logged in user. + # + # Example: + # + # { + # "user": { + # "name": "Sven Fuchs", + # "login": "svenfuchs", + # "email": "svenfuchs@artweb-design.de", + # "gravatar_id": "402602a60e500e85f2f5dc1ff3648ecb", + # "locale": "de", + # "is_syncing": false, + # "synced_at": "2012-08-14T22:11:21Z" + # } + # } + get '/:id?', scope: :private do + body current_user + end + + put '/:id?', scope: :private do + services(:user).update_locale(locale) + 204 + end + + # TODO: Add implementation and documentation. + post '/sync', scope: :private do + services(:user).sync + 204 + end + + private + + def locale + params[:profile][:locale] + end + end + end +end From fbd89ceeb0c4d3682e26fe04f7f105248153273b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 27 Sep 2012 17:14:50 +0200 Subject: [PATCH 09/13] fix accounts and hooks endpoints --- lib/travis/api/app/endpoint/accounts.rb | 2 +- lib/travis/api/app/endpoint/authorization.rb | 2 +- lib/travis/api/app/endpoint/hooks.rb | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/travis/api/app/endpoint/accounts.rb b/lib/travis/api/app/endpoint/accounts.rb index 0626e94f..40ea1dad 100644 --- a/lib/travis/api/app/endpoint/accounts.rb +++ b/lib/travis/api/app/endpoint/accounts.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Accounts < Endpoint get '/', scope: :private do - body service(:account).find_all, type: :account + body service(:account).find_all, type: :accounts end end end diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index 940237fd..2c78a3e7 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -115,7 +115,7 @@ class Travis::Api::App get '/post_message' do handshake do |user, token, target_origin| halt 403, invalid_target(target_origin) unless target_ok? target_origin - rendered_user = Travis::Api.data(service(:user, user).find_one, type: :user, version: :v2) + rendered_user = Travis::Api.data(user, version: :v2) post_message(token: token, user: rendered_user, target_origin: target_origin) end end diff --git a/lib/travis/api/app/endpoint/hooks.rb b/lib/travis/api/app/endpoint/hooks.rb index cfea0a89..e2ea4c78 100644 --- a/lib/travis/api/app/endpoint/hooks.rb +++ b/lib/travis/api/app/endpoint/hooks.rb @@ -5,8 +5,7 @@ class Travis::Api::App # TODO: Add documentation. class Hooks < Endpoint # TODO: Add implementation and documentation. - # TODO scope: :private - get('/') do + get('/', scope: :private) do body service(:hooks).find_all(params), type: :hooks end From 81022ea7b46277696a6e164043913a251c57db6c Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 27 Sep 2012 18:27:09 +0200 Subject: [PATCH 10/13] rename endpoint to users and fix endpoint specs --- Gemfile.lock | 2 +- .../api/app/endpoint/{user.rb => users.rb} | 2 +- spec/endpoint/accounts_spec.rb | 24 +++++++++++++++++++ .../{profile_spec.rb => users_spec.rb} | 17 +++---------- 4 files changed, 29 insertions(+), 16 deletions(-) rename lib/travis/api/app/endpoint/{user.rb => users.rb} (97%) create mode 100644 spec/endpoint/accounts_spec.rb rename spec/endpoint/{profile_spec.rb => users_spec.rb} (63%) diff --git a/Gemfile.lock b/Gemfile.lock index 509e81b7..776d163e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: a4b1446e3746a5ff59a5438a34f7b2471e33a731 + revision: 6d8de39fa098965aad52b51f8f9a3f5490e7def5 branch: sf-more-services specs: travis-core (0.0.1) diff --git a/lib/travis/api/app/endpoint/user.rb b/lib/travis/api/app/endpoint/users.rb similarity index 97% rename from lib/travis/api/app/endpoint/user.rb rename to lib/travis/api/app/endpoint/users.rb index 2d012c45..0d52d0e7 100644 --- a/lib/travis/api/app/endpoint/user.rb +++ b/lib/travis/api/app/endpoint/users.rb @@ -2,7 +2,7 @@ require 'travis/api/app' class Travis::Api::App class Endpoint - class User < Endpoint + class Users < Endpoint # Gives information about the currently logged in user. # # Example: diff --git a/spec/endpoint/accounts_spec.rb b/spec/endpoint/accounts_spec.rb new file mode 100644 index 00000000..c3eafdab --- /dev/null +++ b/spec/endpoint/accounts_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Travis::Api::App::Endpoint::Accounts do + include Travis::Testing::Stubs + let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) } + + before do + User.stubs(:find_by_github_id).returns(user) + User.stubs(:find).returns(user) + user.stubs(:repositories).returns(stub(administratable: stub(select: [repository]))) + user.stubs(:attributes).returns(:id => user.id, :login => user.login, :name => user.name) + end + + it 'includes accounts' do + get('/accounts', access_token: access_token.to_s).should be_ok + parsed_body['accounts'].should == [{ + 'id' => user.id, + 'login' => user.login, + 'name' => user.name, + 'type' => 'user', + 'reposCount' => nil + }] + end +end diff --git a/spec/endpoint/profile_spec.rb b/spec/endpoint/users_spec.rb similarity index 63% rename from spec/endpoint/profile_spec.rb rename to spec/endpoint/users_spec.rb index 612a8e9c..6c8c7110 100644 --- a/spec/endpoint/profile_spec.rb +++ b/spec/endpoint/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Travis::Api::App::Endpoint::Profile do +describe Travis::Api::App::Endpoint::Users do include Travis::Testing::Stubs let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) } @@ -11,11 +11,11 @@ describe Travis::Api::App::Endpoint::Profile do end it 'needs to be authenticated' do - get('/profile').should_not be_ok + get('/users').should_not be_ok end it 'replies with the current user' do - get('/profile', access_token: access_token.to_s).should be_ok + get('/users', access_token: access_token.to_s).should be_ok parsed_body['user'].should == { 'id' => user.id, 'login' => user.login, @@ -27,15 +27,4 @@ describe Travis::Api::App::Endpoint::Profile do 'synced_at' => user.synced_at.strftime('%Y-%m-%dT%H:%M:%SZ') } end - - it 'includes accounts' do - get('/profile', access_token: access_token.to_s).should be_ok - parsed_body['accounts'].should == [{ - 'id' => user.id, - 'login' => user.login, - 'name' => user.name, - 'type' => 'user', - 'reposCount' => nil - }] - end end From 8924ebffffceb5869622e0c73cda90779750c881 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 27 Sep 2012 21:58:24 +0200 Subject: [PATCH 11/13] it is service, not services --- lib/travis/api/app/endpoint/users.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/endpoint/users.rb b/lib/travis/api/app/endpoint/users.rb index 0d52d0e7..ac3e4feb 100644 --- a/lib/travis/api/app/endpoint/users.rb +++ b/lib/travis/api/app/endpoint/users.rb @@ -23,13 +23,13 @@ class Travis::Api::App end put '/:id?', scope: :private do - services(:user).update_locale(locale) + service(:user).update_locale(locale) 204 end # TODO: Add implementation and documentation. post '/sync', scope: :private do - services(:user).sync + service(:user).sync 204 end From fda18942dcda05e9c51714f3f96dd473182c9df2 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 27 Sep 2012 22:54:17 +0200 Subject: [PATCH 12/13] fix locale param name --- lib/travis/api/app/endpoint/users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/users.rb b/lib/travis/api/app/endpoint/users.rb index ac3e4feb..60399ca1 100644 --- a/lib/travis/api/app/endpoint/users.rb +++ b/lib/travis/api/app/endpoint/users.rb @@ -36,7 +36,7 @@ class Travis::Api::App private def locale - params[:profile][:locale] + params[:user][:locale] end end end From 3e371251f7ae5c3ebf4ce0186783183afaabd599 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 28 Sep 2012 10:41:45 +0200 Subject: [PATCH 13/13] bump deps --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 776d163e..26a10c9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,15 +32,15 @@ GIT GIT remote: git://github.com/roidrage/hubble.git - revision: 8972b940a4f927927d2a4bdb250b3c98c04692a6 + revision: f5e6301ac24eabeebaf8f4485d71cdcf93b2f3f8 specs: hubble (0.1.2) faraday - json (~> 1.6.5) + json (~> 1.6) GIT remote: git://github.com/travis-ci/travis-core.git - revision: 6d8de39fa098965aad52b51f8f9a3f5490e7def5 + revision: 6c974f0c0ad529748e95222c3145a0f085311ad1 branch: sf-more-services specs: travis-core (0.0.1) @@ -128,15 +128,15 @@ GEM activesupport faraday (0.8.4) multipart-post (~> 1.1) - foreman (0.59.0) + foreman (0.60.0) thor (>= 0.13.6) hashr (0.0.22) hike (1.2.1) hitimes (1.1.1) i18n (0.6.1) journey (1.0.4) - json (1.6.7) - listen (0.5.1) + json (1.7.5) + listen (0.5.2) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -147,7 +147,7 @@ GEM avl_tree (~> 1.1.2) hitimes (~> 1.1) mime-types (1.19) - mocha (0.12.4) + mocha (0.12.5) metaclass (~> 0.0.1) multi_json (1.3.6) multipart-post (1.1.5) @@ -173,7 +173,7 @@ GEM rack rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) railties (3.2.8) actionpack (= 3.2.8) @@ -217,7 +217,7 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - thin (1.4.1) + thin (1.5.0) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0)