Added some missing model specs + PaperTrail session fix

This commit is contained in:
Priit Tark 2015-02-02 18:09:01 +02:00
parent c248a957a6
commit a637eb5e01
39 changed files with 1447 additions and 845 deletions

View file

@ -1,32 +1,33 @@
require 'rails_helper'
describe Repp::DomainV1 do
let(:api_user) { Fabricate(:api_user) }
before(:each) { create_settings }
before :all do
create_settings
@registrar1 = Fabricate(:registrar1)
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
end
describe 'GET /repp/v1/domains' do
it 'returns domains of the current registrar' do
Fabricate.times(2, :domain, registrar: api_user.registrar)
Fabricate.times(2, :domain, registrar: @api_user.registrar)
get_with_auth '/repp/v1/domains', {}, api_user
expect(response.status).to eq(200)
get_with_auth '/repp/v1/domains', {}, @api_user
response.status.should == 200
body = JSON.parse(response.body)
expect(body['total_pages']).to eq(1)
body['total_pages'].should == 1
# TODO: Maybe there is a way not to convert from and to json again
expect(body['domains'].to_json).to eq(api_user.registrar.domains.to_json)
body['domains'].to_json.should == @api_user.reload.registrar.domains.to_json
log = ApiLog::ReppLog.last
expect(log[:request_path]).to eq('/repp/v1/domains')
expect(log[:request_method]).to eq('GET')
expect(log[:request_params]).to eq('{}')
expect(log[:response].length).to be > 20
expect(log[:response_code]).to eq('200')
expect(log[:api_user_name]).to eq('gitlab')
expect(log[:api_user_registrar]).to eq('Registrar OÜ')
expect(log[:ip]).to eq('127.0.0.1')
log[:request_path].should == '/repp/v1/domains'
log[:request_method].should == 'GET'
log[:request_params].should == '{}'
log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1'
log[:ip].should == '127.0.0.1'
end
end
end