Fix PUT /users/:id and add integration test for it

This commit is contained in:
Piotr Sarnacki 2012-10-11 01:00:53 +02:00
parent d17439513f
commit 4f33a93769
2 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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