From bafa91f255999b991ee84d61e7908f68d6fcd6bb Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 4 May 2017 17:23:41 +1000 Subject: [PATCH] initial create user job --- app/jobs/jobs.rb | 4 ++++ app/jobs/regular/donation_user.rb | 8 ++++++++ plugin.rb | 3 +-- spec/jobs/regular/donation_user_spec.rb | 10 ++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/jobs/jobs.rb create mode 100644 app/jobs/regular/donation_user.rb create mode 100644 spec/jobs/regular/donation_user_spec.rb diff --git a/app/jobs/jobs.rb b/app/jobs/jobs.rb new file mode 100644 index 0000000..6145631 --- /dev/null +++ b/app/jobs/jobs.rb @@ -0,0 +1,4 @@ +load File.expand_path('../award_group.rb', __FILE__) +load File.expand_path('../grant_badge.rb', __FILE__) + +load File.expand_path('../regular/donation_user.rb', __FILE__) diff --git a/app/jobs/regular/donation_user.rb b/app/jobs/regular/donation_user.rb new file mode 100644 index 0000000..b8f4943 --- /dev/null +++ b/app/jobs/regular/donation_user.rb @@ -0,0 +1,8 @@ + +module Jobs + class DonationUser < ::Jobs::Base + def execute(args) + User.create(args) + end + end +end diff --git a/plugin.rb b/plugin.rb index 1ffc6e7..e1ccb33 100644 --- a/plugin.rb +++ b/plugin.rb @@ -11,8 +11,7 @@ load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__) enabled_site_setting :discourse_donations_enabled after_initialize do - load File.expand_path('../app/jobs/award_group.rb', __FILE__) - load File.expand_path('../app/jobs/grant_badge.rb', __FILE__) + load File.expand_path('../app/jobs/jobs.rb', __FILE__) # Must be placed on every page for fraud protection. header_script = '' diff --git a/spec/jobs/regular/donation_user_spec.rb b/spec/jobs/regular/donation_user_spec.rb new file mode 100644 index 0000000..7e1fde7 --- /dev/null +++ b/spec/jobs/regular/donation_user_spec.rb @@ -0,0 +1,10 @@ + +RSpec.describe Jobs::DonationUser, type: :job do + it { should respond_to(:execute).with(1).arguments } + + it 'creates a new user' do + args = { email: 'foo@example.com', username: 'something' } + User.expects(:create).with(args) + subject.execute(args) + end +end