Permalink
Browse files

Delegate flush

  • Loading branch information...
1 parent 7c597cd commit dd02da830a553a0568d64673af6898815904fd9f @halogenandtoast halogenandtoast committed Jan 6, 2011
Showing with 17 additions and 1 deletion.
  1. +6 −0 lib/copycopter_client.rb
  2. +1 −1 lib/copycopter_client/sync.rb
  3. +10 −0 spec/copycopter_client/sync_spec.rb
View
@@ -34,6 +34,12 @@ def self.start_sync
sync.start
end
+ # Flush queued changed synchronously
+ # This is called from the Resque after perform "hook"
+ def self.flush
+ sync.flush
+ end
+
# Call this method to modify defaults in your initializers.
#
# @example
@@ -136,7 +136,7 @@ def register_job_hooks
alias_method :perform_without_copycopter, :perform
def perform
job_was_performed = perform_without_copycopter
- CopycopterClient.sync.flush
+ CopycopterClient.flush
job_was_performed
end
end
@@ -335,5 +335,15 @@ def violated(failure)
sync.should have_received(:start)
end
+
+ it "flushes from the top level" do
+ sync = build_sync
+ CopycopterClient.sync = sync
+ sync.stubs(:flush)
+
+ CopycopterClient.flush
+
+ sync.should have_received(:flush)
+ end
end

0 comments on commit dd02da8

Please sign in to comment.