2014-08-09 06:28:57 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Jobs::ExportCsvFile do
|
|
|
|
|
|
|
|
context '.execute' do
|
|
|
|
it 'raises an error when the entity is missing' do
|
|
|
|
lambda { Jobs::ExportCsvFile.new.execute(user_id: "1") }.should raise_error(Discourse::InvalidParameters)
|
|
|
|
end
|
2014-11-25 17:43:17 -05:00
|
|
|
end
|
|
|
|
|
2015-01-02 01:59:05 -05:00
|
|
|
let :user_list_header do
|
2014-11-25 17:43:17 -05:00
|
|
|
Jobs::ExportCsvFile.new.get_header('user')
|
|
|
|
end
|
|
|
|
|
2015-01-02 01:59:05 -05:00
|
|
|
let :user_list_export do
|
|
|
|
Jobs::ExportCsvFile.new.user_list_export
|
2014-11-25 17:43:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_hash(row)
|
2015-01-02 01:59:05 -05:00
|
|
|
Hash[*user_list_header.zip(row).flatten]
|
2014-11-25 17:43:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'exports sso data' do
|
|
|
|
SiteSetting.enable_sso = true
|
|
|
|
user = Fabricate(:user)
|
|
|
|
user.create_single_sign_on_record(external_id: "123", last_payload: "xxx", external_email: 'test@test.com')
|
|
|
|
|
2015-01-02 01:59:05 -05:00
|
|
|
user = to_hash(user_list_export.find{|u| u[0] == user.id})
|
2014-08-09 06:28:57 -04:00
|
|
|
|
2014-11-25 17:43:17 -05:00
|
|
|
user["external_id"].should == "123"
|
|
|
|
user["external_email"].should == "test@test.com"
|
2014-08-09 06:28:57 -04:00
|
|
|
end
|
|
|
|
end
|