2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-08-09 18:28:57 +08:00
|
|
|
|
|
|
|
describe Jobs::ExportCsvFile do
|
|
|
|
|
|
|
|
context '.execute' do
|
|
|
|
it 'raises an error when the entity is missing' do
|
2014-12-31 22:55:03 +08:00
|
|
|
expect { Jobs::ExportCsvFile.new.execute(user_id: "1") }.to raise_error(Discourse::InvalidParameters)
|
2014-08-09 18:28:57 +08:00
|
|
|
end
|
2014-11-26 06:43:17 +08:00
|
|
|
end
|
|
|
|
|
2017-09-14 00:09:11 +08:00
|
|
|
let(:user_list_header) {
|
|
|
|
%w{
|
|
|
|
id name username email title created_at last_seen_at last_posted_at
|
|
|
|
last_emailed_at trust_level approved suspended_at suspended_till blocked
|
2017-09-14 00:25:58 +08:00
|
|
|
active admin moderator ip_address staged topics_entered posts_read_count
|
2017-09-14 00:09:11 +08:00
|
|
|
time_read topic_count post_count likes_given likes_received location
|
|
|
|
website views external_id external_email external_username external_name
|
|
|
|
external_avatar_url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:user_list_export) { Jobs::ExportCsvFile.new.user_list_export }
|
2014-11-26 06:43:17 +08:00
|
|
|
|
|
|
|
def to_hash(row)
|
2015-01-02 14:59:05 +08:00
|
|
|
Hash[*user_list_header.zip(row).flatten]
|
2014-11-26 06:43:17 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'exports sso data' do
|
2017-12-23 16:46:48 +08:00
|
|
|
SiteSetting.sso_url = "https://www.example.com/sso"
|
2014-11-26 06:43:17 +08:00
|
|
|
SiteSetting.enable_sso = true
|
|
|
|
user = Fabricate(:user)
|
2017-03-21 18:11:03 +08:00
|
|
|
user.user_profile.update_column(:location, "La La Land")
|
2014-11-26 06:43:17 +08:00
|
|
|
user.create_single_sign_on_record(external_id: "123", last_payload: "xxx", external_email: 'test@test.com')
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
user = to_hash(user_list_export.find { |u| u[0].to_i == user.id })
|
2014-08-09 18:28:57 +08:00
|
|
|
|
2017-03-21 18:11:03 +08:00
|
|
|
expect(user["location"]).to eq("La La Land")
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(user["external_id"]).to eq("123")
|
|
|
|
expect(user["external_email"]).to eq("test@test.com")
|
2014-08-09 18:28:57 +08:00
|
|
|
end
|
|
|
|
end
|