From 4f33a937691ef43db949190283527825b29abaa9 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 11 Oct 2012 01:00:53 +0200 Subject: [PATCH] Fix PUT /users/:id and add integration test for it --- lib/travis/api/app/responders/service.rb | 2 +- spec/integration/v2/users_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 spec/integration/v2/users_spec.rb diff --git a/lib/travis/api/app/responders/service.rb b/lib/travis/api/app/responders/service.rb index b045c498..aeda92ea 100644 --- a/lib/travis/api/app/responders/service.rb +++ b/lib/travis/api/app/responders/service.rb @@ -7,7 +7,7 @@ module Travis::Api::App::Responders def apply # TODO add caching headers depending on the resource data = result - flash.concat(data.messages) if data && resource.respond_to?(:messages) + flash.concat(data.messages) if data && data.respond_to?(:messages) data end diff --git a/spec/integration/v2/users_spec.rb b/spec/integration/v2/users_spec.rb new file mode 100644 index 00000000..4032855b --- /dev/null +++ b/spec/integration/v2/users_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'Users' do + let(:user) { Factory(:user, locale: 'en') } + let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) } + let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json', 'HTTP_AUTHORIZATION' => "token #{token}" } } + + it 'GET /workers' do + params = {user: {id: user.id, locale: 'pl'}} + response = put "/users/#{user.id}", params, headers + response.should be_successful + user.reload.locale.should == 'pl' + end +end +