mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 06:15:28 +08:00
3e50313fdc
Since rspec-rails 3, the default installation creates two helper files: * `spec_helper.rb` * `rails_helper.rb` `spec_helper.rb` is intended as a way of running specs that do not require Rails, whereas `rails_helper.rb` loads Rails (as Discourse's current `spec_helper.rb` does). For more information: https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files In this commit, I've simply replaced all instances of `spec_helper` with `rails_helper`, and renamed the original `spec_helper.rb`. This brings the Discourse project closer to the standard usage of RSpec in a Rails app. At present, every spec relies on loading Rails, but there are likely many that don't need to. In a future pull request, I hope to introduce a separate, minimal `spec_helper.rb` which can be used in tests which don't rely on Rails.
34 lines
1.2 KiB
Ruby
34 lines
1.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe Jobs::ExportCsvFile do
|
|
|
|
context '.execute' do
|
|
it 'raises an error when the entity is missing' do
|
|
expect { Jobs::ExportCsvFile.new.execute(user_id: "1") }.to raise_error(Discourse::InvalidParameters)
|
|
end
|
|
end
|
|
|
|
let :user_list_header do
|
|
['id','name','username','email','title','created_at','last_seen_at','last_posted_at','last_emailed_at','trust_level','approved','suspended_at','suspended_till','blocked','active','admin','moderator','ip_address','topics_entered','posts_read_count','time_read','topic_count','post_count','likes_given','likes_received','external_id','external_email', 'external_username', 'external_name', 'external_avatar_url']
|
|
end
|
|
|
|
let :user_list_export do
|
|
Jobs::ExportCsvFile.new.user_list_export
|
|
end
|
|
|
|
def to_hash(row)
|
|
Hash[*user_list_header.zip(row).flatten]
|
|
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')
|
|
|
|
user = to_hash(user_list_export.find{|u| u[0].to_i == user.id})
|
|
|
|
expect(user["external_id"]).to eq("123")
|
|
expect(user["external_email"]).to eq("test@test.com")
|
|
end
|
|
end
|