travis-api/spec/integration/v2/users_spec.rb
Piotr Sarnacki c6e3c29a57 Load the data for integration tests upfront
We can do it, because we use :transaction strategy with DatabaseCleaner,
which starts transaction before each test and rollbacks after it. That
way data before each test is consistent.

The big advantage of such approach is that tests are fast now - we need
to only load Scenario data once.

One of the drawbacks, on the other hand, is that we need to always load
this data, even if no integration tests need running.

We can try to be smart about it and check if any integration tests are
loaded.
2013-01-26 00:00:42 +01:00

26 lines
856 B
Ruby

require 'spec_helper'
describe 'Users' do
let(:user) { User.first }
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}" } }
context 'PUT /users/:id' do
it 'updates user data and returns the user' do
params = {user: {id: user.id, locale: 'pl'}}
response = put "/users/#{user.id}", params, headers
response.should be_successful
response.should deliver_json_for('result' => true, 'flash' => [{ 'notice' => 'Your profile was successfully updated.' }])
user.reload.locale.should == 'pl'
end
end
context 'POST /users/sync' do
it 'syncs current_user repos' do
response = post "/users/sync", {}, headers
response.should be_successful
end
end
end